Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Defmt Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-defmt-knowledge-patch)
---
name: defmt-knowledge-patch
description: defmt
version: "1.2.0"
license: MIT
metadata:
author: Nevaberry
---
# defmt compatibility guidance
Load this skill when upgrading defmt or its workspace tools, deriving `Format`,
configuring log filtering, decoding firmware logs, choosing transport behavior,
or working with embedded tests and QEMU.
## Reference index
| Reference | Topics |
| --- | --- |
| [Compatibility and builds](references/compatibility-and-builds.md) | Dependency bridge, macro compatibility, Rust requirements, locked builds, Cortex-M constraint, ESP32-S2 allocation |
| [Formatting and filtering](references/formatting-and-filtering.md) | Derive attributes, `Format` implementations, display hints, bitfields, metadata, compile-time and runtime filtering |
| [Host tools and decoding](references/host-tools-and-decoding.md) | Print output and input, RTT address, ELF reloads and sections, wire format, decoder APIs and diagnostics |
| [Transports](references/transports.md) | RTT layout, buffer accounting, blocking and contention, critical sections, semihosting dependencies |
| [Testing and QEMU](references/testing-and-qemu.md) | Thumb test targets, QEMU arguments, host log marker |
## Upgrade and compatibility checks
### Dependency bridge and macro compatibility
`defmt` 0.3.100 re-exports `defmt` 1.0.0 as a compatibility bridge for 0.3
dependencies. `defmt-itm` 0.4.0, `defmt-semihosting` 0.3.0, `panic-probe` 1.0.0,
and `defmt-test` 0.4.0 switch to `defmt` 1.0.
`defmt` 0.3.10 pins `defmt-macros` to prevent incompatible combinations.
The `defmt-macros` 0.4.0 bump keeps older `defmt` releases from selecting it
as a compatible update.
### Rust and workspace dependency requirements
- `defmt` 0.3.9 sets its MSRV to Rust 1.76; `defmt-parser` documents the same MSRV.
- `defmt-print` 1.1.0, `defmt-decoder` 1.1.0, and `qemu-run` 0.3.0 require Rust 1.83.
- The workspace release adds a `cortex-m` constraint of `<0.7.8` for builds that
resolve the affected dependency; see [build details](references/compatibility-and-builds.md).
### Match arms and filtered statements
`defmt-parser` 1.0.0 makes `DisplayHint` non-exhaustive. Include a wildcard arm
when matching it in downstream code.
Starting with `defmt` 1.1.0, Rust typechecks log statements even when the
compile-time filter disables them.
### Bitfield validation
The parser update returns an error for a bare-number bitfield spec such as
`{=0}`, which previously panicked. Use an explicit range such as `{=0..1}`
to log a single bit.
### Locked workspace builds
The workspace includes a root `Cargo.lock` for reproducible binary builds.
From the workspace root, build with the recorded dependencies:
```sh
cargo build --locked -p defmt-print
```
## Derive and format values
### Derive helper attributes
`defmt-macros` 1.0.0 adds `#[defmt(crate = path)]` for renamed or re-exported
crates; 1.1.0 adds explicit bounds through `#[defmt(bound(...))]`.
With `defmt` 1.1.0, `#[defmt(transparent)]` formats a newtype as its inner
value, and `Format` accepts multiple `#[defmt(...)]` attributes.
```rust
use defmt as logfmt;
trait Loggable: logfmt::Format {}
#[derive(logfmt::Format)]
#[defmt(crate = logfmt)]
#[defmt(bound(T: Loggable))]
#[defmt(transparent)]
struct Reading<T>(T);
```
### Additional formatted types
- `defmt` 0.3.5 adds `Format` for `core::ptr::NonNull` and function pointers
with up to 12 arguments.
- `defmt` 0.3.9 adds `Format` for `core::panic::PanicInfo`.
- `defmt` 1.1.0 adds `Format` for `core::fmt::Error` and `core::num::Wrapping<T>`.
- With `defmt` 1.2.0, errors from `core::str` implement `defmt::Format`.
- With the `alloc` feature enabled, the release-note update adds `Format`
implementations for supported errors from Rust's `alloc` crate.
`defmt` 1.1.0 also supports enabling its `alloc` Cargo feature on bare-metal
ESP32-S2 targets.
### Octal and CBOR display
`defmt` 0.3.9 adds `:o` for octal output:
```rust
defmt::info!("{:o}", 0o755u16);
```
`defmt-parser` and `defmt-decoder` 1.0.0 support `:cbor` for rendering
RFC 8949-encoded bytes in diagnostic notation:
```rust
let encoded: &[u8] = &[0x82, 0x01, 0x02];
defmt::info!("{=[u8]:cbor}", encoded);
```
## Configure log filtering
`defmt` 1.0.0 records `DEFMT_LOG` in rustc dependency information so filter
changes can trigger recompilation.
With `defmt` 1.2.0, a nested module's directive can be less verbose than its
parent. This enables debug logging in `my_app` and limits `my_app::noisy`
to warnings and errors:
```sh
DEFMT_LOG=my_app=debug,my_app::noisy=warn cargo build
```
`defmt` 0.3.9 groups log-message IDs by severity, allowing a runtime filter
to use severity ranges.
## Print and decode firmware logs
### Output and input controls
- The decoder changes shipped with `defmt` 0.3.9 add optional one-line output
and render `defmt::println!` records without the log format.
- `defmt-print` 1.1.0 adds `--log-format=default` and `--log-format=online`.
- `defmt-print` 1.1.0 can read a serial port and assert DTR when connecting.
- Its `--set-addr` option sets the `_SEGGER_RTT` address explicitly.
- `defmt-print` 0.3.13 adds the `watch_elf` flag to reload the ELF while running.
- The print-tool update exits at EOF; a script feeding a finite stream can wait
for it to finish after closing the input.
### Decoder compatibility and integration
`defmt-print` 0.3.7 adds decoding for wire format version 3. Use a decoder
supporting that wire format when reading firmware logs encoded with it.
The decoder update accompanying `defmt` 1.2.0 can gather metadata from
multiple unmerged defmt sections in a firmware ELF.
With `defmt-decoder` 1.1.0:
- `Frame::fragments()` and `Frame::display_fragments()` expose frame fragments.
- `Table` and related types implement `Clone`, `serde::Serialize`, and `serde::Deserialize`.
- Returned `StreamDecoder` objects have `Send + Sync` bounds.
- The version-mismatch error no longer references `probe-run`; check the decoder
version used by the host tool when diagnosing it.
## Configure transports
Enable `defmt-rtt`'s `disable-blocking-mode` feature, available since 0.4.2,
to prevent writes from blocking on a full buffer. `defmt-rtt` 1.1.0 adds
the public `in_blocking_mode` method for checking the mode.
`defmt-rtt` 1.3.0 can drop logs under contention to keep interrupt latency low.
Enable this behavior with the opt-in Cargo feature:
```toml
[dependencies]
defmt-rtt = { version = "1.3", features = ["drop-on-contention"] }
```
Supply a target-appropriate `critical-section` implementation for `defmt-itm`
0.4.0 or `defmt-semihosting` 0.2.0, which use it for transport synchronization.
`defmt-rtt` 0.4.2 updates its `critical-section` dependency to 1.2; if the
workspace pins it, allow 1.2 or a later compatible release.
## Run embedded tests and QEMU
`defmt-test` 0.5.0 switches to the generic `semihosting` crate so the test
harness can run on non-Cortex-M Thumb targets.
`qemu-run` 0.3.0 accepts `--arg name=value` to pass `-name value` to QEMU.
For example, `--arg cpu=cortex-m3` passes `-cpu cortex-m3`.
Its decoder upgrade moves `(HOST)` to the end of host log lines; look for
the marker at the end when parsing them.