st-flash(1)

st-flash1

Flash binary files to stm32 device

Usage

st-flash [OPTIONS] {read | write | erase} [FILE] <ADDR> <SIZE>

Overview

Flash binary files to arbitrary sections of memory, or read arbitrary addresses of memory out to a binary file.

You can use this instead of st-util(1) if you prefer, but remember to use the .bin image, rather than the .elf file.

Use hexadecimal format for the ADDR and SIZE.

Commands

write FILE ADDR

Write firmware FILE to device starting from ADDR

read FILE ADDR SIZE

Read firmware from device starting from ADDR up to SIZE bytes to FILE

erase

Perform a mass erasing of the device firmware

reset

Reset the target

Options

--version

Print version information

--debug

TODO

--reset

Trigger a reset both before and after flashing

--opt

Enable ignore ending empty bytes optimization

--serial iSerial

TODO

--flash=fsize

Where fsize is the size in decimal, octal, or hex followed by an optional multiplier `k' for KB, or `m' for MB. Use a leading “0x” to specify hexadecimal, or a leading zero for octal.

Examples

Flash firmware.bin to device

$ st-flash write firmware.bin 0x8000000

Read firmware from device (4096 bytes)

$ st-flash read firmware.bin 0x8000000 0x1000

Erase firmware from device

$ st-flash erase

Releases

5 releases since Debian 10 (Buster); the text changed 2 times.

  1. 10
  2. 11
  3. 12–Arch

--opt since Debian 11 (Bullseye).

From stlink 1.9.0-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.