#embedded

probe-rs

A collection of on chip debugging tools to comminicate with microchips

11 releases (6 breaking)

✓ Uses Rust 2018 edition

0.8.0 Jun 29, 2020
0.7.1 Jun 3, 2020
0.6.2 Apr 19, 2020
0.6.0 Mar 30, 2020
0.2.0 Oct 23, 2019

#29 in Debugging

Download history 48/week @ 2020-03-16 37/week @ 2020-03-23 101/week @ 2020-03-30 47/week @ 2020-04-06 184/week @ 2020-04-13 80/week @ 2020-04-20 53/week @ 2020-04-27 22/week @ 2020-05-04 134/week @ 2020-05-11 33/week @ 2020-05-18 29/week @ 2020-05-25 214/week @ 2020-06-01 56/week @ 2020-06-08 83/week @ 2020-06-15 183/week @ 2020-06-22 324/week @ 2020-06-29

401 downloads per month
Used in less than 7 crates

MIT/Apache

1MB
14K SLoC

probe-rs

a modern, embedded debugging toolkit, written in Rust

crates.io documentation Actions Status chat

The goal of this library is to provide a toolset to interact with a variety of embedded MCUs and debug probes.

Similar projects like OpenOCD, PyOCD, Segger Toolset, ST Tooling, etc. exist. They all implement the GDB protocol and their own protocol on top of it to enable GDB to communicate with the debug probe. Only Segger provides a closed source DLL which you can use for talking to the JLink.

This project gets rid of the GDB layer and provides a direct interface to the debug probe, which then enables other software to use its debug functionality.

The end goal of this project is to have a complete library toolset to enable other tools to communicate with embedded targets.

Functionality

As of version 0.6.0 this library can

  • connect to a DAPLink, STLink or JLink
  • talk to ARM and Risc-V cores via SWD or JTAG
  • read and write arbitrary memory of the target
  • halt, run, step, breakpoint and much more the core
  • download ELF, BIN and IHEX binaries using standard CMSIS-Pack flash algorithms to ARM cores
  • provide debug information about the target state (stacktrace, stackframe, etc.)

To see what new functionality was added have a look at the CHANGELOG

Downloading a file

The cargo-flash utility can be used as a cargo subcommand to download a compiled Rust program onto a target device. It can also be used to download arbitrary ELF files that might come out of a C/C++ compiler. Have a look at cargo-flash for more information.

GDB

We provide a GDB stub so you can use all your usual tools. You can find it here and you can also use it from within cargo-flash with the --gdb flag.

VSCode

We are implementing Microsoft DAP. This makes embedded debugging via probe-rs available in moden code editors implementing the standard, such as VSCode.

Usage Examples

Halting the attached chip

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()?;

Reading from RAM

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)?;

FAQ

I need help!

Don't hesitate to file an issue, ask questions on Matrix, or contact @Yatekii via e-mail.

How can I help?

Please have a look at the issues or open one if you feel that something is needed.

Any contributions are very welcome!

Also have a look at CONTRIBUTING.md.

Our company needs feature X and would pay for its development

Please reach out to @Yatekii

Sponsors

Technokrat

Acknowledgements

In early stages of this library, we profited invaluably from the pyOCD code to understand how flashing works. Also it's always a good reference to cross check how ARM specific things work. So, a big thank you to the team behind pyOCD!

License

Licensed under either of

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~6.5MB
~132K SLoC