Using NVIC_SystemReset() in bootloader<->application jumps
I am working on a project with STM32L432 and trying to get a clean (without necessity to de-init peripherals and disable peripheral interrupts) jump to application from a bootloader and back.
The widely described method to do so is as follows (for a booloader):
- Write a predefined key value to the non-initialized RAM predefined key variable.
- Call NVIC_SystemReset().
- After reset check the key variable.
If it contains the key value, erase it and execute standard jump to the application:
typedef void (*pFunction)(void);
pFunction Jump_To_Application;
void Application_jump(void)
{
uint32_t JumpAddress;
/* Get the application stack pointer (First entry in the application vector table) */
JumpAddress = (uint32_t) *((__IO uint32_t*)APP_START_ADDRESS);
/* Get the application entry point (Second entry in the application vector table) */
Jump_To_Application = (pFunction) *(__IO uint32_t*) (APP_START_ADDRESS + 4);
/* Reconfigure vector table offset register to match the application location */
SCB->VTOR = JumpAddress;
/* Set the application stack pointer */
__set_MSP(JumpAddress);
/* Start the application */
Jump_To_Application();
} My question is:
Is it possible to force the system to start at the application address after reset.
I tried it, but system always starts at a base address. Maybe I've done something wrong.
It it's possible, then how?
And in this case would using only NVIV_SystemReset() call provide a clean jump?
BTW, if system always starts at a base address, would using only NVIC_SystemReset() in application provide a clean jump to a bootloader?
Thank you.