QUERY · ISSUE
[mboot] It will stay in the dfu mode forever and not reset
port-stm32needs-info
When using mboot to replace the code with dfu commands all works fine. However, mboot stays in dfu mode and not resetting the device. This is tested using mboot with the H743.
CANDIDATE · PULL REQUEST
stm32/mboot: Leave bootloader from thread mode, not from IRQ.
port-stm32
Leaving the bootloader from an IRQ (eg USB or I2C IRQ) will not work if MBOOT_LEAVE_BOOTLOADER_VIA_RESET is disabled, ie if mboot jumps directly to the application. This is because the CPU will still be in IRQ state when the application starts and IRQs of lower priority will be blocked.
Fix this by setting a flag when the bootloader should finish, and exit the bootloader always from the main (top level) thread.
This also improves the USB behaviour of mboot: it no longer abruptly disconnects when the manifest command is sent.