LinuxCommandLibrary

st-flash

TLDR

Flash binary

$ st-flash write [firmware.bin] [0x8000000]
copy
Read flash
$ st-flash read [output.bin] [0x8000000] [0x1000]
copy
Erase flash
$ st-flash erase
copy
Reset device
$ st-flash reset
copy
Verify write
$ st-flash --verify write [firmware.bin] [0x8000000]
copy

SYNOPSIS

st-flash [--verify] command [file] [address] [size]

DESCRIPTION

st-flash is a command-line tool for reading, writing, and erasing the flash memory of STM32 microcontrollers through an ST-Link programmer/debugger. It is part of the open-source stlink toolset.
The tool works with raw binary files and requires explicit memory addresses for read and write operations. The flash base address for most STM32 devices is 0x8000000. Write verification can be enabled with --verify to confirm the programmed data matches the input file. The erase command clears the entire flash memory, and reset restarts the microcontroller after programming.

PARAMETERS

write

Write to flash.
read
Read from flash.
erase
Erase all flash.
reset
Reset chip.
--verify
Verify after write.
--reset
Reset after operation.
--serial SN
Device serial.

CAVEATS

ST-Link required. STM32 specific. Correct address needed.

HISTORY

st-flash is part of stlink, an open-source toolset for programming STM32 microcontrollers via ST-Link.

SEE ALSO

st-info(1), st-util(1), openocd(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community