cargo flash

# Installing cargo flash is simple:
cargo install cargo-flash

# In your cargo project directory, call
cargo flash --release --chip <chip_name>

# Don't know if your target is available
# and what it's name is?
cargo flash --list-targets

# You can run your examples as usual with
cargo flash --example <your_example>
    
# If you like GDB for debugging,
# you can open a GDB server after downloading
cargo flash --gdb

cargo-flash is a cargo extension and drop in replacement for 'cargo run'.

You can use cargo-flash just like 'cargo run', but instead of running on the host, cargo-flash will download your binary to the target and run.

Any config flags that are accepted by 'cargo run' are accepted by cargo-flash too. If not, hit us with an issue.

probe-rs as a library

use probe_rs::Probe;

// Get a list of all available debug probes.
let probes = Probe::list_all();

// Use the first probe found.
let probe = probes[0].open()?;

// Attach to a chip.
let session = probe.attach("nrf52")?;

// Select a core.
let core = session.attach_to_core(0)?;

// Halt the attached core.
core.halt()?;

probe-rs as a library can be used to automate your workflow.

Want to do

  • hardware-in-the-loop testing?
  • WCET analysis with automatic stepping and reporting
  • automatic firmware downloads in your project?

probe-rs was designed with such usecases in mind.

use probe_rs::Core;

let core = Core::auto_attach("nrf52")?;

// Read a block of 50 32 bit words.
let mut buff = [0u32;50];
core.read_32(0x2000_0000, &mut buff)?;

// Read a single 32 bit word.
let word = core.read_word_32(0x2000_0000)?;

// Writing is just as simple.
let buff = [0u32;50];
core.write_32(0x2000_0000, &buff)?;

// of course we can also write 8bit words.
let buff = [0u8;50];
core.write_8(0x2000_0000, &buff)?;

Reading and writing memory is trivial with probe-rs.

probe-rs supports different word sizes and block transfers.

Don't forget to unlock the flash before you write to it!

use probe_rs::Core;

let core = Core::auto_attach("nrf52")?;

// Read a block of 50 32 bit words.
let mut buff = [0u32;50];
core.read_32(0x2000_0000, &mut buff)?;

// Read a single 32 bit word.
let word = core.read_word_32(0x2000_0000)?;

// Writing is just as simple.
let buff = [0u32;50];
core.write_32(0x2000_0000, &buff)?;

// of course we can also write 8bit words.
let buff = [0u8;50];
core.write_8(0x2000_0000, &buff)?;

Downloading firmware to your target is as easy.

Of course the flash facility can also report progress. Have a closer look at probe_rs::flash::download::download_file_with_progress_reporting.

Any target that has a CMSIS-Pack can be converted into a probe-rs flash download target with our utility

Features

Flash programming stable
Cargo integration stable
CMSIS-Pack support stable
RiscV support alpha
ARM support stable
CMSIS-DAP (DAP-Link) support stable
ST-Link support stable
J-Link support alpha
JTAG support alpha
SWD support stable
GDB stub beta
Microsoft DAP (VSCode) server alpha
WASM extensions for chip-specific functionality planned
Chip autodetection beta
Debugging (run, halt, step, break) beta
ITM support planned
Flash (soft) breakpoints planned
Write to externally connected flashes planned
Segger RTT support planned
Semihosting planned