How to exit/reset STM32 DFU bootloader

Both dfu-util and dfu-tool can flash firmware, but their current versions can’t reset the STM32 from DFU mode to run the application.

I found that using MicroPython’s pydfu.py is able to reset the. Note that currently I use pydfu.py only for resetting, not for flashing (but that might change in the future).

Download using

wget https://raw.githubusercontent.com/micropython/micropython/master/tools/pydfu.py

Install the PyUSB dependency using

sudo pip3 install pyusb

And then reset the STM32 in DFU mode:

python3 pydfu.py -x