liveBook · Manning

.cargo/config.toml

As explained in Embedded Software with Rust

.cargo/config.toml is Cargo's project configuration file for specifying build targets, linker arguments, and runner commands.

In embedded Rust, .cargo/config.toml centralizes settings that make builds target the right hardware and run through the chosen flashing or debugging tool. It avoids repeating long, error-prone arguments on each Cargo command. section 3.2.3

[target.thumbv7m-none-eabi]
runner = "gdb-multiarch -q -x openocd.gdb"

rustflags = [
  "-C", "link-arg=-Tlink.x",
]

[build]
target = "thumbv7m-none-eabi"

This Cortex-M3 configuration selects the target, sets a GDB/OpenOCD runner, and passes a linker script to rustc. Replace the runner with `probe-rs run` to use probe-rs instead. section 3.2.3

Choose a target triple that matches the microcontroller. The linker script must also describe the device’s memory layout; that layout is specified separately in memory.x and should match the hardware. section 2.4.3 section 3.2.3

How Embedded Software with Rust covers it

How deep it goes
Explains target selection, runners, and linker flags with a Cortex-M3 configuration example.
Examples
Shows a thumbv7m-none-eabi target, a GDB/OpenOCD runner, and a probe-rs alternative.
What it assumes
Requires identifying the target microcontroller and matching its target triple and memory layout.
What you can do after
Operate embedded Cargo builds with a configured target, linker script, and flashing or debugging runner.
How it connects
Connects Cargo configuration to linker scripts, memory layout, OpenOCD, and probe-rs.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Embedded Software with Rust. The section links point to the parts of the book it draws on.