Tracealyzer and IAR Embedded Workbench

>Tracealyzer and IAR Embedded Workbench
Tracealyzer and IAR Embedded Workbench2018-07-05T10:10:20+00:00

When developing embedded software based on a real-time operating system (RTOS), a good understanding of the runtime behavior can save you many valuable hours when debugging and validating your application. Tracealyzer is an advanced software tracing tool designed for RTOS-based applications and provides more than 30 graphical views of the real-time behavior, making it easier reveal errors and bottlenecks. The views are interconnected in clever ways and very intuitive to use. With Tracealyzer you increase development efficiency and deliver robust, responsive software, on time and within budget.

IAR I-Jet and Renesas Synergy board
Tracealyzer 30+ views

To learn more about how Tracealyzer can be used in practice, check out the blogs and white papers on the RTOS Debug Portal. And to see what others think of Tracealyzer, check out these testimonials.

Using Tracealyzer with IAR Embedded Workbench

First, you need to enable tracing in your system. Tracealyzer uses software-based tracing, so no special hardware is required. We recommend an IAR I-Jet probe to allow for trace streaming, although this is also possible in other ways.

For ThreadX and Renesas Synergy, Tracealyzer supports the included trace recorder from Express Logic, which just needs to be enabled in your build (see this section in the User Manual). Note that this recorder library only supports snapshot mode (see below). However, streaming support for ThreadX should be available later this year.

For FreeRTOS, SafeRTOS and Micrium µC/OS-III, Percepio provides a powerful trace recorder library that supports both snapshot and streaming mode. To include this in your build, check this guide for FreeRTOS. Other RTOSes have very similar guides, found in their respective User Manual (found in the Tracealyzer Help menu).

Snapshot mode

If using “snapshot mode”, software events are stored in a on-target RAM buffer, that limits the length of the trace. The IAR debugger can be configured to save the trace buffer to a file, that Tracealyzer can then read and visualize.

Follow these steps:

  1. Download one of these macro files, depending on your RTOS, into your IAR project directory. For FreeRTOS, SafeRTOS or Micrium µC/OS, download save_trace_buffer.mac. For ThreadX, including Renesas Synergy, download save_trace_threadx.mac instead.
  2. In the ThreadX case, open the file in a text editor and make sure that the name of the trace buffer is correct, i.e. same as specified for tx_trace_enable(). If using Renesas Synergy, the default name is “g_tx_trace_buffer”.
  3. Add the macro file under Options -> Debugger -> Use Macro File(s).
  4. Check that the macro is correctly included. When in a debug session, open View -> Macros -> Debugger Macros and look for “save_trace_buffer”.
  5. Saving a trace can now be done in three ways:
    • Manually: In the “Debugger Macros” view, right-click on you macro and select “Add to Quicklaunch window”. Now you can save the trace by double-clicking on the blue “refresh” icon in the Quicklaunch window.
    • On a breakpoint: Place a breakpoint on a suitable location in the code. Open it in the breakpoint editor and enter your macro name (e.g., “save_trace_buffer()”) in the Action -> Expression field. The trace is now saved every time that breakpoint is hit.
    • On every halt: To update the trace on every halt, rename the “save_trace_buffer” function to execUserExecutionStopped(). That is a special hook that is called every time the execution is halted. Note that this can slow down single-stepping if the buffer is large.

Streaming Mode

Tracealyzer also allows for continuous streaming of the trace data via IAR I-Jet debug probes and other streaming interfaces.

Streaming via IAR Embedded Workbench and I-Jet probes is supported since Tracealyzer v4.1.5, which allow IAR users to fully benefit from the powerful capabilities of Tracealyzer 4. This leverages the ITM module found on most Arm Cortex-M3, M4 and M7 MCUs. With a fast debug probe like IAR I-Jet, ITM allows for high data rates and low tracing overhead. Moreover, unlike some other streaming solutions we support, this does not require a RAM buffer for the event data. Many thanks to Renesas for supporting this work.

Read Percepio Application Note PA-023 to learn how to use setup Tracealyzer and IAR Embedded Workbench for ITM streaming.

This video shows how it is used in practice.

Adding Tracealyzer to the Tools menu

To enable quick access to Tracealyzer, you may include a shortcut to Tracealyzer in the “Tools” menu.

  1. In the IAR “Tools” menu, select “Configure Tools…”
  2. Add a new entry, e.g., “Tracealyzer”
  3. Set the path to the Tracealyzer executable (the “.exe” file).
  4. If using snapshot mode, you can set the argument to “$PROJ_DIR$\trace.hex” to make it open the latest saved trace automatically.