Master Tracealyzer with PX5 RTOS

Getting Started with Tracealyzer on PX5 RTOS

Integrate TraceRecorder, capture your first PX5 RTOS trace, and analyze it in Tracealyzer.

Step 1

Integrate TraceRecorder

Integrate TraceRecorder into your project, enabling detailed trace analysis.

Step 2

Configure Tracing

Necessary and common trace configurations to ensure accurate and efficient trace data capture.

Step 3

Capture Your First Trace

Capture your first trace and see how your PX5 RTOS application executes.

Prerequisites

Before you begin

  • Install Tracealyzer. If you haven’t done so, see detailed instructions here
  • Existing PX5 RTOS application
  • PX5 RTOS application builds and runs
  • Target/debug connection available

Step 1: Add TraceRecorder

Integrate TraceRecorder into Your Project

Add TraceRecorder

  1. Clone the PX5-RTOS_TraceRecorder library from GitHub
  2. Include all C source files from the following folders into your PX5 RTOS project:

    PX5-RTOS_TraceRecorderSource
    PX5-RTOS_TraceRecorderSource/streamports/RingBuffer

  3. Add the following directories to your compiler’s include path:

    PX5-RTOS_TraceRecorderSource/config
    PX5-RTOS_TraceRecorderSource/include
    PX5-RTOS_TraceRecorderSource/streamports/RingBuffer/config
    PX5-RTOS_TraceRecorderSource/streamports/RingBuffer/include

  4. In PX5-RTOS_TraceRecorderSource/config/trcConfig.h set TRC_CFG_HARDWARE_PORT to the architecture used:
    • For Cortex-M3/M4/M7 devices, use TRC_HARDWARE_PORT_ARM_Cortex_M
    • For other devices, all available hardware ports can be found at the bottom of RTOS_TraceRecorderSource/include/trcDefines.h

Configure TraceRecorder

  1. In PX5-RTOS_TraceRecorderSource/config/trcConfig.h the line #error "Trace Recorder: Please include your processor's header file here and remove this line." might need to be replaced. If compilation works by only removing the line everything is fine, else it needs to be replaced with an include of the processor header file.
  2. In PX5-RTOS_TraceRecorderSource/config/trcKernelPortConfig.h set the TRC_CFG_CPU_CLOCK_HZ to the frequency used by the timer for time stamping in the hardware port.
  3. In px5_user_config.h, add #include "trcRecorder.h"
  4. Define PX5_THREAD_ENTER_EXIT_NOTIFY_ENABLE in your assembler’s preprocessor settings.

Start TraceRecorder

  1. In main after platform_setup is called (or any time after the timestamp source is setup) and before px5_pthread_start is called, add a call to xTraceEnable with TRC_START as the argument.

For complete TraceRecorder Integration details and advanced configuration, see the detailed TraceRecorder for PX5 RTOS reference guide.

C

Step 2: Configure Tracing

Configure Tracing

Initial setup

There are some configurations possible regarding the ringbuffer used for capturing the trace data. They are to be found in PX5-RTOS_TraceRecorderSource/streamports/RingBuffer/config/trcStreamPortConfig.h. Therein you’re able to set the trace buffer size and select the ringbuffer mode. This minimal configuration will allow you to capture essential trace data without overwhelming your system resources.

  • TRC_CFG_STREAM_PORT_BUFFER_SIZE decides the size of the trace buffer that is stored in RAM.
  • TRC_CFG_STREAM_PORT_RINGBUFFER_MODE can be set to
    • TRC_CFG_STREAM_PORT_RINGBUFFER_MODE_OVERWRITE_WHEN_FULL for continuously recording
    • TRC_CFG_STREAM_PORT_RINGBUFFER_MODE_STOP_WHEN_FULL for stopping when the buffer is full
Note: TraceRecorder uses “Streaming Mode” as the default recorder configuration. This mode supports both snapshot and streaming capture depending on the selected stream port. The legacy Snapshot Mode is deprecated.
C

Step 3: Trace Capture

Capture Your First Trace

The capture procedure depends on your development environment. Select the method you use below.

Snapshot

Opening the Trace

If you used Snapshot tracing, open the captured trace file in Tracealyzer. If you used Streaming, the trace is displayed in Tracealyzer as data arrives.

A successful trace should show recorded task execution, interrupts and other system events in the timeline.

If the trace is empty or doesn’t open correctly, see Troubleshooting.

Using Your Trace

Start by looking at:

  • Task scheduling — See when tasks execute, block and resume.

  • CPU usage — Identify tasks consuming significant CPU time.

  • Timing — Find long execution times and unexpected delays.

  • Interrupts — Understand how interrupts affect task execution.

  • User events — Correlate trace data with application-specific behavior and custom events/logs. All synchronized into one execution timeline.

To learn more about using Tracealyzer, see Tracealyzer Features and Capabilities.

Troubleshoot Your PX5 RTOS Trace

Resolve common TraceRecorder setup and capture issues when using Tracealyzer.

Check the Setup Before Capturing Again

Start with a PX5 RTOS application that builds and runs, a working target connection, and Tracealyzer installed on your host. Then follow the checks below for the symptom you see.
Build Fails After Adding TraceRecorder
Check that every TraceRecorder source file is included in the build and that the project compiler can find all required include directories. Review trcConfig.h for the correct hardware port and processor header, and confirm the PX5 RTOS kernel port settings match your setup. If the compiler reports a missing symbol or header, use the error message to identify the source file or include path to adjust, then rebuild.
Hardware-Port or Version Error
Check that TRC_CFG_HARDWARE_PORT in trcConfig.h matches your processor architecture and that the selected port is supported by your TraceRecorder version. Compare the PX5 RTOS integration files with the matching TraceRecorder release, then update the port or library version as needed and rebuild.
Trace File Is Empty
Confirm tracing starts after the timestamp source is initialized and before PX5 RTOS begins scheduling threads. Check that xTraceEnable is called with TRC_START and that the application reaches this call. Verify the trace buffer is configured and has enough space, then capture again. If the trace remains empty, review the hardware port and clock settings in trcConfig.h and trcKernelPortConfig.h, and make sure TraceRecorder is included and initialized correctly.
Snapshot Stops Too Soon
A snapshot capture ends when its buffer reaches capacity. Increase TRC_CFG_STREAM_PORT_BUFFER_SIZE to retain more events, or shorten the capture by reproducing only the behavior you want to inspect. Choose overwrite mode to keep the latest activity, or stop when full to preserve the earliest events. Rebuild, capture again, and check that the trace contains the relevant time period.

Enhance Your Tracing Skills

Unlock deeper insights by exploring advanced trace analysis techniques and optimize your PX5 RTOS applications.
Percepio: Sensing Software

Solutions

Tracealyzer

Detect

DevAlert

Try

Buy

Resources

Blog

White Papers

Application Notes

Videos

Company

Management

Press

Contact

Security Policy

Events

Stay in Touch

Subscribe

Copyright © 2026 Percepio AB. All rights reserved.  |  Privacy Policy  |  Licensing  |  Terms and Conditions  |  Cookie Settings