pub struct DebugNet<'a> { /* private fields */ }Expand description
Handle for a debug-probe net (blocking).
Created via crate::LagerBox::debug. Cheap to construct; the net’s
saved record is fetched from the box on first use and cached on the
handle (clones share the cache), so back-to-back debug ops pay for
/nets/list once instead of per call. The cache is invalidated when an
operation fails, so a re-saved net record is picked up on retry.
Implementations§
Source§impl DebugNet<'_>
impl DebugNet<'_>
Sourcepub fn connect(&self) -> Result<DebugConnection>
pub fn connect(&self) -> Result<DebugConnection>
Connect to the probe with default options (starts a GDB server).
Sourcepub fn connect_with(&self, opts: &ConnectOptions) -> Result<DebugConnection>
pub fn connect_with(&self, opts: &ConnectOptions) -> Result<DebugConnection>
Connect to the probe with explicit options.
Sourcepub fn disconnect(&self, keep_running: bool) -> Result<()>
pub fn disconnect(&self, keep_running: bool) -> Result<()>
Disconnect. If keep_running is true the gdbserver is left running so
an external GDB client can stay attached.
Sourcepub fn reset(&self, halt: bool) -> Result<()>
pub fn reset(&self, halt: bool) -> Result<()>
Reset the target, optionally halting at the reset vector.
Sourcepub fn flash(&self, firmware_path: impl AsRef<Path>) -> Result<()>
pub fn flash(&self, firmware_path: impl AsRef<Path>) -> Result<()>
Flash a firmware file, inferring the type from its extension
(.hex, .elf, .bin). .bin is flashed at 0x08000000; use
DebugNet::flash_bin to choose the address.
Sourcepub fn flash_bin(
&self,
firmware_path: impl AsRef<Path>,
address: u32,
) -> Result<()>
pub fn flash_bin( &self, firmware_path: impl AsRef<Path>, address: u32, ) -> Result<()>
Flash a raw binary at an explicit base address.
Sourcepub fn flash_bytes(
&self,
contents: &[u8],
kind: FirmwareKind,
address: Option<u32>,
) -> Result<()>
pub fn flash_bytes( &self, contents: &[u8], kind: FirmwareKind, address: Option<u32>, ) -> Result<()>
Flash raw firmware bytes of a known kind.
Sourcepub fn read_memory(&self, address: u64, length: usize) -> Result<Vec<u8>>
pub fn read_memory(&self, address: u64, length: usize) -> Result<Vec<u8>>
Read length bytes of target memory starting at address.
Sourcepub fn info(&self) -> Result<DebugInfo>
pub fn info(&self) -> Result<DebugInfo>
Probe/target information (device, arch, backend, connected state).
Sourcepub fn status(&self) -> Result<DebugStatus>
pub fn status(&self) -> Result<DebugStatus>
Whether a gdbserver/daemon is currently running for this probe.
Sourcepub fn rtt(&self) -> Result<RttStream>
pub fn rtt(&self) -> Result<RttStream>
Open an RTT log stream on channel 0.
Returns a reader that yields the target’s RTT output as raw bytes
until the connection closes or the reader is dropped. Wrap it in a
std::io::BufReader to read lines.
Sourcepub fn rtt_with(&self, opts: &RttOptions) -> Result<RttStream>
pub fn rtt_with(&self, opts: &RttOptions) -> Result<RttStream>
Open an RTT log stream with explicit options.
Sourcepub fn rtt_interactive(&self) -> Result<RttSession>
pub fn rtt_interactive(&self) -> Result<RttSession>
Open a bi-directional RTT session on channel 0 (feature rtt,
box software >= 0.35.0).
Unlike DebugNet::rtt, the returned session can also write to
the target’s RTT down-channel, so firmware that reads commands over
RTT can be driven from a test:
use std::time::Duration;
use lager::LagerBox;
let lager = LagerBox::from_env()?;
let debug = lager.debug("debug1");
debug.connect()?; // gdbserver must be up first
let mut rtt = debug.rtt_interactive()?;
rtt.write_str("self_test\n")?;
rtt.wait_for(b"self_test: pass", Duration::from_secs(5))?;Two prerequisites (see crate::nets::rtt for the full story): the
gdbserver must already be running — call DebugNet::connect first —
and writing needs a firmware-declared RTT down buffer on the
channel (defmt-rtt alone only provides the up buffer; without one
the target silently discards writes).
Sourcepub fn rtt_interactive_with(&self, opts: &RttOptions) -> Result<RttSession>
pub fn rtt_interactive_with(&self, opts: &RttOptions) -> Result<RttSession>
Open a bi-directional RTT session with explicit options
(feature rtt). opts.channel selects the RTT channel in both
directions.