This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi everyone,
I have written a custom bootloader and want it to jump to my application. The jump address is calculated by reading the reset vector address from the application image (using a hard-coded address), then jumping to that address. This approach works fine if the application is in the 16-bit address space, but my final design places my application at 0x10000 (reset vector at 0x1007E). My bootloader starts at 0xDC00 and ends at 0xFFFF, and my application starts at 0x10000 and ends at 0x2A000.
My question is this - how do I use the 16-bit value stored in the reset vector of my application to jump to the 20-bit address I need? I have large code and large data models enabled, and can manually jump to the c_init() routine if I hard code its address in my bootloader, but I want to read the proper address from the reset vector as the compiler changes that address with each build.
I am using CCS 8.3, and have tried my code on the MSP-EXP430FR5994 board and my own hardware (I'm using the MSP430FR5964).
I have assembly and C code that jumps to the correct address if I place my application at 0x4000 (or any other 16-bit address), and tried using the following (which doesn't work):
asm( " MOVA #1007Eh, R12" ); // Set R12 to the address of my application reset vector entry (at address 0x1007E)
asm( " MOV.W @R12, R13" ); // Load reset vector value into R13
asm( " MOVA @R13, PC" ); // Jump to the reset vector address value.
The middle line above only loads 16-bits, so the last line jumps to the incorrect location.
I've combed through the TI documentation on large code models and have everything working but this one thing. Any ideas?
Hi,
1. I am afraid that you can't put a 20-bit address into the reset vector, because reset vector only has two byte area. That's how MSP430 was designed as a 16-bit MCU.
2. My advice is that spare some area below 0xDC00 as the application code area. And put vector table and a part of main memory code in there. I made a example for you(based on f5529) :
The memory configuration of MSPboot:
MEMORY
{
SFR : origin = 0x0000, length = 0x0010
PERIPHERALS_8BIT : origin = 0x0010, length = 0x00F0
PERIPHERALS_16BIT : origin = 0x0100, length = 0x0100
// RAM from _NonReserved_RAM_Start - __RAM_End
RAM : origin = 0x2408, length = 0x1FF8
// Flash from __Boot_Start -( __Boot_SharedCallbacks or INT_VECTOR_TABLE)
FLASH : origin = 0xDC00, length = 0x237A
// Shared callbacks from __Boot_SharedCallbacks + Len (when used)
BOOT_SHARED_CALLBACKS : origin = 0xFF7A, length = 6
// Boot vector Table from __Boot_VectorTable- __Boot_Reset
INT_VECTOR_TABLE : origin = 0xFF80, length = 0x7E
// Boot reset from __Boot_Reset-_Flash_End
RESET : origin = 0xFFFE, length = 0x0002
}
The memory configuration of App:
MEMORY
{
SFR : origin = 0x0000, length = 0x0010
PERIPHERALS_8BIT : origin = 0x0010, length = 0x00F0
PERIPHERALS_16BIT : origin = 0x0100, length = 0x0100
// RAM from _NonReserved_RAM_Start - __RAM_End
RAM : origin = 0x2408, length = 0x1FF8
USBRAM : origin = 0x1C00, length = 0x800
// Info Mem Sections
INFOA : origin = 0x1980, length = 0x80
INFOB : origin = 0x1900, length = 0x80
INFOC : origin = 0x1880, length = 0x80
INFOD : origin = 0x1800, length = 0x80
// Flash from _App_Start -> (APP_PROXY_VECTORS-1)
FLASH : origin = 0x4402, length = 0x9700
FLASH2 : origin = 0x10000, length = 0x14400
// Interrupt Proxy table from _App_Proxy_Vector_Start->(RESET-1)
APP_PROXY_VECTORS : origin = 0xDB02, length = 252
// App reset from _App_Reset_Vector
RESET : origin = 0xDBFE, length = 0x0002
}
Hi Eason,
That makes complete sense. I like your solution and will make a shared callback area part of my firmware update.
Thanks!
**Attention** This is a public forum