First let me get some particulars out of the way. I am using CrossStudio 2.0.9 for MSP430 for my project. Currently I am using TIs EXP430FG4618 development board for some testing, I am using the MSP430FG4618 on the board (which may seem obvious, but there are actually two different MSP430s on that board).
I am working on implementing a bootloader into my system. The unit is wireless so my plan is to have a bootloader the unit will go to once it starts up, and two sections for the code. One of the code sections will be temporary storage for the new program, while the other section is running and receiving the new code.
I have never done one before and as such I am trying to break it down into small steps. I have used the section placement file, and the #pragma codeseg command* to make a BOOT section in flash, starting at 0x4000 with a size of 0x0100, and CODE_A section starting at 0x4100 with a size of 0x0100. So far the bootloader simply turns on an LED, so I can see that it has run, and then tries to jump to the CODE_A section, which toggles a second LED.
At the end of the code in the BOOT section, I am trying to use function pointers to jump to the start address of the CODE_A section. Currently both sections of code are defined in the one project, so I could simply call the function in the CODE_A section rather than try to jump to the address, however that would do me no good in the long run, since they will inevitably be separate. If I set the pointer to be &CODE_A_main like this,
func_ptr = (int(*)())&CODE_A_main;
it works fine and jumps to the function at the start of the section (at address 0x4100), however if I set the pointer to 0x4100, like this,
func_ptr = (int(*)())0x4100;
the MSP430 seems to do a reset and goes back to the start of the CrossStudio init code.
Looking at the disassembly I can see that the code in address 0x4100 is the same using both methods. When the first method is used, the disassembly shows that the jump command is going to address 0x4200, which is the start of the CrossStudio init code, and there are two instructions, that are not there when using the second method. They are
0x4200 0041 BR SP
0x4202 0000 BRA PC
If anyone has any ideas regarding what I could do to solve my problem, or point me in the right direction it would be much appreciated.
Thanks for your time,
* which reminds me, in the "Linking and section placement" section of the help, there is a typo in the example of how to use the #pragma codeseg directive. It says #pragma codeseq.
Please sign in to leave a comment.