Skip to main content
Visitor
October 6, 2026
Question

STM32U595 bootloader resets when no peripheral is connected

  • October 6, 2026
  • 2 replies
  • 36 views

Here is my main and jump to bootloader :

int main(void)
{
HAL_Init();
SystemPower_Config();
SystemClock_Config();

HAL_Delay(500); // Catch bootloader constantly resetting

jump_to_bootloader();
while (1)
{
HAL_Delay(50);
}
}

#define BOOTLOADER_ADDR (0x0BF90000UL)

HAL_StatusTypeDef jump_to_bootloader(void)
{
__disable_irq();

HAL_RCC_DeInit(); // Must be run before disabling systick because it depends on it
HAL_DeInit();

SysTick->CTRL = 0U; // Disable systick
SysTick->LOAD = 0U;
SysTick->VAL = 0U;

int count = sizeof(NVIC->ICER)/sizeof(NVIC->ICER[0]);
for (int i = 0; i < count; i++)
{ // Clear pending interrupts
NVIC->ICER[i]=0xFFFFFFFFUL;
NVIC->ICPR[i]=0xFFFFFFFFUL;
}

void (*jump_to_bootloader_fptr)(void);
jump_to_bootloader_fptr = (void (*)(void)) (*((uint32_t *) ((BOOTLOADER_ADDR + 4))));

__enable_irq();

__set_MSP(*(uint32_t *)BOOTLOADER_ADDR);
jump_to_bootloader_fptr();

return HAL_ERROR; // Should never get there because of jump
}

 

When manually debugging using gdb, when breaking at jump_to_bootloader_fptr(); , I use step instruction to step into the code, I can see that the addresses of instructions being executed are in the bootloader’s address range.

Here’s some gdb debugging output :

Breakpoint 3, jump_to_bootloader () at /home/src/bsp/bsp_bootloader.c:53
53 jump_to_bootloader_fptr();
(gdb) si
0x08000636 53 jump_to_bootloader_fptr();
(gdb) si
0x0bf98c38 in ?? ()
(gdb)
0x0bf98c3a in ?? ()
(gdb)
0x0bf98a10 in ?? ()
(gdb)
0x0bf98a12 in ?? ()

I can execute ‘stepi’ (step instructions) for a long time and it will stay in the bootloader’s address range. 

But when I execute 'continue' command, the program restarts at the user code's address range.

0x0bf90cf6 in ?? ()
(gdb)
0x0bf90cee in ?? ()
(gdb) c
Continuing.

Breakpoint 1, main () at /home/src/main.c:36
36 HAL_Init();

So it means that the bootloader resets after some condition is met. However, reading Figure 125 of AN2606, the bootloader should be 'stuck' in a loop of checking for peripheral detection and should not reset.

My option bytes : TZEN=0, nSWBOOT0=0 nBOOT0=1

So my question : is it expected that the bootloader resets when no peripheral is connected, or is there something wrong with my setup ?

2 replies

ST Technical Moderator
October 7, 2026

Hello ​@christophe.durand 

So my question : is it expected that the bootloader resets when no peripheral is connected, or is there something wrong with my setup ?

The bootloader does not perform a reset, even if no peripheral is connected. However, you should check in your application whether you are using the same stack as the bootloader. If so, you need to change your stack address.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Saket_Om
Visitor
October 7, 2026

Finally found the cause : the USB was not powered on, which caused the bootloader to reset.

I had to activate VDDUSB.