Jump to bootloader from application is not Working
Hi Guys,
I am working on STM32F446 MCU. Everything is running fine. I just want to implement firmware upgrade over UART. As we know UART bootloader is already available in system memory we just need to jump over there to run it. I Have used below code to do so.
void JumpToBootloader (void)
{
uint32_t i=0;
void (*SysMemBootJump)(void);
/* Disable all interrupts */
__disable_irq();
/* Disable Systick timer */
SysTick->CTRL = 0;
/* Set the clock to the default state */
HAL_RCC_DeInit();
/* Clear Interrupt Enable Register & Interrupt Pending Register */
for (i=0;i<5;i++)
{
NVIC->ICER[i]=0xFFFFFFFF;
NVIC->ICPR[i]=0xFFFFFFFF;
}
/* Re-enable all interrupts */
/* Set up the jump to boot loader address + 4 */
SysMemBootJump = (void (*)(void)) (*((uint32_t *) ((BootAddr[MCU] + 4))));
/* Set the main stack pointer to the boot loader stack */
__set_MSP(*(uint32_t *)BootAddr[MCU]);
__enable_irq();
/* Call the function to jump to boot loader location */
SysMemBootJump();
/* Jump is done successfully */
while (1)
{
/* Code should never reach this loop */
}
}
It works perfectly if i Call it in beginning of main function before calling HAL_Init(). But if I call same code after one or two lines ( HAL_Init(); SystemClock_Config(); ) Then it stop working. I tried to call HAL_DeInit Before calling this but it will not works at all. I know i am missing something, please guide me to solve this issue. @B.Montanari
