Defmt
Efficient, deferred formatting for logging on embedded systems
Install / Use
/learn @knurling-rs/DefmtREADME
defmt
defmt ("de format", short for "deferred formatting") is a highly efficient logging framework that targets resource-constrained devices, like microcontrollers.
For more details about the framework check the book at https://defmt.ferrous-systems.com.
Components
This repository contains the following packages:
| Name | Path | Description |
| ------------------- | -------------------------------------------------------------- | -------------------------------------------------------------------------- |
| defmt | ./defmt | On-target code for highly efficient logging |
| defmt-macros | ./macros | Proc Macros for defmt |
| defmt-print | ./print | CLI utility for decoding and printing defmt encoded logs to standard out |
| defmt-decoder | ./decoder | Host Library for decoding defmt log frames |
| defmt-parser | ./parser | Host Library for parsing defmt log frames |
| defmt-rtt | ./firmware/defmt-rtt | On-target library for sending defmt logs over RTT |
| defmt-itm | ./firmware/defmt-itm | On-target library for sending defmt logs over ITM |
| defmt-semihosting | ./firmware/defmt-semihosting | On-target library for sending defmt logs over semihosting |
| panic-probe | ./firmware/panic-probe | On-target library for sending panic! over defmt |
| defmt-test | ./firmware/defmt-test | Framework for running tests on-target |
| defmt-test-macros | ./firmware/defmt-test/macros | Proc Macros for defmt-test |
| defmt-json-schema | ./decoder/defmt-json-schema | Describes the JSON emitted by defmt-decoder |
MSRV
The minimum supported Rust version is 1.76 (or Ferrocene 24.05) for the crates that cross-compile to your microcontroller. The minimum supported Rust version is 1.83 for all host-side crates.
The defmt crates are tested against the latest stable Rust version and the MSRV.
Developer Information
Running Tests
Tests are run using cargo xtask -- although this is simply an alias (defined in .cargo/config.toml) for cargo run --package xtask --.
To see a list of options, see xtask/src/main.rs, or run:
cargo xtask help
For example, to run all the tests, run:
cargo xtask test-all
You will need qemu-system-arm installed and in your $PATH for some of the tests (e.g. test-snapshot).
Support
defmt is part of the Knurling project, Ferrous Systems' effort at
improving tooling used to develop for embedded systems.
If you think that our work is useful, consider sponsoring it via GitHub Sponsors.
License
Licensed under either of
-
Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
-
MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.
Related Skills
mcp-for-beginners
15.5kThis open-source curriculum introduces the fundamentals of Model Context Protocol (MCP) through real-world, cross-language examples in .NET, Java, TypeScript, JavaScript, Rust and Python. Designed for developers, it focuses on practical techniques for building modular, scalable, and secure AI workflows from session setup to service orchestration.
mcp-shrimp-task-manager
2.1kShrimp Task Manager is a task tool built for AI Agents, emphasizing chain-of-thought, reflection, and style consistency. It converts natural language into structured dev tasks with dependency tracking and iterative refinement, enabling agent-like developer behavior in reasoning AI systems.
mcp-shrimp-task-manager
2.1kShrimp Task Manager is a task tool built for AI Agents, emphasizing chain-of-thought, reflection, and style consistency. It converts natural language into structured dev tasks with dependency tracking and iterative refinement, enabling agent-like developer behavior in reasoning AI systems.
contextplus
1.5kSemantic Intelligence for Large-Scale Engineering. Context+ is an MCP server designed for developers who demand 99% accuracy. By combining RAG, Tree-sitter AST, Spectral Clustering, and Obsidian-style linking, Context+ turns a massive codebase into a searchable, hierarchical feature graph.
