TraceUtil

From Texas Instruments Embedded Processors Wiki

Jump to: navigation, search
Translate this page to   

END OF LIFE

Note that TraceUtils is no longer recommended. This article remains for existing users.

Contents

Introduction

TraceUtil is an ARM-side module that simplifies using Codec Engine's complex tracing features. It lets the user, at build time and/or run time, say what trace levels they want and where they want the trace collected. At run-time, user can turn on or off tracing features by writing command strings to a named Unix pipe.

Use TraceUtil for debugging, to collect real-time data, or both.

Note: TraceUtil is not supported in Codec Engine 3.x.

Features

TraceUtil takes care of three kinds of tracing that Codec Engine modules can produce:

TraceUtil lets you specify what tracing features you want when you build your application, and lets you override some of all of those specs via Linux shell environment variables when you run the application.

Configuring TraceUtil for use at build time

To use TraceUtil, when you build your application you must have this line added to your application's configuration (.cfg) script (anywhere in the script is fine):

var TraceUtil = xdc.useModule('ti.sdo.ce.utils.trace.TraceUtil');

If you don't do anything else, this will configure TraceUtil to:

You can modify the default behavior by assigning the TraceUtil.attrs field. For complete details, please see the reference documentation for the "ti.sdo.ce.utils.trace.TraceUtil" module.

A commonly used .attrs assignment is the DVT/SoCrates profile:

TraceUtil.attrs = TraceUtil.SOCRATES_TRACING;

With this profile, the GPP and DSP enable "SoCrates tracing", which includes BIOS logging. GPP trace is stored in /tmp/cearmlog.txt file, DSP trace in /tmp/cedsp0log.txt, and BIOS logging in /tmp/bioslog.dat. The polling rate is also pre-defined. However: the application begins to run without tracing enabled. To turn tracing on, the user -- or a program -- must write the "turn trace on" command to the trace command pipe.

Another profile is the 'full tracing' profile:

TraceUtil.attrs = TraceUtil.FULL_TRACING;

The output destinations are the same as for SOCRATES_TRACING, but it enables all levels of trace for both the GPP and the DSP.

Supporting TraceUtil in your app's C code

To collect the trace that the DSP silently produces, you have to add these lines of C code to your Arm application:

#include <ti/sdo/ce/utils/trace/TraceUtil.h>
/* ... */
TraceUtil_start(engineName); /* engineName is a string; call after CERuntime_init */
/* ... */
TraceUtil_stop();           /* call at the end of your app */

This code spawns a (p)thread that every 200ms (by default) collects all available DSP trace and dumps it to a file or standard output. (It also collects and stores DSP BIOS log if you wanted it so.)

Configuring TraceUtil for use at application start time

Before you run your TraceUtil-powered application, if you set one or more environment variables below, you will change TraceUtil properties that you specified in your .cfg script:

CE_TRACE                - trace mask for the Arm side, e.g. CE_TRACE="*=0567;OM-0"
CE_TRACEFILE            - output file for Arm trace, e.g. CE_TRACE="trace/armtrace.txt"; if
                          it can't be opened (e.g. points to a directory that doesn't exist)
                          the trace will go to the standard output. (Try CE_TRACEFILE=/ for that.)
CE_TRACEFILEFLAGS       - file creation flags for all files to be opened, e.g. CE_TRACEFILEFLAGS="a"
                          (meaning "append"), or "w" (write); these are standard fopen() flags
TRACEUTIL_DSP0TRACEFILE - output file for the DSP trace; same remark holds as for the Arm trace
TRACEUTIL_DSP0BIOSFILE  - output binary file for the BIOS log; if can't be open, will not be collected
TRACEUTIL_DSP0TRACEMASK - trace mask for the DSP side, e.g. TRACEUTIL_DSP0TRACEMASK="*+01;ti.bios=01234567"
TRACEUTIL_REFRESHPERIOD - number of milliseconds before the Arm thread collects all available DSP trace
                          since the last time it did it
TRACEUTIL_CMDPIPE       - name of a Unix named pipe ("fifo") where the TraceUtil listens for run-time
                          trace commands
TRACEUTIL_VERBOSE       - when set to 1 makes TraceUtil print the what trace settings (masks, files) 
                          it uses and where it gets them from. When set to 2 and up it shows more 
                          debugging info.
                          You almost always want TRACEUTIL_VERBOSE=1 set.

If you use bash shell on Linux, it is especially convenient to set environment variables in the same line where you start your application, so they apply to that execution of the application only:

CE_TRACE="*+5" CE_TRACEFILE="mylog" TRACEUTIL_VERBOSE=1 ./app.out

Note These environment variables are read once, at application startup time. Changing them after the application is executing will not have any effect: when the application runs, the application process gets its own copy of environment variables (changing them in the shell process does not affect the application process), and the application reads its copy of environment variables only when it initializes.

Controlling trace at app execution time through a named pipe

If the TRACEUTIL_CMDPIPE variable is set to a valid name, or TraceUtil.attrs.cmdPipeFile build-time option is set (as it is for TraceUtil.SOCRATES_TRACING profile), the TraceUtil thread listens for any tracing commands that appear in the pipe.

Valid trace pipe commands

Below is the list of supported trace pipe commands. Note that only one command per line should be written to the trace pipe.

As with socrates=on, the Arm application integrator can define, in his application config script, command pipe aliases that issue several pipe commands, as in this example:

var TraceUtil = xdc.useModule('ti.sdo.ce.utils.trace.TraceUtil');
TraceUtil.attrs.cmdAliases = [ 
    {
        alias: "mycommands_1",
        cmds:  [ 
               "resetfiles",
               "tracemask=*+5", 
               "dsp0tracemask=*+5,ti.bios+3",
               "refreshperiod=200",
        ],
    },
    { 
        alias: "mycommands_2",
        cmds:  [ 
               "tracemask=*-5", 
               "refreshperiod=0",
               "dsp0tracemask=*-5,ti.bios-3" 
        ],
    },
    /* and so on -- no limit on the number of aliases */
];

A note on configuring the DSP server for BIOS logging

If you set TraceUtil on the Arm side to use BIOS logging, you must have BIOS logging enabled in your DSP server image. That you do by adding this one line to your DSP server's configuration script:

var LogServer = xdc.useModule('ti.sdo.ce.bioslog.LogServer');

If your DSP server is incapable of BIOS logging, you will see Arm-side error/warning messages like,

LogClient_connect> Error: failed to locate server queue, Check if your DSP image has BIOS logging enabled

and

LogClient_fwriteLogs> Warning: not connected to the BIOS log server on the DSP, cannot collect any BIOS log data.
Leave a Comment
Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox