How to program the STM32

If you like it, share it

For programming the STM32 there are different possibility that are:

  • SWD – is ARM specification, useful for developing a FW, it use only 2 pins (SWDIO and SWCLK) + GND, VCC, /RST pin and optionally SWO pin
  • JTAG – is ARM specification, useful for developing a FW
  • DFU or DFUSE – is STM utility that use USB interface for program the STM32. The STM32 must be put in boot mode.
  • Flash Loader – is STM utility that use UART interface for program the STM32. The STM32 must be put in boot mode.

JTAG – SWD connector

The yellow signal, are necessary for SWD.
TRACE-SWO is an optional for SWD.

SWD was introduced by ARM for reduce the number of pins for programming & debugging the Cortex Mx.
The SWD pins are three and are:
SWDIO – bidirectional data
SWCLK – it’s the clock
SWO – (ITM) it’s an optional implementation depend of what STM32 you use and that implement some extra features like: trace, printf, etc.

STLINK-xxx, STM32CubeIDE and ATOLLIC support also the SWO pin.


DFU or DFUSE

DFU (STSW-STM32080) is a SW is for programming the STM32 via the USB (UM0412)
The package contains all binaries and source code for DfuSe USB device firmware upgrade (DFU) software, including the demonstration, debugging GUIs and protocol layers.
It includes the DFU driver compatible with the latest Microsoft®OS.
DfuSe utility can be used to interact with the STM32 system memory bootloader or any In-Application Programming (IAP) firmware, running from the user Flash, thus allowing internal memories programming through USB.

See this video.

ATTENTION:
Now STM suggest to use the STM32CubePROGRAMMER

Flash Loader

Flash LoaderThe STM32 Flash loader demonstrator (FLASHER-STM32) is a free software PC utility from STMicroelectronics, which runs on PC and communicates through the RS232 with the STM32 system memory bootloader.
To get an example of how to execute the device bootloader, refer to the STM32 microcontroller system memory boot mode Application note (AN2606).
To get information about the USART protocol used in the STM32 bootloader, refer to the USART protocol used in the STM32 bootloader Application note (AN3155).

ATTENTION:
Now STM suggest to use the STM32CubePROGRAMMER

Some useful A.N.

  • AN2606: STM32 microcontroller system memory boot mode
  • AN3155: USART protocol used in the STM32 bootloader
  • AN3156: USB DFU protocol used in the STM32 bootloader
  • X-CUBE-IAP-USART – STM32Cube in-application programming using the USART embedded software
    • Flash erase
    • Flash programming
    • UART communication using Ymodem protocol
    • Flash write protection configuration
    • Separating application from loader
    • Read also the AN4657 – STM32 in-application programming (IAP) using the USART