I am working on a project based on the STM32F769i-Discovery board.
What I am trying to accomplish is start a bootloader application and then jump from it to an offset of the flash memory where my main application is located.
The bootloader application does the following:
- Reads from the SD card the main application which is stored as a binary.
- Stores the main application binary at the 0x8020000 offset of the flash memory.
- Finally makes the jump to the 0x8020000 offset to run the main application.
According to ST code examples and forums in order for the bootloader to jump to the main application I used the following code:
if (((*(__IO uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS) & 0x2FFE0000 ) == 0x20000000)
/* Jump to user application */
JumpAddress = *(__IO uint32_t*) (USER_FLASH_FIRST_PAGE_ADDRESS + 4);
Jump_To_Application = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) USER_FLASH_FIRST_PAGE_ADDRESS);
where USER_FLASH_FIRST_PAGE_ADDRESS is the 0x8020000 offset of the flash memory.
The main application just makes two user leds blink.
According, again, to what is suggested by forums I made the following changes to the main application:
- In the system_stm32f7xx.c I set the VECT_TAB_OFFSET with 0x20000 offset value.
- I set the linker script as follows:
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 512K
FLASH (rx) : ORIGIN = 0x8020000, LENGTH = 2048K - 128K
Considering that everything is set correctly I run the bootloader application which executes normally and when it makes the jump nothing happens.
Something that is worth noting is that when I use the ST-Link Utility to store the main application binary at the 0x8020000 offset of the flash (instead of reading from the SD card) then when the bootloader makes the jump the main application seems to start (the red led lights up) and then hangs.
What could I be missing?
Is there any STM32F769-specific constraint that I should take into consideration?