DEV.co
Open-Source Observability · knurling-rs

defmt

defmt is an open-source logging framework optimized for embedded systems and microcontrollers, emphasizing memory efficiency through deferred formatting. It provides both on-target logging libraries and host-side decoding tools, supporting multiple transport protocols (RTT, ITM, semihosting).

Source: GitHub — github.com/knurling-rs/defmt
1.2k
GitHub stars
129
Forks
Rust
Primary language
Apache-2.0
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositoryknurling-rs/defmt
Ownerknurling-rs
Primary languageRust
LicenseApache-2.0 — OSI-approved
Stars1.2k
Forks129
Open issues115
Latest releasedefmt-v1.1.1 (2026-07-03)
Last updated2026-07-03
Sourcehttps://github.com/knurling-rs/defmt

What defmt is

defmt uses compile-time format string interning and on-device binary encoding to reduce RAM and code footprint on resource-constrained targets. The ecosystem includes proc macros, transport adapters (defmt-rtt, defmt-itm, defmt-semihosting), a decoder library, CLI tools, and test framework integration.

Quickstart

Get the defmt source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/knurling-rs/defmt.gitcd defmt# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

ARM Cortex-M microcontroller logging

Primary use case: embedded projects requiring low-overhead, efficient debug logging on memory-constrained ARM platforms via RTT, ITM, or semihosting transports.

Resource-constrained IoT and edge devices

Ideal for battery-powered or flash-limited devices where traditional logging frameworks consume too much memory or power.

Embedded test infrastructure

defmt-test provides on-target unit testing with efficient output, suitable for firmware validation without external test runners.

Implementation considerations

  • Minimum Rust version: 1.76 for cross-compile targets, 1.83 for host tools; verify your embedded toolchain meets these requirements.
  • Transport selection: choose between RTT (fastest, requires debug probe), ITM (ARM Serial Wire Viewer), or semihosting (slowest, maximum compatibility); each has different hardware and tooling dependencies.
  • Proc macro dependencies: defmt-macros must be kept in sync with the defmt crate version to avoid format string mismatches.
  • MSRV testing: the project tests against stable Rust and declared MSRV; pin versions if stability is critical for your build pipeline.
  • Symbol table embedding: defmt requires embedding metadata in firmware binaries for decoding; verify linker script and binary size impact.

When to avoid it — and what to weigh

  • Desktop or cloud applications — defmt is purpose-built for embedded systems; general-purpose applications should use standard logging crates (tracing, log, etc.).
  • Need for third-party integration without custom transport — If your device uses a non-standard debug interface not covered by RTT, ITM, or semihosting, you must write a custom transport layer.
  • Minimal Rust expertise on the team — defmt requires understanding of Rust macros, embedded Rust conventions, and debugger/RTT tooling; steep learning curve for non-embedded teams.
  • Projects not using Rust — defmt is Rust-only; C or C++ embedded projects cannot use this framework directly.

License & commercial use

Dual-licensed under Apache License 2.0 and MIT. Both are permissive, OSI-approved open-source licenses.

Both Apache-2.0 and MIT are permissive licenses that allow commercial use, modification, and distribution without royalties. Attribution is required for Apache-2.0; MIT requires only license retention. No trademark or patent clauses add restrictions. Suitable for commercial embedded products, but standard legal review recommended for your use case.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationStrong
License clarityClear
Deployment complexityModerate
DEV.co fitGood
Assessment confidenceHigh
Security considerations

No explicit security audit data provided. Considerations: (1) defmt encodes log data; review transport layer security (RTT/ITM/semihosting are debug-only, not production-secure), (2) debug probes may expose internal state via captured logs, (3) proc macros execute at compile-time—audit macro code if using untrusted dependencies, (4) symbol table in binary may leak internal structure; consider stripping or obfuscating for production if needed. No known CVEs mentioned in data.

Alternatives to consider

log + slog crates

Standard Rust logging ecosystem; larger footprint and not optimized for RAM-constrained targets. Use if you need broader ecosystem support or non-embedded deployment.

probe-run (alternative transport)

probe-run is a companion tool, not an alternative logging framework. If you need ultra-minimal on-target overhead, consider custom binary logging with defmt as the decoder layer.

cortex-m-semihosting + simple fmt

Basic semihosting combined with manual formatting; much lower-level, higher RAM overhead, but requires no additional tooling. Only viable for very small debug sessions.

Software development agency

Build on defmt with DEV.co software developers

defmt is production-ready for Rust-based embedded systems. Review the Knurling book, test with your target hardware and debug probe, and consider transport selection (RTT/ITM/semihosting) early. Commercial use is permitted under Apache-2.0 or MIT licenses.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

defmt FAQ

Does defmt require a specific debugger or debug probe?
No single probe required, but transport choice determines dependencies: RTT requires a compatible probe (J-Link, ST-Link, OpenOCD-compatible); ITM requires ARM Serial Wire Viewer support; semihosting works with any GDB-compatible debugger. See documentation for probe compatibility matrix.
Can I use defmt in production/release builds?
Yes, defmt is designed for low overhead and can be compiled into release builds. However, debug transport layers (RTT, ITM, semihosting) are debug-only; for production, you would need a custom transport (e.g., UART) or disable logging entirely. This is not documented in the provided data; requires review.
What is the binary size overhead?
Not quantified in the provided data. The efficiency claim is based on deferred formatting (format strings stored once, not repeated). Symbol table embedding adds some overhead; exact figures require benchmarking against your target device and code. See defmt book or run benchmarks.
Is defmt compatible with async/await and RTIC?
Not explicitly stated in the data. The README mentions no async-specific concerns, and the project is modern (Rust 1.76+), suggesting compatibility, but integration details require review of the defmt book and RTIC ecosystem.

Software development & web development with DEV.co

Need help beyond evaluating defmt? DEV.co is a software development agency offering software development services and web development for teams of every size. Our software developers and web developers build custom software, web applications, APIs, and open-source observability integrations — and maintain them long-term.

Evaluate defmt for Your Embedded Project

defmt is production-ready for Rust-based embedded systems. Review the Knurling book, test with your target hardware and debug probe, and consider transport selection (RTT/ITM/semihosting) early. Commercial use is permitted under Apache-2.0 or MIT licenses.