Question
Jump from Bootloader code to application code
Hi,
I want to implement a bootloader for FOTA process. My bootloader code resides in sector 0 and application code in sector 5(the firmware to be updated ). But I am not able to jump from bootloader code to application code. Any help will be highly useful.
Bootloader code - 0x08000000
Application code - 0x08020000
Thanks
Jump Function defination :
int JumpToApplication(void)
{
if (((*(__IO uint32_t*)SECTOR_START_ADDRESS) & 0x2FFE0000 ) != 0x20000000)
{
return -1;
}
__disable_irq();
HAL_DeInit();
/* Get the main application start address */
uint32_t jump_address = *(__IO uint32_t *)(SECTOR_START_ADDRESS + 4);
SCB->VTOR = SECTOR_START_ADDRESS;
/* Set the main stack pointer to to the application start address */
__set_MSP(*(__IO uint32_t *)SECTOR_START_ADDRESS);
HAL_UART_Transmit(&huart1, (uint8_t*)"MSP Done \r\n ", 30, 1000);
// Create function pointer for the main application
void (*pmain_app)(void) = (void (*)(void))(jump_address);
// Now jump to the main application
pmain_app();
return 0;
}