defmt logo

defmt

Free

a highly efficient logging framework that targets resource-constrained devices, like microcontrollers.

FreeFree tier
Type
Open Source
Company
Ferrous Systems

About defmt

defmt (short for 'deferred formatting') is a highly efficient logging framework designed for resource-constrained devices such as microcontrollers. It minimizes the time spent in log statements by deferring the formatting of log messages to the host side, resulting in smaller binary sizes and lower CPU overhead. The framework includes on-target libraries for sending logs over RTT, ITM, or semihosting, a host-side decoder and CLI utility (defmt-print) for viewing logs, proc macros for easy integration, and a test framework for running tests on target. defmt is part of the Knurling project by Ferrous Systems and is available as open-source under Apache 2.0 or MIT license.

Key Features

Deferred formatting minimizes time spent in log statements on the microcontroller
Multiple transport options: RTT, ITM, and semihosting
Host-side decoder and CLI tool (defmt-print) for decoding and viewing logs
Proc macros for simple integration with Rust code
On-target test framework (defmt-test) for running tests on microcontrollers
Panic handler (panic-probe) that sends panic messages via defmt
Supports resource-constrained devices with low binary size and CPU overhead

Pros & Cons

Pros
  • Highly efficient: deferred formatting reduces CPU and memory overhead on the device
  • Small binary footprint compared to traditional logging frameworks
  • Flexible transport options (RTT, ITM, semihosting) for different debugging setups
  • Part of the well-established Knurling project by Ferrous Systems
  • Open source with permissive licensing (Apache 2.0 or MIT)
  • Integrates seamlessly with the Rust embedded ecosystem
Cons
  • Limited to Rust programming language
  • Requires host-side decoder to view human-readable logs (additional setup)
  • Deferred formatting concept may have a learning curve for new users
  • Primarily focused on embedded systems; not suitable for general-purpose logging

Best For

Logging and debugging on microcontrollers and embedded systemsFirmware development with real-time constraintsMonitoring resource-constrained devices during developmentRunning on-target tests with defmt-testAnalyzing panic conditions in embedded Rust applications

FAQ

What does defmt stand for?
defmt stands for 'deferred formatting' (or 'de format' in short). It defers the formatting of log messages to the host side.
What transports are supported for sending logs?
defmt supports RTT (Real-Time Transfer), ITM (Instrumentation Trace Macrocell), and semihosting for transmitting log frames from the microcontroller to the host.
How do I decode and view defmt logs?
Use the defmt-print CLI utility included in the repository. It decodes the binary log frames and prints them to standard output on the host.
Is defmt free to use?
Yes, defmt is open source and free to use. It is licensed under Apache 2.0 or MIT at your option.