Trace

Trace Recording

µC/OS-III has trace points built into the code to record all the kernel events and interrupts in real-time using some of the most popular tracing tools.

Trace recording is disabled by default and can only be enabled at compile-time by setting the configuration constant OS_CFG_TRACE_EN to DEF_ENABLED in os_cfg.h.

Trace functions are defined in multiple files found under the uCOS-III\Trace\<tool> folder, where <tool> is the name of one of the trace tools supported by µC/OS-III.

Benefits

Trace recording allows you to put your µC/OS-III based application to the test. Not a functional test but a real-time performance test that can be executed with just a few kilobytes of RAM and no special hardware required other than a J-Link. Your system can be placed in the field and have all its inputs subjected to heavy load in order to cover the most realistic worst case scenarios. Meanwhile, the data is streamed to a host PC where the Third-Party Trace Analysis tool takes all the data and presents it in various views which allow you to:

  • Determine if the worst case execution times are less than the deadlines required by the application.
  • Discover potential bugs such as blocking API calls that are getting close to a timeout.
  • Capture rare, sporadic bugs which otherwise can be very hard to reproduce and analyze.
  • Verify if the tasks priority assignments are correct.
  • See how often interrupts occur.
  • Determine when tasks are being interrupted.
  • See when µC/OS-III performs task switches.
  • Determine the length of interrupts.
  • Improve the application performance.

Trace Tools

The comparison table below outlines in detail the functionality present in the third-party tracing tools supported by µC/OS-III:

Recording Modes of Operation

Both Trace Recorders; SystemView and TraceAlyzer support three modes of operation that are important to understand.

  • Streaming Mode:

Events are continuously read from buffer via J-Link and the SEGGER Real Time Transfer technology (RTT). The recorder can continuously record target execution in real time, while the target is running. This enables analysis of the system behavior over a long period of time without requiring a large target memory buffer.

  • Snapshot Mode:

When the embedded target device does not support RTT or when no J-Link is available, the recorder can still record data into its buffer until it gets full. This snapshot mode offers insight to the startup sequence or event-triggered activity in any system for a decent amount of time.

  • Post-Mortem Mode:

It is similar to the previous snapshot recording mode, with one difference: events are continuously recorded. When the embedded target buffer gets full, older events are overwritten and reading the buffer provides the latest recorded events. Post-mortem analysis can provide information of long-time system tests by helping in the analysis of system crashes.

Getting Started

Select one of the Trace Tools listed in the table above and see their respective section in this documentation: