AnsweredAssumed Answered

How do I properly jump and reset "things" in order to switch execution area?

Question asked by arnold_w on May 30, 2016
Latest reply on May 31, 2016 by Clive One
I am working with the Discovery Development Board and a custom-made PCB with an STM32F405 microcontroller. My 2 projects are very similar and usually I use the custom-made board, but when I need to probe or measure something I use the Discovery Development Board. My projects have identical bootloaders, that I wrote myself, and I experience problems when I jump from my bootloader to the application. In order to do that I use the following:

#define JMP(addr) \
    __asm__("mov pc,%0" \
            : /*output*/ \
            : /*input*/ \
            "r" (addr) \

The code seems to hang when I do the jump on the custom-made PCB, but it works fine on the Discovery Development Board. However, if I do a reset (NVIC_SystemReset()) and then do the same jump when the microcontroller boots back up again, then it works fine. This makes me suspect that I need to do something before I do the jump, such as resetting the stack pointer or something else. Does anybody know all the required steps to take before doing a jump like this? My vector file (system\src\cmsis\vectors_stm32f405xx.c) looks like this:

void __attribute__ ((section(".after_vectors"),noreturn))
Reset_Handler (void)
  _start ();
__attribute__ ((section(".isr_vector"),used))
pHandler __isr_vectors[] =
    // Cortex-M Core Handlers
    (pHandler) &_estack,               // The initial stack pointer
    Reset_Handler,                     // The reset handler
    NMI_Handler,                       // The NMI handler
    HardFault_Handler,                 // The hard fault handler

SCB->VTOR  is set to 0x08010000.