Cargo coordinates embedded Rust builds and project workflows. Bare-metal projects use explicit target configuration; Cargo also manages dependencies and features that can select different build behavior. section 1.7.1 section 6.4.5
In embedded projects, Cargo supports:
- Building for an explicitly selected Arm Cortex-M or RISC-V target. section 1.7.1
- Working with tools to convert and inspect firmware binaries. section 2.8
- Using project configuration to set a target, runner, and linker script without repeating command-line options. section 3.2.3
- Keeping dependency versions reproducible through Cargo.lock, which Cargo manages automatically. section 3.1.3
[target.thumbv7m-none-eabi] runner = "gdb-multiarch -q -x openocd.gdb" rustflags = [ "-C", "link-arg=-Tlink.x", ] [build] target = "thumbv7m-none-eabi"
This configuration sets a Cortex-M target, a GDB/OpenOCD runner, and a linker script for the build. section 3.2.3
Choose panic behavior with a feature
A debug-panic Cargo feature selects semihosting output; a build without that feature selects a silent halt handler. The same source tree can produce either variant. section 6.4.5
// Cargo.toml [features] debug-panic = [] [dependencies] panic-halt = "1.0" panic-semihosting = "0.6"
The manifest listing declares the debug-panic feature and the two candidate panic-handler dependencies. section 6.4.5
// main.rs #[cfg(feature = "debug-panic")] use panic_semihosting as _; #[cfg(not(feature = "debug-panic"))] use panic_halt as _;
The conditional imports link exactly one panic handler, according to whether debug-panic is enabled. section 6.4.5






