Early in my career it always bothered me that I couldn’t see how my program was executing. I would write some software, cross my fingers, and assume the application worked because the LED seemed to be blinking with the correct timing. In reality, once the run button was pressed, who knows if the application executed along the paths the way I thought they should. Verifying the application ran correctly required extraordinary effort.
Developers have not had to guess or hope for several years now. Modern microcontrollers have had the hardware built in and the debugging technology available for the past several years to
- to visualize and see the program execution path;
- monitor the exact instructions that are executed by the processor;
- record events occurring in the application such as context switches;
- track the program counter and stack pointer.
Tracing has provided developers with new insights, debugging, and verification capabilities that have the potential to dramatically change the way embedded software is developed. Here are seven tips for getting started with embedded application tracing.
Tip #1 – Purchase a High-End Debugger Probe
The tools required to do basic tracing don’t need to cost an arm and a leg. Tracing can be performed using low-cost debuggers but I have generally found that it requires more time and effort to get it up and running. Trade-offs need to be performed to get some data out. Low-cost debuggers tend to be slower and have smaller buffers, which means it may not be possible to download all the data fast enough.
Now this may sound like I’m advocating purchasing expensive tools but I have noticed that when I tried to go cheap, it costs me far more in time and effort than if I had just bit the bullet and purchased the professional tool. For example, when I started playing around with tracing, I used a debugger I had gotten for maybe $100 but spent days tweaking the target library buffers and code so that I could get a clean trace from it. Fast forward to when I invested in my J-Link Ultra Plus -- the adjustments to get tracing up and running were minor, I didn’t have to down select the data I wanted, and suddenly I had a third-party tool that worked with nearly any IDE so I don’t have to keep buying low-cost debuggers for every new microcontroller I work with.
Tip #2 – Download System Viewer and Tracealyzer
There are different tools that can be used to record trace data and then view that data, but the two tools that I like and have been using the most is Segger’s System Viewer and Percepio’s tracealyzer. These tools are very powerful and provide a wide range of trace functionality. System Viewer is free while Tracealyzer has a 30-day trial and a fee associated with it.
Tip #3 – Create a Simple Test Application
I wouldn’t recommend a developers’ first trace being with a full-fledged production intent application. These applications can be complicated, fast, event-heavy, and confusing. We don’t want to be overwhelmed