I am working on STM32F429NI Evaluation board, I have a code to blink the led. I want the blink led code to be present in external nor flash and the bootloader residing the internal flash has to transfer control to the external nor flash of STM32F429NI.
Reference manual of STM32F429NI evaluation board: https://www.st.com/en/microcontrollers-microprocessors/stm32f429ni.html#documentation
Steps I have followed is:
void jump_to_external_flash(uint32_t address)
{
uint32_t msp_value = *(__IO uint32_t*)address;
void (*reset_handler)(void);
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
HAL_DeInit();
__set_MSP(msp_value);
uint32_t rst_handler_addr = *(__IO uint32_t*)(address + 0x4);
reset_handler = (void*) rst_handler_addr;
reset_handler();
}
In the code for led blink linked script
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K
CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K
FLASH (rx) : ORIGIN = 0x60000000, LENGTH = 64MB
}
It is very simple. You need to initialize the Flexible memory controller (FMC) to map the external flash into uC address space. Then simply jump to the code there.
FLASH will still be at the normal address. Add a new memory segment for the external FLASH.
To program it you will probably need to write your own routine. Example here: https://github.com/magicmicros/AT25Q641_ExternalLoader
PS do not use HAL functions in the bootloader.