This workspace wraps the Stm32CubeProgrammer API to provide a rust interface. The API can be found in the directory where the Stm32CubeProgrammer is installed.
Inspired by https://github.com/wervin/stm32cubeprog-rs but using bindgen to generate the bindings.
Crates:
stm32cubeprogrammer-sys
: Bindings to the Stm32CubeProgrammer API (generated with bindgen)stm32cubeprogrammer
: Safe rust interface to the Stm32CubeProgrammer API -> WIPstm32cubeprogrammer-cli
: Command line interface to the Stm32CubeProgrammer API -> WIP (not yet existing)
The bindings are generated with bindgen when running cargo build
. The bindings are generated in the src
directory of the stm32cubeprogrammer-sys
crate. The header file STM32_Programmer_API.h
and the whole include
directory were copied from the api
folder of the Stm32CubeProgrammer installation directory. This is tested with Stm32CubeProgrammer version 2.18.0.
The tests show how to use this crate. You can generate an instance of CubeProgrammer
via its builder. The builder requires the path to the Stm32CubeProgrammer installation directory. The path needs to be the root of the installation directory, e.g. C:\STMicroelectronics\STM32Cube\STM32CubeProgrammer
.
You need to add a .env
file in the root to supply the necessary environment variables. Take a look at the tests
directory for an example.
A convenient way to run the tests is via just
:
just test
The justfile needs just
and nu
to be installed.
Working functionality:
- Discover ST-Link probes
- Connect to a target
- Write hex/bin file to target
- Save memory to file
- Mass erase memory
- Upgrade BLE stack
- Reset
- Get general device information
Functionality to be added:
- Enable readout protection
- Disable readout protection
- And much more.. PRs are more than welcome! 😊
- Windows: Tested
- Linux: Not tested yet but should work
This project is provided as is without any warranty.