cancel
Showing results for 
Search instead for 
Did you mean: 

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):

  1. Write a predefined key value to the non-initialized RAM predefined key variable.
  2. Call NVIC_SystemReset().
  3. 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.

10 REPLIES 10

I read your idea for a solution, but I don’t have a good understanding of assembly, and I have some doubts about whether it would work in CubeIDE. Would you happen to have an example of code implementing this process in CubeIDE? It would be very helpful. I'm trying to develop a bootloader to read an SD card via SDMMC, look for a binary update file, and, if found, write it to the flash of the F722RET6 and jump to execution.
However, I don’t know how to write this in code without causing a handler error at address 0xFFFFFFFFFFF.
I can even buy you a coffee if you help me. Feel free to reach out at my email: robert@teknikao.com.br.