Skip to content
Back to skills

Defmt Knowledge Patch

ASecurity

defmt

  • 25 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added December 1, 2026
developmentrustgotestingapibackend

Works with

  • api

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill defmt-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Defmt Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Defmt Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-defmt-knowledge-patch-nevaberry-plugins/badge)](https://www.skillsdirectory.com/skills/nevaberry-defmt-knowledge-patch-nevaberry-plugins)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: defmt-knowledge-patch
description: defmt
version: "1.2.0"
license: MIT
metadata:
  author: Nevaberry
---


# defmt compatibility guidance

Load this skill when upgrading defmt dependencies, deriving `Format`, configuring
log filtering, decoding firmware logs, or working with transports and embedded tests.
Use the topic references for package-specific behavior and dependency requirements.

## Reference index

| Reference | Topics |
| --- | --- |
| [Upgrades and builds](references/upgrades-and-builds.md) | Compatibility bridge, macro dependencies, Rust requirements, locked builds, Cortex-M constraint |
| [Formatting and filtering](references/formatting-and-filtering.md) | Derive attributes, implementations, display hints, bitfields, metadata, `DEFMT_LOG` |
| [Host decoding and printing](references/host-decoding-and-printing.md) | Decoder compatibility, ELF metadata, output formats, serial input, RTT address, EOF, decoder APIs |
| [Transports](references/transports.md) | RTT layout, buffering, blocking and contention, synchronization, 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 all 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.

### Disabled log statements still typecheck

Starting with `defmt` 1.1.0, Rust typechecks log statements even when the filter
disables them. `defmt` 1.0.0 records `DEFMT_LOG` in rustc dependency information,
so changing the filter can trigger recompilation.

### Match display hints with a wildcard

`defmt-parser` 1.0.0 marks `DisplayHint` as non-exhaustive.
Include a wildcard arm when matching it in downstream code.

### Use an explicit bitfield range

The parser returns an error for a bare-number bitfield spec such as `{=0}`;
this previously caused a panic. Use `{=0..1}` to log a single bit.

### Rust and workspace dependency requirements

`defmt` 0.3.9 sets its MSRV to Rust 1.76, also the documented MSRV for
`defmt-parser`. `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` version constraint of `<0.7.8` for
builds that resolve the affected dependency.

### Diagnose decoder compatibility

`defmt-print` 0.3.7 adds decoding support for wire format version 3.
Use a decoder supporting that wire format when reading firmware logs encoded with it.
`defmt-decoder` 1.1.0 removes the `probe-run` reference from its version-mismatch
error; check the decoder version used by the host tool when diagnosing it.

## Formatting and filtering quick reference

### Derive through a renamed crate with explicit bounds

`defmt-macros` 1.0.0 adds `#[defmt(crate = path)]` for renamed or re-exported
crates; 1.1.0 adds `#[defmt(bound(...))]` for explicit bounds.
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);
```

### Reduce logging in a nested module

In `defmt` 1.2.0, a nested module's `DEFMT_LOG` directive can set a less verbose
level 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.

### Display octal values and CBOR bytes

`defmt` 0.3.9 adds `:o` for octal output:
`defmt::info!("{:o}", 0o755u16)`.
`defmt-parser` and `defmt-decoder` 1.0.0 support `:cbor` for RFC 8949-encoded
bytes rendered in diagnostic notation.

```rust
let encoded: &[u8] = &[0x82, 0x01, 0x02];
defmt::info!("{=[u8]:cbor}", encoded);
```

### Log supported errors directly

With `defmt` 1.2.0, errors from `core::str` implement `defmt::Format`.
For example, log a `Utf8Error` returned by `core::str::from_utf8` with
`defmt::warn!("{}", error)`.
With the `defmt` `alloc` feature enabled, new `Format` implementations let
firmware pass supported errors from Rust's `alloc` crate directly to logging macros.

See [formatting and filtering](references/formatting-and-filtering.md) for the
other added implementations, ESP32-S2 allocation support, and metadata emission.

## Host tools quick reference

### Build with recorded dependencies

The workspace includes a root `Cargo.lock` for reproducible binary builds.
From the workspace root, use `cargo build --locked -p defmt-print`.

### Select output and input behavior

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`.
It also supports reading log data from a serial port and can assert DTR on connection.
Use its `--set-addr` option to set the `_SEGGER_RTT` address explicitly.

### Reload metadata and finish finite streams

`defmt-print` 0.3.13 adds the `watch_elf` flag to reload the ELF while the
process continues running. The decoder update accompanying `defmt` 1.2.0
can gather metadata from multiple unmerged defmt sections in a firmware ELF.
The `defmt-print` update exits at input EOF, so a script feeding a finite
stream can wait for the process to finish after closing the input.

See [host decoding and printing](references/host-decoding-and-printing.md)
for frame fragments, table serialization, and stream decoder bounds.

## Transport quick reference

### Control RTT blocking and contention

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 the opt-in behavior with:

```toml
[dependencies]
defmt-rtt = { version = "1.3", features = ["drop-on-contention"] }
```

### Supply transport synchronization

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 a workspace
pins this dependency, allow 1.2 or a later compatible release.

`defmt-semihosting` 0.2.0 switches to the `semihosting` crate. If patching the
backend in a workspace, apply the patch to `semihosting`.
See [transports](references/transports.md) for RTT layout and buffer fixes,
RTT panic removal, and the semihosting dependency removal.

## Embedded testing quick reference

`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 those lines.

Files in this skill

  • SKILL.md7.3 KB
  • coverage.json927 B
  • references/formatting-and-filtering.md3.1 KB
  • references/host-decoding-and-printing.md1.9 KB
  • references/testing-and-qemu.md613 B
  • references/transports.md1.9 KB
  • references/upgrades-and-builds.md1.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.