Crates.io | probe-rs-mi |
lib.rs | probe-rs-mi |
version | 0.1.0 |
source | src |
created_at | 2024-05-22 21:56:24.769755 |
updated_at | 2024-05-22 21:56:24.769755 |
description | The probe-rs machine interface for computers interfacing probe-rs |
homepage | https://github.com/probe-rs/probe-rs |
repository | https://github.com/probe-rs/probe-rs |
max_upload_size | |
id | 1248832 |
size | 9,920 |
a modern, embedded debugging toolkit, written in Rust
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.
As of version 0.10.0 this library can
To see what new functionality was added have a look at the CHANGELOG
If you think probe-rs makes your embedded journey more enjoyable or even earns you money, please consider supporting the project on Github Sponsors for better support and more features.
In addition to being a library, probe-rs also includes a suite of tools which can be used for flashing and debugging.
The recommended way to install the tools is to download a precompiled version, using one of the methods below. See https://probe.rs/docs/getting-started/installation/ for a more detailed guide.
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/probe-rs/probe-rs/releases/latest/download/probe-rs-installer.sh | sh
irm https://github.com/probe-rs/probe-rs/releases/latest/download/probe-rs-installer.ps1 | iex
The tools can also be installed from source. After installing the necessary prerequisites, the latest development version can be installed using cargo install
:
cargo install probe-rs-tools --git https://github.com/probe-rs/probe-rs --locked
This will compile the tools and place them into the cargo bin
directory. See the Cargo book for details.
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.
If you are looking for a more extended debugging experience, please have a look at cargo-embed which provides support for GDB, RTT, and config files.
We have implemented the Microsoft Debug Adapter Protocol (DAP). This makes embedded debugging via probe-rs available in modern code editors implementing the standard, such as VSCode. The DAP website includes a list of editors and IDEs which support DAP.
The probe-rs website includes VSCode configuration instructions.
use probe_rs::{Permissions, Probe};
fn main() -> Result<(), probe_rs::Error> {
// 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 mut session = probe.attach("nRF52840_xxAA", Permissions::default())?;
// Select a core.
let mut core = session.core(0)?;
// Halt the attached core.
core.halt(std::time::Duration::from_millis(300))?;
Ok(())
}
use probe_rs::{MemoryInterface, Permissions, Session};
fn main() -> Result<(), probe_rs::Error> {
// Attach to a chip.
let mut session = Session::auto_attach("nRF52840_xxAA", Permissions::default())?;
// Select a core.
let mut core = session.core(0)?;
// 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)?;
Ok(())
}
Don't hesitate to file an issue, ask questions on Matrix, or contact @Yatekii via e-mail.
There is also a troubleshooting section on the project page.
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.
Please reach out to @Yatekii
Building requires Rust and Cargo which can be installed using rustup. On Linux these can be installed with your package manager:
# Ubuntu
> sudo apt install -y libudev-dev
# Fedora
> sudo dnf install -y libudev-devel
Target files are generated using target-gen from CMSIS packs provided here.
Generated files are then placed in probe-rs/targets
for inclusion in the probe-rs project.
If there is no CMSIS-Pack with a flash algorithm available, it is necessary to write a target definition and a flash algorithm by oneself.
You can use our template for writing an algorithm. Please follow the instructions in the README.md
in that repo.
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!
Licensed under either of
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.