Skip to content

stm32flash

Flash STM32 microcontrollers over their built-in serial bootloader

What it does

Reads, writes, erases and verifies the flash of an STM32 microcontroller through the ROM bootloader ST builds into every part, over a serial line (a USB-serial adapter or a Raspberry Pi's UART) or I2C. It can also start the program it has just written, and on boards that wire them it can use the adapter's RTS and DTR lines, or GPIO, to put the chip into bootloader mode and reset it.

Why you would want it

Many small STM32 boards have no USB bootloader and no debug header fitted, and the serial bootloader is the one way in that every STM32 has. Ham hotspot boards built on the MMDVM design are a common example (the gap analysis's search result; not measured here). It is the alternative to ST's own STM32CubeProgrammer, and complements the catalog's stlink-tools (an ST-LINK probe over SWD) and dfu-util (parts with a USB DFU bootloader).

Before it will work

A serial connection to the board's bootloader pins (TX, RX and ground at 3.3 V logic), and access to the serial device -- the dialout group. The chip must be in its system bootloader: BOOT0 held high at reset, by a jumper, a button or the adapter's control lines.

How it installs

  • apt: stm32flash

Known problems

Unmeasured here: no board has been flashed with it. The commonest failure is a chip not in bootloader mode, which reports as a timeout rather than an error that says so. Some parts ship with read-out protection set; clearing it erases the chip. Getting the wrong serial device writes nothing but wastes time, so name the adapter by its /dev/serial/by-id/ path.

Keeping it current

  • probe: apt policy
  • strategy: apt_upgrade
  • Tagged releases are years apart (v0.7 is the latest tag); the default branch keeps adding newer STM32 parts between them. A part missing from 0.7's table is a reason to look at the upstream head, not a fault.

Where to get help with the software itself

The SourceForge project page above: its tickets and its mailing list.

Source: catalog/packages/stm32flash.yaml