Flashing STM32 over SWD
An SWDSWD (Serial Wire Debug). A two-pin debug and programming interface, used on STM32 devices to enter bootloader mode and flash firmware. programmer such as an ST-LINK writes firmware straight to flash over the SWDSWD (Serial Wire Debug). A two-pin debug and programming interface, used on STM32 devices to enter bootloader mode and flash firmware. pins. It does not use the ROM bootloader, so BOOT0 and the bootloader UARTUART (Universal Asynchronous Receiver-Transmitter). A serial interface used to communicate with a device over its pins or through a USB-to-serial bridge. are not involved.
GUI — STM32CubeProgrammer
- Launch STM32CubeProgrammer.
- Select the ST-LINK connection.
- Click Connect.
- Open the
firmware-<target>-X.X.X.xxxxxxx.binfile and confirm the start address is0x08000000(the default). - Click Download.
If your ST-LINK's nRST pin is not connected to the board's nRST, set Reset mode to Software reset or Core reset instead of Hardware reset in the ST-LINK settings.
CLI
STM32CubeProgrammer, nRST connected
STM32_Programmer_CLI -c port=SWD mode=UR -w firmware-<target>-X.X.X.xxxxxxx.bin 0x08000000 -v -rst
-v verifies the write and -rst restarts the board into the new firmware.
STM32CubeProgrammer, nRST not connected
STM32_Programmer_CLI -c port=SWD mode=HOTPLUG -w firmware-<target>-X.X.X.xxxxxxx.bin 0x08000000 -v -rst
OpenOCD
openocd -f interface/stlink.cfg -f target/stm32wlx.cfg -c "program firmware-<target>-X.X.X.xxxxxxx.bin 0x08000000 verify reset exit"