Debugging with JLink on Eclipse I: FreeRTOS thread awareness

I've been using Eclipse with Segger's JLink for a while now to write my FreeRTOS applications. It's all good, until you want to check the state of threads. When you pause execution in debug mode, what you'll see most likely is idle thread. Because that's what embedded systems do for most of the time - they idle. Often when some task dies or hangs, everything else is still working. At least idle task is working. Unless the system experiences hardfault.

So I finally decided to improve my debugging facilities to obtain at least some info on the state of the system. I'll document my findings as I figure things out. This one will be about threads.

I'm definitely not the first person to want to do that. A brief search revealed a nice source of info: DZone, as usual. Most of the info sources deal with specific manufacturer ICs, but I wanted something more general. But DZone article at least taught me the keywords what to search for. Which led me to this article on MCUonEclipse. It deals with NXP Design Studio, but under the hood it's good old Eclipse. All we need from there is:
 -rtos GDBServer/RTOSPlugin_FreeRTOS
Which we have to add to "Other options" in our JLink debug configuration. And voila:

This is JLinkGDBServer specific, for OpenOCD there are other solutions out there.
Thread numbering is somewhat weird, but it's ok for now. For each thread debugger is able to show state, priority and load variables. Great success!

Next we should figure out tracing stacks and heaps. Basically, memory status

No comments:

Post a comment