2019-07-11 10:38 PM
My bootloader starts from 0x08000000 and my application starts from 0x08004000. After i flash the application through UART I jump to my application using the code below.
HAL_UART_DeInit(uart_handle);
HAL_RCC_DeInit();
HAL_DeInit();
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
__disable_irq();
/* execute the new program */
JumpAddress = *((__IO uint32_t*) (APPLICATION_ADDRESS_BANK_1 + 4));
/* Jump to user application */
JumpToApplication = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS_BANK_1);
JumpToApplication();
After i jump to my application the SBC->VTOR is loaded with 0x08004000 in system init and the application runs. All the interrupts are managed through the vector table of my application.
What should be the behavior when a reset occurs while my application is running. Should it go to the reset handler of my application i.e. at ox08004004 or the reset handler of my bootloader (0x080000004)
2019-07-11 10:49 PM
The reset will go to your boot loader provided BOOT0=LOW
2019-07-11 11:11 PM
Thanks.
What about a soft reset from Watch dog in my application. And also is there a way to ensure that after reset, the controller straightaway goes to my application.
2019-07-11 11:16 PM
The watchdog generates a reset pulse with resets the core, SCB->VTOR gets set to zero, and whatever memory is mapped there via the BOOTx pins takes control.
You could expedite the jump to your applications Reset_Handler by having the boot loader recognize a signature value in RAM in its Reset_Handler.
2019-07-11 11:54 PM
Thanks a lot.
If i write a simple application it is working perfectly after switching.
But my main application is freertos based and it unexpectedly resets back to my bootloader. Am i doing my application switching correctly or do i need to do something extra do take care for my rtos based application.