Skip to main content
Visitor II
May 29, 2024
Question

Jump to bootloader from application is not Working

  • May 29, 2024
  • 1 reply
  • 957 views

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

@Tesla DeLorean  

    This topic has been closed for replies.

    1 reply

    Technical Moderator
    May 29, 2024

    Hello @Harwinder Singh

    Make sure to set the address of the entry point to bootloader at 0x1FFF0000. 

    System memory bootloader address is mentioned on AN2606 and for STM32F446.

    Visitor II
    May 29, 2024

    Hi lmen.D , Thanks for prompt reply. Yes i have used the same address. Thing is that it works properly when called after reset but not working after executing some code. Also same code was working with keil in an early project but not working in CubeIDE.