rokath/trice logo

rokath/trice

Free

🟢 super fast 🚀 tiny 🐥 𝘾 printf-look-and-feel ✍ trace code, in ⚡ interrupts ⚡ too ‼️, and real-time PC 💻 logging 👀

FreeFree tier
Type
Open Source

About rokath/trice

Trice is a compact ID-based logging framework for embedded C/C++. Developers use printf-like calls in firmware code, but the target sends only small binary records (a numeric ID plus optional runtime values), drastically reducing FLASH usage, transfer bandwidth, and execution time. The PC-side trice tool reconstructs readable logs using a cumulative til.json file, which preserves old IDs and format strings for backward compatibility. Designed to be super-fast and tiny, Trice can log even from interrupt handlers in a few CPU cycles. It is ideal for scenarios where normal printf logging is too slow, too large, too intrusive, or impractical for field diagnostics.

Key Features

ID-based logging with printf-like syntax
Compact binary records (ID plus optional runtime values)
Super-fast execution, usable in interrupt handlers
Real-time PC-side logging and decoding
Cumulative til.json for backward compatibility with older firmware
Reduced target FLASH usage and transfer bandwidth
Minimal CPU cycles per log call in optimized configurations

Pros & Cons

Pros
  • Extremely fast and lightweight footprint
  • Safe to use even in interrupt handlers
  • Real-time host-side log reconstruction
  • Backward compatible with logs from older firmware versions
  • Significantly reduces FLASH usage and bandwidth compared to printf
Cons
  • Requires host-side tool and til.json for decoding logs
  • Additional build step ('trice insert') needed to assign IDs
  • Not a drop-in replacement for printf in all scenarios
  • Debugging without the host tool is not possible

Best For

Embedded firmware development and debuggingReal-time tracing in interrupt contextsField diagnostics on deployed devicesReplacing printf when too slow, large, or intrusiveLogging in resource-constrained embedded systems

FAQ

Can I use Trice inside interrupt handlers?
Yes, Trice is designed to log even from interrupt handlers in a few CPU cycles with optimized configurations.
How does ID-based decoding work?
The developer writes trice() calls with format strings. Before compilation, 'trice insert' assigns stable numeric IDs. The target sends only the ID and runtime values. The PC tool uses the til.json file to reconstruct the readable text.
What is til.json?
It is a cumulative file that stores the mapping of numeric IDs to format strings. It intentionally preserves old IDs so logs from older firmware versions can still be decoded.
Is Trice free?
Yes, Trice is open-source and free to use.
How do I start using Trice?
The quickstart guide offers several paths: using an existing non-blocking byte writer, SEGGER RTT direct mode, UART/USB-VCOM deferred output, or example projects for STM32.