Coder Social home page Coder Social logo

freertos-btf-trace's Introduction

FreeRTOS-BTF-Trace

Codacy Badge

Generate BTF trace file or VCD waveform for FreeRTOS.

BTF (Best Trace Format) is a CSV-based format used to record and trace at the system level to analyze the timing, performance, and reliability of embedded real-time systems. The spec can be found here.

VCD (Value Change Dump) is an ASCII-based format for dumpfiles generated by EDA logic simulation tools, which can be opened by GTKWave tool.

Tracelyzer from Percepio is the best analysis tools to visualize the real-time execution of tasks and ISRs. However, sometimes we just need a simple solution to find the performance bottleneck. This project provides a simple and extensible framework for this, and most importantly, it is open source and free.

There's another related solution is using BareCTF and Trace Compass to trace FreeRTOS system in freerots-barectf.

Build

This is an example to test srv32 on FreeRTOS. The code can be run on the ISS (Instruction Set Simulator) of srv32 to generate trace data in BTF and VCD format. I use srv32 to run the test, and this can be easily ported to another platform.

Requirement: Install the toolchains. See details in srv32 Building toolchains section.

The file "trace.btf" and "trace.vcd" will be generated under tracedata folder. Open it by the Trace Compass (for trace.btf) or VCD viewer (for trace.vcd).

$ make run

Results

This is a screen shot of Trace Compass by reading the BTF trace file. Use the gentrace tool to convert the trace data into BTF format.

$ gentrace dump.bin trace.btf

trace-compass

This is the VCD waveform showing task switching. Use gentrace tool to generate trace data into VCD format.

$ gentrace -v dump.bin trace.vcd

vcd

Porting guide

  1. Include FreeRTOS-Trace/FreeRTOS-Trace.h in your FreeRTOSConfig.h.
  2. Provide xGetTime() macro in FreeRTOS-Trace/btf_port.h to report the system time in nanoseconds.
  3. Keep HAVE_SYS_DUMP undefined in FreeRTOS-Trace/btf_port.h.
  4. Compile the code FreeRTOS-Trace/btf_trace.c with your project.
  5. Call traceSTART() in your application to enable trace log.
#if configUSE_TRACE_FACILITY
    traceSTART();
#endif
  1. Call traceEND() in your application to disable trace log.
#if configUSE_TRACE_FACILITY
    traceEND();
#endif
  1. After the application is built, use readelf to find the location of trace_data. Run the application and dump the memory to a binary file. In this example, you should dump 65572 bytes of data from address 0x21d44.
$ readelf -a task.elf
...
21: 00021d44 65572 OBJECT  LOCAL  DEFAULT    4 trace_data
...
  1. Using gentrace tools to convert trace data to BTF file.
$ ../../tools/gentrace dump.bin trace.btf
814 events generated
  1. Open the BTF file with Trace Compass to view the trace file.

License

MIT license

freertos-btf-trace's People

Contributors

kuopinghsu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.