Flash firmware to STM32 microcontrollers using Python.
Maintained. Last release 3 weeks ago, commits in 2 of the last 26 weeks. Weaker on commit activity and release cadence.
pip install stm32loaderSTM32Loader
Python module to upload or download firmware to / from ST Microelectronics STM32 microcontrollers over UART.
Also supports ST BlueNRG devices, and the SweetPeas bootloader for Wiznet W7500.
Compatible with Python version 3.9-3.15 and PyPy 3.10-3.11.
Run using uvx
uvx stm32loader
Installation with pip
pip install stm32loader
To also support loading .hex files:
pip install stm32loader[hex]
To install the latest development version:
pip install git+https://github.com/florisla/stm32loader.git
Usage
usage: stm32loader [-h] [-e] [-E] [-u] [-x] [--write-unprotect]
[--write-protect] [-w] [-v] [-r] [-l LENGTH] -p PORT
[-b BAUD] [-a ADDRESS | -o OFFSET] [-g ADDRESS] [-f FAMILY]
[-V] [-q] [-s] [-R] [-B] [-n] [-P {even,none}] [--version]
[FILE.BIN]
Flash firmware to STM32 microcontrollers.
positional arguments:
FILE.BIN File to read from or store to flash.
options:
-h, --help show this help message and exit
-e, --erase Erase the full flash memory or a specific region
(support --address and --length). Note: this is
required on previously written memory.
-E, --auto-erase Before writing, erase only the flash pages that the
written data covers.
-u, --unprotect Unprotect flash from readout.
-x, --protect Protect flash against readout.
--write-unprotect Disable write protection before flashing
--write-protect Enable write protection after flashing
-w, --write Write file content to flash.
-v, --verify Verify flash content versus local file (recommended).
-r, --read Read from flash and store in local file.
-l, --length LENGTH Length of read or erase. For write and verify, use
only this many bytes of the file.
-p, --port PORT Serial port (default: $STM32LOADER_SERIAL_PORT).
-b, --baud BAUD Baudrate. (default: 115200)
-a, --address ADDRESS
Target address for read or write. For erase, this is
used when you supply --length. Default: the start of
flash memory.
-o, --offset OFFSET Alternative to --address: an offset from the start of
flash memory.
-g, --go-address ADDRESS
Start executing from address (0x08000000, usually).
-f, --family FAMILY Device family to read out device UID and flash size;
e.g F1 for STM32F1xx. Possible values: C0, F0, F1, F2,
F3, F4, F7, G0, G4, H5, H7, L0, L1, L4, L5, WBA, WB0,
WB, WL, U5, W, NRG, WIZ, GD32VW55X (default:
$STM32LOADER_FAMILY).
-V, --verbose Verbose mode.
-q, --quiet Quiet mode.
-s, --swap-rts-dtr Swap RTS and DTR: use RTS for reset and DTR for boot0.
-R, --reset-active-high
Make RESET active high.
-B, --boot0-active-low
Make BOOT0 active low.
-n, --no-progress Don't show progress bar.
-P, --parity {even,none}
Parity: "even" for STM32, "none" for BlueNRG.
(default: even)
--version show program's version number and exit
examples:
stm32loader --port COM7 --family F1
stm32loader --erase --write --verify example/main.bin