Coder Social home page Coder Social logo

oll3 / probe-rs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from probe-rs/probe-rs

0.0 0.0 0.0 22.76 MB

A debugging toolset and library for debugging embedded ARM and RISC-V targets on a separate host

Home Page: https://probe.rs

License: Apache License 2.0

Shell 0.01% Assembly 0.02% Rust 99.97% Dockerfile 0.01%

probe-rs's Introduction

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.10.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

Support

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.

Tools

In addition to being a library, probe-rs also includes a suite of tools which can be used for flashing and debugging.

Installation

After installing the necessary prerequisites, the tools can be installed using cargo install:

cargo install probe-rs --features cli

See the website for a more detailed guide.

cargo-flash

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.

cargo-embed

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.

VSCode

We have implemented the Microsoft DAP protocol. This makes embedded debugging via probe-rs available in modern code editors implementing the standard, such as VSCode. Please see the website for more information.

Usage Examples

Halting the attached chip

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(())
}

Reading from RAM

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(())
}

FAQ

I need help!

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

There is also a trouble-shooting section on the project page.

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

Building

Building requires Rust and Cargo which can be installed using rustup. probe-rs also depends on libusb and libftdi. On linux these can be installed with your package manager:

# Ubuntu
> sudo apt install -y libusb-1.0-0-dev libftdi1-dev libudev-dev libssl-dev

# Fedora
> sudo dnf install -y libusbx-devel libftdi-devel libudev-devel openssl-devel

On Windows you can use vcpkg:

# dynamic linking 64-bit
> vcpkg install libftdi1:x64-windows libusb:x64-windows
> set VCPKGRS_DYNAMIC=1

# static linking 64-bit
> vcpkg install libftdi1:x64-windows-static-md libusb:x64-windows-static-md

See the vcpkg crate documentation for more information about configuring vcpkg with rust.

Adding Targets

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.

Writing new flash algorithms

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.

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.

probe-rs's People

Contributors

bors[bot] avatar yatekii avatar tiwalun avatar noppej avatar dependabot[bot] avatar dirbaio avatar adamgreig avatar tmplt avatar renovate[bot] avatar ryan-summers avatar diondokter avatar therealprof avatar disasm avatar jacobrosenthal avatar dbrgn avatar ruabmbua avatar mabezdev avatar dependabot-preview[bot] avatar thefaxman avatar rnestler avatar benmkw avatar hannobraun avatar jonas-schievink avatar thalesfragoso avatar hargonix avatar bjoernq avatar jannic avatar mvirkkunen avatar urhengulas avatar jgust avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.