Application booting issue after FW upgrade using ROM bootloader
Hi,
I am using STM32U575 MCU and implementing firmware upgrade feature in it using the ROM bootloader. The application code boots the bootloader by calling the following function. The firmware upgrades correctly and I verified that all the bytes are written correctly into the flash memory. But after upgrade the new application code does not boot up. I have to restart my nucleo board to boot the new firmware.
Also, my application code uses following peripherals -
- GPIO
- GPDMA1
- I2C1 and I2C4
- TIM2, TIM3, TIM4, TIM15, TIM6
- UART1 and LPUART1
- SPI2
If I use a simple blinky FW and on top of it I try to upgrade the FW, the upgrade works correctly, and the new FW boots up. However, if my actual application code is running and I do FW upgrade, the new FW does not bootup.
I assume it could be an issue of peripherals not initializing correctly during boot up because on hardware reset the new FW boots up. What needs to be done to load the new firmware without resetting the board. Also I am sending the GO command (0x21) after completion of image transfer and also getting a positive response for that. I am using UART port for transferring image.
Kindly help me out on this issue.
#define BOOT_ADDR 0x0BF90000 // my MCU boot code base address
#define MCU_IRQS 125u // no. of NVIC IRQ inputs
void JumpToBootloader(void)
{
uint8_t Test[] = "Jumping to Bootloader...!!!\r\n"; //Data to send
HAL_UART_Transmit(&huart1, Test, sizeof(Test), 10);
void (*SysMemBootJump)(void) = (void*)(*((volatile uint32_t*) (BOOT_ADDR + 4U)));
__set_MSP(*(uint32_t *)BOOT_ADDR);
/* Disable all interrupts */
__disable_irq();
/* Set the clock to the default state */
HAL_UART_DeInit(&huart1);
HAL_RCC_DeInit();
HAL_DeInit();
/* Clear Interrupt Enable Register & Interrupt Pending Register */
for (uint8_t i = 0; i < (MCU_IRQS + 31u) / 32; i++)
{
NVIC->ICER[i]=0xFFFFFFFF;
NVIC->ICPR[i]=0xFFFFFFFF;
}
/* Disable Systick timer */
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
/* Re-enable all interrupts */
__enable_irq();
SysMemBootJump();
}
