#ring-buffer #rtt #debugging #read-write

probe-rs-rtt

Host side implementation of the RTT (Real-Time Transfer) I/O protocol over probe-rs

12 releases (breaking)

0.14.2 Jan 18, 2023
0.13.0 Jul 12, 2022
0.12.0 Nov 24, 2021
0.11.0 Jun 23, 2021
0.3.0 Jun 30, 2020

#1705 in Embedded development

Download history 207/week @ 2023-12-11 7/week @ 2023-12-18 6/week @ 2023-12-25 7/week @ 2024-01-01 87/week @ 2024-01-08 199/week @ 2024-01-15 240/week @ 2024-01-22 252/week @ 2024-01-29 223/week @ 2024-02-05 130/week @ 2024-02-12 339/week @ 2024-02-19 285/week @ 2024-02-26 219/week @ 2024-03-04 265/week @ 2024-03-11 69/week @ 2024-03-18 138/week @ 2024-03-25

699 downloads per month
Used in postform_rtt

MIT license

4MB
61K SLoC

probe-rs-rtt

crates.io documentation

Host side implementation of the RTT (Real-Time Transfer) I/O protocol over probe-rs.

Documentation

RTT implements input and output to/from a microcontroller using in-memory ring buffers and memory polling. This enables debug logging from the microcontroller with minimal delays and no blocking, making it usable even in real-time applications where e.g. semihosting delays cannot be tolerated.

This crate enables you to read and write via RTT channels. It's also used as a building-block for probe-rs debugging tools.


lib.rs:

Host side implementation of the RTT (Real-Time Transfer) I/O protocol over probe-rs

RTT implements input and output to/from a microcontroller using in-memory ring buffers and memory polling. This enables debug logging from the microcontroller with minimal delays and no blocking, making it usable even in real-time applications where e.g. semihosting delays cannot be tolerated.

This crate enables you to read and write via RTT channels. It's also used as a building-block for probe-rs debugging tools.

Example

use std::sync::{Arc, Mutex};
use probe_rs::{Probe, Permissions};
use probe_rs_rtt::Rtt;

// First obtain a probe-rs session (see probe-rs documentation for details)
let probe = Probe::list_all()[0].open()?;
let mut session = probe.attach("somechip", Permissions::default())?;
let memory_map = session.target().memory_map.clone();
// Select a core.
let mut core = session.core(0)?;

// Attach to RTT
let mut rtt = Rtt::attach(&mut core, &memory_map)?;

// Read from a channel
if let Some(input) = rtt.up_channels().take(0) {
    let mut buf = [0u8; 1024];
    let count = input.read(&mut core, &mut buf[..])?;

    println!("Read data: {:?}", &buf[..count]);
}

// Write to a channel
if let Some(output) = rtt.down_channels().take(0) {
    output.write(&mut core, b"Hello, computer!\n")?;
}

Dependencies

~10–21MB
~291K SLoC