Trace tutorial
Getting started with J-Trace PRO is easy. With the Ozone J-Trace tutorial project, developers can test J-Trace PRO’s streaming and live analysis capabilities… No complex configuration meaning you can get things up and running within 15 minutes.
The Ozone J-Trace PRO Tutorial serves as a starting point for you to test J-Trace PRO’s streaming trace and live analysis capabilities. It demonstrates how you can get the most advanced analysis of your system within 15 minutes.
The Tutorial Project starts with a simple application running on the target hardware, demonstrating the trace features without any special code or configuration. More advanced examples, including system init and the use of embOS are part of the project too, and can be analyzed with J-Trace PRO as well. It includes the pre-built applications, the Ozone projects, and an Embedded Studio project to modify and re-build the application.
Which Target Hardware to Use?
This tutorial project can be used with SEGGER Reference Boards. This particular Tutorial Walkthrough was written with the Cortex-M Trace Reference Board in mind.
Note: Want to get started with tracing on your own hardware? If so, then make sure to check out Tested Devices for tracing with J-Trace PRO for more information. Additional information can be found on the J-Trace PRO - Setting up Trace page.
Trace Tutorial Walkthrough
1. Download the Tutorial Project and make sure the J-Link Software and the latest Ozone are installed.
2. Extract the project into any destination directory on your computer.
3. Connect the J-Trace PRO with your computer and the target board, and power the board.
4. Open SEGGER_CortexM_Trace_Reference_Board.jdebug from the project directory with Ozone.
5. Open the Code Profile Window and the Instruction Trace Window. (View → Code Profile and View → Instruction Trace)
6. Set a breakpoint at BSP_Init; in main() in OS_TraceDemo.c.
7. Start the debug session (Debug → Start Debug Session → Download and Reset program). Ozone starts and loads the pre-built executable for your Cortex-M Trace Reference Board. The application is loaded into your Cortex-M Trace Reference Board, it starts and runs to main.
8. Continue to run to your breakpoint (Debug → Continue). Ozone breaks after returning from OS_InitHW().
The Instruction Trace Window shows what has been executed up to this point. The most recent instructions are at the bottom. Instructions are grouped by source line and corresponding function. Collapsing all blocks shows the functions that have been called and to which functions the application has returned. To collapse all blocks, right-click on "Instruction Trace" and click on "Collapse all".
When all blocks are expanded, you can navigate through the instructions to follow the execution in the Source Viewer and Disassembly Window and see what has exactly happened from the start at main until the breakpoint was hit. To expand all blocks, right-click on "Instruction Trace" and click on "Expand all".
9. Continue the execution again (Debug → Continue).
The application is running, and the LEDs are blinking. The source lines in the Source Viewer can be expanded to show which instructions each source line generated.
The left column of the Source Viewer shows code coverage levels. Each line of code is marked as either fully executed (yellow), partially executed (orange), or not executed (gray).
10. Show Code Profile counters in Source Viewer (right-click on Source Viewer → Execution Counters)
In addition to the code coverage marker, the left column can display the number of source lines and instructions executed. The counters are updated live from the trace stream while the application is running. Hover the mouse over a counter to get the fetch and not-executed counts, as well as the CPU load of that line in a tooltip.
11. Code Profile Window (View → Code Profile)
The Code Profile Window displays the code coverage and profiling information by function. It allows sorting by load or coverage and filtering functions to not count them in the load statistics. In the example screenshot below, OS_Idle() is deselected from the load calculation, as the application spends over 99% of its time in that function.
12. Export trace data into a report (right-click in Code Profile Window → Export...)
The information from the Code Profile Window can be exported into a report with different formatting, which can be used for verification processes.
To alter the project, open J-Trace_PRO_CortexM_Tutorial.emProject with Embedded Studio.
Modifications should be done to the Application project. You can change OS_TraceDemo.c or add your own application file.
When all changes are done, recompile the project (Build → Build Solution), which creates the application for the reference board. If the Ozone project is still opened, it will prompt to reload the application file, which has just changed. If Ozone is not started, start it and load SEGGER_CortexM_Trace_Reference_Board.jdebug.