A Cargo runner is the command Cargo invokes to run an embedded program. Set it in .cargo/config.toml so cargo run can launch firmware on a physical board or in an emulator. section 3.2.3 section 2.7.2
[target.thumbv7m-none-eabi] runner = "gdb-multiarch -q -x openocd.gdb" rustflags = [ "-C", "link-arg=-Tlink.x", ] [build] target = "thumbv7m-none-eabi"
This configuration pairs a Cortex-M3 target with a gdb-multiarch runner and linker flags; the runner command can be changed to use another tool. section 3.2.3
Choose the runner command to match how you want to run the firmware:
- Use probe-rs to flash and run a Blue Pill, specifying the STM32F103C8 chip. section 2.6.4
- Use gdb-multiarch with a GDB script to automate flashing and debugging through OpenOCD. section 3.2.3
- Use QEMU to run firmware in an emulated environment; the runner command differs from the one used for a physical board. section 2.7.2
Keep the runner aligned with the selected target and the intended execution environment. Centralizing it in .cargo/config.toml avoids repeating lengthy command-line arguments. section 3.2.3 section 2.7.2
