There is an ST application note about bootloader.
In addition to patterns described above, user can execute bootloader
by performing a jump to system memory from user code. Before jumping
to bootloader user must:
- Disable all peripheral clocks
- Disable used PLL
- Disable interrupts
- Clear pending interrupts
This is why when you activate interrupts the bootloader crashes.
EDIT
To address @Clifford thoughts STM32 system bootloader exits with jump to master defined address with go command. This address should be reset vector not main so that heap, stack and FW will be correctly initialized. After that you can either do system_reset to be in a known HW state or you must fully configure the peripherals you use in application because they are not set bat to reset state after bootloader used them.
Note: If you choose to execute the Go command, the peripheral
registers used by the bootloader are not initialized to their default
reset values before jumping to the user application. They should be
reconfigured in the user application if they are used. So, if the IWDG
is being used in the application, the IWDG prescaler value has to be
adapted to meet the requirements of the application (since the
prescaler was set to its maximum value). For some products, not all
reset values are set. For more information please refer to the known
limitations detailed for each product’s bootloader versions.
NVIC_SystemReset? That is by far the simplest method. This may be an X-Y problem - you are trying to avoidNVIC_SystemResetfor some unstated and your solution to that does not work. It may be that avoidingNVIC_SystemResetis necessary, but knowing your reason for that assumption may just get you a better solution. - Cliffordmain()address is used, the bootloader will run in the in the C runtime environment (stack, heap, library state) of the application, which may also cause problems. Typically from reset, there will be hardware (PLL, external memory interface etc) initialisation, C (or C++) runtime initialisation, thenmain(). You need to start from the runtime initialisation at least, so long as your bootloader has no hard clock speed dependencies. - Clifford