Boot0 / 1 bottles are only selected at processor startup to check whether to load user code from memory or load the bootloader. The state of these contacts does not affect the bootloader after that.
I ran into a similar query and found two ways to boot the bootloader on demand.
First, you can "JUMP" from custom code to the loader. For example, you can go to the bootloader when you click a button.
But ... this is much more complicated than a simple JUMP instruction: some registers and devices must be reconfigured correctly to work with the bootloader, you must make sure that IRQ will not start during JUMP, ... In fact, you must reconfigure the processor, as if it was only started after reset. You can find information about this technique: in this video from ST .
I managed to do such things in the STM32F1xx project. However, in a more complex project based on STM32F4, this will become really difficult ... I would have to stop all devices (timers, communication interface, ADC, DAC, ...), to ensure that IRQ will not start, reconfigure all hours , ...
Instead, I decided to implement this second solution: when I want to go to the bootloader, I write a byte in one of the backup registers, and then issue a soft-reset. Then, when the processor restarts, at the very beginning of the program it will read this register. This register contains a value indicating that it should be rebooted in bootloader mode. Then the transition to the bootloader is much easier, as presented in the youtube video .
Jf002 source share