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.
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).
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:
- 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.
- 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”.
- Add the macro file under Options -> Debugger -> Use Macro File(s).
- Check that the macro is correctly included. When in a debug session, open View -> Macros -> Debugger Macros and look for “save_trace_buffer”.
- 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.
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.
- In the IAR “Tools” menu, select “Configure Tools…”
- Add a new entry, e.g., “Tracealyzer”
- Set the path to the Tracealyzer executable (the “.exe” file).
- If using snapshot mode, you can set the argument to “$PROJ_DIR$\trace.hex” to make it open the latest saved trace automatically.