Debugging Azure RTOS applications using TraceX

cancel
Showing results for 
Search instead for 
Did you mean: 

Debugging Azure RTOS applications using TraceX

100% helpful (1/1)

Debugging Azure RTOS applications using TraceX

1  TraceX Introduction

Azure RTOS TraceX is Microsoft’s host-based analysis tool that provides developers with a graphical view of real-time system events and enables them to visualize and better understand the behavior of their real-time systems. With Azure RTOS TraceX, developers can se clearly the occurrence of system events like interrupts and context switches that occur out of view of standard debugging tools.

 

This article explains how to start the traceX debug with MCUXpresso SDK

Hardware: MIMXRT1060-EVK & 1 Micro-USB cable

Software: SDK_2_10_1_EVK-MIMXRT1060

 

2 Installing TraceX

 

You can obtain the TraceX app from the Microsoft App Store by searching for TraceX, or by going directly to the TraceX page. Then install the TraceX according to the pop up manuals.

 

3 Enabling Trace Inside the application

3.1 Add required preprocessor symbols

Trace-dependent code is activated using TX_ENABLE_EVENT_TRACE define. It must be added in the preprocessor section of the compiler. This must be done for the application itself and for the linked libraries. (e.g. ThreadX library)

danielchen_0-1635607576958.png

 

 

danielchen_1-1635607617234.png

 

 

3.2 Declare the trace buffer

A buffer area for storing the trace events occurring at run-time must be specified and then further instruct the ThreadX trace sub-system to use it. Buffer can be a global variable, just like in the example below:

 /*Trace buffer*/

#ifdef TX_ENABLE_EVENT_TRACE

UCHAR trace_buffer[64000];

#endif

danielchen_2-1635607713977.png

 

 

3.3 Enable trace

Trace must be explicitly enabled inside the application by calling tx_trace_enable(). This can be achieved by adding the below code.

 #ifdef TX_ENABLE_EVENT_TRACE

/*

* Enable event tracing using the global “trace buffer”.

* Allow a maximum of 30 ThreadX objects in the registery.

*/

 

UINT status =  tx_trace_enable(&trace_buffer, sizeof(trace_buffer), 30);

if (status != TX_SUCCESS)

{

    for (; ; ) { }

}

#endif

 

It is recommended to enable trace inside tx_application_define( ).

danielchen_3-1635607824972.png

 

3.4 compile

Compile the ThreadX lib (the compiled library will be in the Debug folder).

After successful build and compilation, a new library appears in the Debug / Release directory. It has a name like libevkimixrt1060_threadx_lib.a.

Please rename it to libthreadx.a and copy it to the directory, azure-rtos/binary/treadx/mcux/, in the evkmimxrt1060_threadx_demo project to replace the original one.

 

Replace the libthreadx.a files in the threadx_demo project

 

danielchen_4-1635607872961.png

 

danielchen_5-1635607897187.png

 

 

4 Exporting Trace

4.1 Configuration of Trace Export feature

 

Trace Export feature is controlled by a list of preferences that can be accessed and further modified via window->Preference page.

danielchen_6-1635607940151.png

 

4.2 Trace Export button

Pause your application and the Trace Export button is located in the Debug view’s toolbar, as illustrated in the screenshot below.

danielchen_7-1635607976058.png

 

 

4.3 Exporting Trace

Once the Trace Expert button is clicked, a modal dialog window will be presented.  A file path must be specified and then click the Export button. The exported file can be imported in Azure RTOS TraceX tool afterwards.

 

danielchen_8-1635608025717.png

 

 

5 Display with Azure RTOS TraceX tool

From Azure RTOS TraceX, we can open the imported file.

System summary line contains a summary of the context as well as the corresponding event summary underneath.

 

danielchen_9-1635608071567.png

 

Azure RTOS TraceX provides a built-in execution profile for all executed contexs

 

danielchen_10-1635608107172.png

 

 

Azure RTOS TraceX provides a build in performance statistics report for the currently loaded trace file

danielchen_11-1635608148485.png

 

 

 

Reference doc:

https://docs.microsoft.com/en-us/azure/rtos/

 

 

 

Version history
Revision #:
1 of 1
Last update:
‎10-30-2021 08:37 AM
Updated by: