Master Tracealyzer with Bare Metal

Getting Started with Tracealyzer on Bare Metal

Integrate TraceRecorder, capture your first Bare Metal 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 Bare Metal application executes.

Prerequisites

Before you begin

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

Step 1: Add TraceRecorder

Integrate TraceRecorder into Your Project

TraceRecorder

  1. Add the following TraceRecorder source files to your project and make sure they are compiled:
    TraceRecorder/src/*.c
  2. Add the following TraceRecorder header files to your project:
    TraceRecorder/include/*.h
    Make sure to update the compiler’s include path to ensure all header files are found!

Configure TraceRecorder

  1. In config/trcConfig.h, set TRC_CFG_HARDWARE_PORT to a suitable hardware port for your device (see include/trcDefines.h and include/trcHardwarePort.h)
  2. If your application builds after removing the line #error "Trace Recorder: Please include your processor's header file …" in config/trcConfig.h, everything is fine, else replace it with your processors header file

Start TraceRecorder

  1. Enable tracing by adding a call in your main function to xTraceEnable(TRC_START);
    This should be done after the initial hardware setup, but must be called before any other TraceRecorder functions. Optionally, xTraceInitialize() can be used to initialize the trace system without starting the tracing. Then call xTraceEnable() at a later point to start the tracing.

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

C

Step 2: Configure Tracing

Configure Tracing

Initial setup

You’ll begin by selecting a capture method that suits your needs, either Snapshot or Streaming. Each method offers unique benefits, so consider your requirements carefully before proceeding.

  • Snapshot: Store trace data in target RAM and retrieve it later by utilizing the RingBuffer stream port.

  • Streaming: Continuously transfer trace data to Tracealyzer using a stream port such as J-Link RTT, TCP/IP etc.

Recommended: Capture your first trace with Snapshot

Snapshot tracing is the simplest way to verify that TraceRecorder is working. It stores the latest trace data in target RAM using the RingBuffer stream port.

Need long-running or live traces?

Use Streaming instead.

Snapshot

Run → Halt → Save Snapshot → Open in Tracealyzer

Ensure the trcStreamPort_RingBuffer.c is copied into your project (should already be if you followed instructions above)

Set the trace buffer size and select the ringbuffer mode in trcConfig.h. 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. A larger buffer stores more trace history but uses more RAM. Start with the default/recommended value of 10240 bytes and increase it if you need a longer trace.
  • 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

After your application has run, halt the target and store the RingBuffer content to your host. Instructions for how to achieve this in an easy manner may be found under “Capture Your First Trace” below.

Streaming

Run → Continously Capture in Tracealyzer → Stop

Streaming reduces the limitation imposed by the target’s RAM because trace data is continuously transferred to the host. The practical trace length and reliability still depend on the transport and its available bandwidth. To setup streaming you will:

  1. Start by selecting a method for your data streaming
    Streaming method Typical use
    J-Link RTT Debug probe
    TCP/IP Network-connected target
    ITM ARM Cortex-M + debugger
    Other stream ports See stream-port documentation
  2. Update the stream port configuration in config/trcConfig.h to match your desired streaming solution.
  3. Ensure your target settings are matched in Tracealyzer application.
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

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 Bare Metal Trace

Resolve common TraceRecorder setup and capture issues when using Tracealyzer.

Check the Setup Before Capturing Again

Start with a Bare Metal 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 compiler can find the headers in TraceRecorder include. Confirm trcConfig.h is configured for your target and that any required processor header is included. Review the build output for the first error, fix that issue, then rebuild. If the error persists, verify that the TraceRecorder version and hardware port match your project.
Hardware-Port or Version Error
Check that TRC_CFG_HARDWARE_PORT is supported by your target and matches the TraceRecorder version in your project. Use the hardware-port definitions and configuration guide for that release, then clean and rebuild to avoid stale files. If the error remains, confirm the processor header and port files are included and consult the matching TraceRecorder documentation.
Trace File Is Empty
Confirm that tracing starts only after hardware setup and that xTraceEnable is called before other TraceRecorder functions. For Snapshot capture, let the application generate events before halting the target, then save the RingBuffer contents using the correct capture procedure for your development environment. Check that the chosen stream port is included and configured, and that the buffer has enough space. If it is still empty, verify the target connection and TraceRecorder configuration, then capture again.
Snapshot Stops Too Soon
If your snapshot ends before the events you need are recorded, increase TRC_CFG_STREAM_PORT_BUFFER_SIZE in trcConfig.h. A larger buffer preserves more trace history but uses more target RAM. If the buffer fills during capture, set TRC_CFG_STREAM_PORT_RINGBUFFER_MODE to TRC_CFG_STREAM_PORT_RINGBUFFER_MODE_OVERWRITE_WHEN_FULL to keep recording the latest events, or use TRC_CFG_STREAM_PORT_RINGBUFFER_MODE_STOP_WHEN_FULL to retain the earliest events. For longer or continuous captures, consider Streaming.
Streaming Data Does Not Arrive
Check that the selected stream port is included in your project and configured in trcConfig.h, and that its settings match the connection selected in Tracealyzer. Confirm the target is running, tracing has been enabled, and the debug probe or network link is connected and available. For J-Link RTT, verify the correct probe and RTT settings; for TCP/IP, check the target address and network connection. Also make sure the stream port has enough bandwidth for the trace data. If data still does not appear, restart the capture and review your stream port documentation for target specific setup details.

Enhance Your Tracing Skills

Unlock deeper insights by exploring advanced trace analysis techniques and optimize your Bare Metal 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