Small (RTT) targets quick-start¶
Tracing quick-start for targets with constrained resources that support RTT
transfer over J-Link (i.e. armv7m7-imxrt117x).
Warning
Currently, only single-core targets are supported. It can be fairly easily
extended to multi-core if you expose additional buffers in
plo/devices/pipe-rtt/rtt.c.
Objectives¶
Ensure RTT tracing back-end is correctly set up on your target
Record a trace on your target and gather it on host over RTT
Pass the directory to
convert.shto get a single file readable by Perfetto Trace ViewerOpen the trace file in the Perfetto GUI
Prerequisites¶
Aside from Common prerequisites, you need:
A working RTT transfer on your target (
.rttmap, ID 2 and ID 3 TX channels of at least 1024 B and similar channels for subsequent IDs if your target is multi-core)
Step 1: ensure RTT tracing back-end is set up correctly¶
In the board_config.h for your target, ensure the following options are set:
#define RTT_ENABLED 1
#define RTT_ENABLED_PLO 1
#define PERF_RTT_ENABLED 1
#define RTT_PERF_BUFFERS 1
Step 2: record the trace and gather it on host over RTT¶
On host, run collect_rtt_trace.py from phoenix-rtos-hostutils/trace with a
path to your OpenOCD config, say $MY_OCD_CONFIG, and a destination folder, say
$TRACE_DIR:
cd $PRTOS_PROJECT/phoenix-rtos-hostutils/trace ./collect_rtt_trace.py $MY_OCD_CONFIG $TRACE_DIR
A successful invocation:
./collect_rtt_trace.py ../../evkb_common/ocd/imxrt_wip.cfg output
Now, start the trace on your target. You can use libtrace library from
phoenix-rtos-corelibs or use psh applet perf:
perf
The minimal invocation is:
perf -m trace
This starts a trace for 3 seconds and emits it over RTT.
A successful invocation:
perf -m trace
While the trace is gathering, the log from collect_rtt_trace.py should display
the current transfer rate and the amount of data read so far:
Rate: 29.89 KB/s
channel_meta0: 2.45 KB
channel_event0: 91.19 KB
Once the trace is finished, terminate collect_rtt_trace.py with ^C (SIGINT).
Note
If you notice something like:
kernel (perf_traceFinish:312): event delay detected 2 times - event receiver couldn't keep up
kernel (perf_traceFinish:313): start ts=913491309 delay ts=915280482 stop ts=916571720
This means the RTT receiver couldn’t keep up with the rate of event emission. The events were still captured, but the kernel was unable to put the events into the RTT buffer immediately and it had to actively wait. This may be a concern to you or not, depending on how many times the delay has occurred and how long it was. Usually delays are caught when the rate of event emission drastically changes. This is still being investigated.
Step 3: invoke convert.sh¶
Once you have your trace on host in a folder, say $TRACE_DIR, you can now invoke:
cd $PRTOS_PROJECT/phoenix-rtos-hostutils/trace ./convert.sh $TRACE_DIR $PRTOS_PROJECT/phoenix-rtos-kernel/perf/tsdl/metadata out.pftrace
The resulting out.pftrace is ready to be opened in Perfetto.