A template for working with the STM32F411RETx MCU using either stm32f4xx-hal or Embassy.
Options for flashing/debugging with openocd/gdb, probe-rs, and cargo embed.
Includes VS Code JSON files for easy in-IDE debugging with probe-rs.
This template will mostly work with other STM32 models, you will just have to update memory.x and the chip name in various files.
This template includes files for several different development/debugging strategies, so not all may be necessary to your workflow. But regardless, the first steps are:
- Run
cargo generate --git https://github.com/kurtjd/stm32f411-quickstart
to generate a project - If not using Embassy, you can safely remove main.rs.embassy and the Embassy dependencies from Cargo.toml
- If you are using Embassy, uncomment out the Embassy dependencies from Cargo.toml and replace main.rs with main.rs.embassy
Steps for your preferred development enviroment are below.
- Run
openocd
(uses settings in openocd.cfg) - From another terminal, run
gdb -q -x target/thumbv7em-none-eabihf/debug/{{project-name}}
(uses settings in openocd.gdb)
- To flash/execute, run
cargo run
(.cargo/config.toml includes runner setting for probe-rs) - To debug, run
probe-rs debug --chip STM32F411RETx
- Run
cargo-embed
(defaults to no GDB, but can change this in Embed.toml)
- Ensure rust-analyzer and probe-rs VS Code extensions are installed
- Various tasks provided for building and running (in both debug and release mode)
- Run and Debug supported via probe-rs extension and the stm32f411 SVD file