Flashing STM32 over SWD
An SWD programmer such as an ST-LINK writes firmware straight to flash over the SWD pins. It does not use the ROM bootloader, so BOOT0 and the bootloader UART 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.
note
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"