# trice **Repository Path**: veyun/trice ## Basic Information - **Project Name**: trice - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-06-17 - **Last Updated**: 2024-06-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ![TriceGirlS.png](./docs/ref/TriceGirl-167x222.png) **Trice** <- **TR**~~ace~~ **I**~~ds~~ **C** **E**~~mbedded~~ [github.io/trice/](https://rokath.github.io/trice/) ![GitHub issues](https://img.shields.io/github/issues/rokath/trice) ![GitHub All Releases](https://img.shields.io/github/downloads/rokath/trice/total) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/rokath/trice) ![GitHub watchers](https://img.shields.io/github/watchers/rokath/trice?label=watch) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/rokath/trice) ![GitHub commits since latest release](https://img.shields.io/github/commits-since/rokath/trice/latest) [![Go Report Card](https://goreportcard.com/badge/github.com/rokath/trice)](https://goreportcard.com/report/github.com/rokath/trice) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![test](https://github.com/shogo82148/actions-goveralls/workflows/test/badge.svg?branch=main)](https://coveralls.io/github/rokath/trice) [![Coverage Status](https://coveralls.io/repos/github/rokath/trice/badge.svg?branch=master)](https://coveralls.io/github/rokath/trice?branch=master) Log in (a) trice ([S>G](https://www.screentogif.com/)) ![ ](./docs/ref/life0.gif) even inside **↯ interrupts** in less than 1 µs❗ ## About - Replace `printf` or `log` in **C**-code for getting: - **[Speed](./docs/TriceSpeed.md)**, to be usable also **inside interrupts**, - **[Space](./docs/TriceSpace.md)**, to reduce needed FLASH memory size, - **[Features](./docs/TraceWithTrice.md#Tricefeatures)** delighting the developers heart. - Main idea: Logging strings **not** into an embedded device to display them later on a PC but keep [usage comfortable and simple](./docs/TriceUserGuide.md#2-get-started). - *Trice* consists of 2 parts: 1. **C** code `TRICE` macros generating tiny & super-fast embedded device real-time trace/log code 2. Tool **trice** for managing and visualization. - Written in [Go](https://golang.org/) and therefore usable on all platforms Go supports. - You can also use your own environment to receive the *Trice* packages, exchange the carried IDs with the format string and print out. - [Trice User guide](./docs/TriceUserGuide.md) ## Possible Use Cases - Using *Trice* not only for **printf debugging** but also as **logging** technique is possible and gives the advantage to have very short messages (no strings) for transmission, but keep in mind that the file [til.json](./test/testdata/til.json) is the key to read all output if your devices in the field for 10 or more years. - Optionally add [til.json](./test/testdata/til.json) as a (compressed) resource to your target image. One possibility is using [SRecord](http://srecord.sourceforge.net/download.html). Or simply provide a download link. - You can see *Trice* also as a kind of **data compression** what could be interesting for [IoT](https://en.wikipedia.org/wiki/Internet_of_things) things, especially [NB-IoT](https://en.wikipedia.org/wiki/Narrowband_IoT), where you have very low data rates. - Storing *Trice* messages in [FLASH memory](https://en.wikipedia.org/wiki/Flash_memory) for later log analysis saves memory because a typical `TRICE` occupies only 4 bytes independently of the format string length plus optional values. - Also, it is possible to **encrypt** the *Trice* transfer packets to get a reasonable protection for many cases. - This way you can deliver firmware images with encrypted *Trice* output, only readable with the appropriate key and [til.json](./test/testdata/til.json). - [XTEA](https://en.m.wikipedia.org/wiki/XTEA) is implemented as one option. - You can even translate the [til.json](./test/testdata/til.json) file in **different languages**, so changing a language is just changing the [til.json](./test/testdata/til.json) file without touching the target binary. - With *Trice* it is easy to do **timing analysis** on distributed embedded systems. Host and target timestamps are supported. ## How it approximately works (UART example) This slightly simplified [view](https://github.com/jgraph/drawio) is explained [here](./docs/TraceWithTrice.md#4-how-it-works---the-main-idea) ![trice](./docs/ref/triceCOBSBlockDiagram.svg) ## Data Transfer - Implemented: - [UART](https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter) connectable to virtual UART over USB - [RTT](https://www.segger.com/products/debug-probes/j-link/technology/about-real-time-transfer/) over [J-Link](./third_party/segger.com/ReadMe.md) and [RTT over ST-Link](./third_party/goST/ReadMe.md) - A small separate microcontroller is always usable as interfaces bridge to [GPIO](https://circuitcellar.com/cc-blog/a-trace-tool-for-embedded-systems/), [I²C](https://en.wikipedia.org/wiki/I%C2%B2C), [SPI](https://en.wikipedia.org/wiki/Serial_Peripheral_Interface), [CAN](https://en.wikipedia.org/wiki/CAN_bus), [LIN](https://en.wikipedia.org/wiki/Local_Interconnect_Network), ... - With a Chip from FTDI, check for example [Adafruit FT232H Breakout](https://learn.adafruit.com/adafruit-ft232h-breakout), GPIO, I2C and SPI are easy accessable. ## Display server option Start `trice ds` inside a console, option: [third_party/alacritty](./third_party/alacritty), locally or on a remote PC and connect with several **trice** tool instances like with `trice log -p COM15 -ds` for example. ## Documentation - [https://interrupt.memfault.com/blog/trice](https://interrupt.memfault.com/blog/trice) - [Trice User Guide](./docs/TriceUserGuide.md) - Check the [docs](./docs) folder. No need to read all this stuff - it is just for help and reference. ## Support? Yes please - or simply :star: it. ☺ Cloning the repo: ```b git clone https://github.com/rokath/trice.git ``` ## Similar projects - [baical.net](http://baical.net/up7.html) (C) - [call stack logger function instrumentation](https://dev.to/taugustyn/call-stack-logger-function-instrumentation-as-a-way-to-trace-programs-flow-of-execution-419a) (a way to trace programs flow of execution) - [Debugging with Dynamic Printf Breakpoints](https://mcuoneclipse.com/2022/02/09/debugging-with-dynamic-printf-breakpoints/) (Eclipse IDE option) - [defmt](https://github.com/knurling-rs/defmt) (Rust) - [Diagnostic Log and Trace](https://github.com/COVESA/dlt-daemon) (AUTOSAR) - [elog](https://github.com/martinribelotta/elog) (Embedded logger with minimal footprint and memory usage) - [J-Link System View](https://www.segger.com/products/development-tools/systemview/technology/what-is-systemview/) (SEGGER) - [Logging with symbols - The Embedonomicon](https://docs.rust-embedded.org/embedonomicon/logging.html) - [Memfault Compact Log Library](https://docs.memfault.com/docs/mcu/compact-logs/#host-decoding) - [Metal Serial Library](https://github.com/metal-ci/test/tree/master/doc/metal.serial.md) - [Minimal Structured Logging for Autonomous Vehikles](https://youtu.be/FyJI4Z6jD4w) (C++, closed source talk) - [NanoLog](https://github.com/PlatformLab/NanoLog) (Linux C++) - [Percepio Tracealyzer](https://percepio.com/tracealyzer/) (Visual Trace Diagnostics) - [Pigweed Trace Tokenized](https://pigweed.dev/pw_trace_tokenized/) - [qpspy](https://www.state-machine.com/qtools/qpspy.html) (C/C++) - [Serial-Studio](https://github.com/Serial-Studio/Serial-Studio) (Data visualisation) - [Traces](https://github.com/yotamr/traces) (API tracing framework for Linux C/C++ applications - [Zepyr Dictionary Based Logging](https://docs.zephyrproject.org/3.1.0/services/logging/index.html#dictionary-based-logging) ## Debugging using VS-Code and Clang for a Trice-instrumented Project in Direct-Out Mode over SEGGER-RTT (See folder [./examples](./examples) for more details.) ![x](./examples/Animation.gif)