Expand description
defmt global logger over RTT.
NOTE when using this crate it’s not possible to use (link to) the
rtt-target crate
To use this crate, link to it by importing it somewhere in your project.
// src/main.rs or src/bin/my-app.rs
use defmt_rtt as _;§Blocking/Non-blocking
probe-rs puts RTT into blocking-mode, to avoid losing data.
As an effect this implementation may block forever if probe-rs disconnects
at runtime. This is because the RTT buffer will fill up and writing will
eventually halt the program execution.
defmt::flush would also block forever in that case.
If losing data is not an concern you can disable blocking mode by enabling
the feature disable-blocking-mode
§Critical section implementation
This crate uses
critical-section to
ensure only one thread is writing to the buffer at a time. You must import a
crate that provides a critical-section implementation suitable for the
current target. See the critical-section README for details.
For example, for single-core privileged-mode Cortex-M targets, you can add the following to your Cargo.toml.
[dependencies]
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"]}With feature drop-on-contention you do not need a critical section
implementation and interrupts are not disabled. Instead, when execution
contexts collide, frames are dropped. This mode is for bare-metal
Cortex-M use where thread mode is a single execution context. It is not
correct on RTOS or other multi-thread-mode systems because all thread-mode
tasks share IPSR == 0, which can misidentify ownership and panic. It can
be combined with disable-blocking-mode, in which case frames that do not
already fit are dropped. Because the public write cursor advances only once
at frame end, every encoded frame in this mode must fit within the RTT
ring’s usable capacity (BUF_SIZE - 1); oversized frames are dropped even
in blocking mode.
Functions§
- in_
blocking_ mode - Report whether the SEGGER RTT up channel is in blocking mode.