cancel
Showing results for 
Search instead for 
Did you mean: 

Implementation of bootloader and application in memory space

rsoc
Associate III

I am attempting to integrate a bootloader and an application into my stm32f7 mcu. I understand this has been done numerous times previously, so apologies for probably small questions leading to larger ones.

I am running into issues on the jump function between my bootloader (located at 0x08000000) to the application firmware (located at 0x0800FA00). The bootloader occupies two sectors of memory, and the firmware the remaining 8, in single bank memory mode. When i attempt to jump between the bootloader and the application, I would assume I would jump to memory address 0x0800FA00 + 4, which is the offset from the top of the application, but that does not seem to be successful. Prior to this jump, I map the interrupt vector to 0x0800FA00. (code snippet below)

//Jump function
void Bootloader_JumpToApplication(void)
{
    pFunction appEntry;
    uint32_t appStack;
 
    appStack = (uint32_t) *((__IO uint32_t *) APPLICATION_ADDRESS);
    appEntry = (pFunction) *(__IO uint32_t *) (APPLICATION_ADDRESS + 4);
    SCB->VTOR = APPLICATION_ADDRESS;
    __set_MSP(appStack);
    appEntry();
}

I guess my initial question is assuming I place the application and the bootloader in the aformented spaces in memory (which I am positive I am doing), is there something I am missing on the jump function? Should I be going to a different place in memory on the jump? A secondary question is if I just wanted to test my application firmware at 0x0800FA00 without something at the top of flash, is this possible? I dont think it is, but I wanted to confirm.

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions

0x0800FA00 doesn't strike me as a valid sector boundary for the F7 flash.

Make sure the SP/PC you're reading aren't erased data, ie 0xFFFFFFFF, and are in fact valid looking data, ie within RAM and within FLASH respectively.

Use the Debugger.

Step the transition and confirm that it is landing in your App Reset_Handler, or NOT

The debugger can also let you set the PC anyway you want, if you don't have a table/code starting in the 0x08000000 region, then stop the debugger, and set it someplace else, and start there.

Make a stub loader that just loads new SP/PC values in the loader's Reset_Handler, then something like Keil will just allow you to "run to main()" for the App.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3

0x0800FA00 doesn't strike me as a valid sector boundary for the F7 flash.

Make sure the SP/PC you're reading aren't erased data, ie 0xFFFFFFFF, and are in fact valid looking data, ie within RAM and within FLASH respectively.

Use the Debugger.

Step the transition and confirm that it is landing in your App Reset_Handler, or NOT

The debugger can also let you set the PC anyway you want, if you don't have a table/code starting in the 0x08000000 region, then stop the debugger, and set it someplace else, and start there.

Make a stub loader that just loads new SP/PC values in the loader's Reset_Handler, then something like Keil will just allow you to "run to main()" for the App.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

This definitely pointed me in the right direction, with regards to using the PC to control where the software goes to verify I am looking in the right place. Thank you! The code above was functional, but being used with the wrong address. I was not jumping to the reset handler of the other firmware. Additionally, the firmware was doing system inits which were not necessary a second time, getting itself stuck in a do while loop.

Sivasubramaniyan
Associate II

Can you please explain the details elaborately. I am also trying to jump from boot loader to application. My application is starting at 0x08040000. Whenever i am tried to jump the application is not executing.