probe_rs/
lib.rs

1//! # Debugging toolset for embedded devices
2//!
3//!
4//! # Prerequisites
5//!
6//! - Udev rules
7//!
8//! # Examples
9//!
10//!
11//! ## Halting the attached chip
12//! ```no_run
13//! # use probe_rs::Error;
14//! use probe_rs::probe::{list::Lister, Probe};
15//! use probe_rs::Permissions;
16//!
17//! // Get a list of all available debug probes.
18//! let lister = Lister::new();
19//!
20//! let probes = lister.list_all();
21//!
22//! // Use the first probe found.
23//! let mut probe = probes[0].open()?;
24//!
25//! // Attach to a chip.
26//! let mut session = probe.attach("nrf52", Permissions::default())?;
27//!
28//! // Select a core.
29//! let mut core = session.core(0)?;
30//!
31//! // Halt the attached core.
32//! core.halt(std::time::Duration::from_millis(10))?;
33//! # Ok::<(), Error>(())
34//! ```
35//!
36//! ## Reading from RAM
37//!
38//! ```no_run
39//! # use probe_rs::Error;
40//! use probe_rs::{Session, SessionConfig, MemoryInterface};
41//!
42//! let session_config = SessionConfig::default();
43//! let mut session = Session::auto_attach("nrf52", session_config)?;
44//! let mut core = session.core(0)?;
45//!
46//! // Read a block of 50 32 bit words.
47//! let mut buff = [0u32;50];
48//! core.read_32(0x2000_0000, &mut buff)?;
49//!
50//! // Read a single 32 bit word.
51//! let word = core.read_word_32(0x2000_0000)?;
52//!
53//! // Writing is just as simple.
54//! let buff = [0u32;50];
55//! core.write_32(0x2000_0000, &buff)?;
56//!
57//! // of course we can also write 8bit words.
58//! let buff = [0u8;50];
59//! core.write_8(0x2000_0000, &buff)?;
60//!
61//! # Ok::<(), Error>(())
62//! ```
63//!
64//! probe-rs is built around 4 main interfaces: the [Probe],
65//! [Target], [Session]  and [Core] structs.
66//!
67//! [Probe]: probe::Probe
68#![warn(missing_docs)]
69#![recursion_limit = "256"] // required by bitfield!
70#![cfg_attr(probers_docsrs, feature(doc_cfg))] // Used for docs.rs
71
72pub mod architecture;
73pub mod config;
74pub mod vendor;
75
76mod core;
77mod error;
78pub mod flashing;
79pub mod integration;
80mod memory;
81pub mod probe;
82pub mod rtt;
83pub mod semihosting;
84mod session;
85
86// TODO: Should this be public?
87#[cfg(any(test, feature = "test"))]
88pub mod test;
89
90pub use crate::config::{CoreType, Endian, InstructionSet, Target};
91pub use crate::core::dump::CoreDump;
92pub use crate::core::dump::CoreDumpError;
93pub use crate::core::registers::RegisterDataType;
94pub use crate::core::registers::UnwindRule;
95pub use crate::core::{
96    Architecture, BreakpointCause, Core, CoreInformation, CoreInterface, CoreRegister,
97    CoreRegisters, CoreState, CoreStatus, HaltReason, MemoryMappedRegister, RegisterId,
98    RegisterRole, RegisterValue, SpecificCoreState, VectorCatchCondition,
99};
100pub use crate::error::Error;
101pub use crate::memory::MemoryInterface;
102pub use crate::session::{Permissions, Session, SessionConfig};
103
104#[doc = include_str!("../../README.md")]
105#[cfg(doctest)]
106pub struct ReadmeDoctests;