Adding FreeRTOS Thread Awareness to GDB and Eclipse
This article describes the steps how to use it with the NXP Kinetis Design Studio (V3.2.0) with the GNU ARM Eclipse plugins.
Join the DZone community and get the full member experience.
Join For FreeSegger has released a beta version of the J-Link software which includes their GDB thread awareness for embOS and FreeRTOS.
Outline
I had a first chance to try this plugin at NXP FTF 2016 in Austin (see "FreeRTOS Thread Debugging with Segger GDB in Eclipse"). Now that feature is included in the latest Segger beta download.
This article describes the steps how to use it with the NXP Kinetis Design Studio (V3.2.0) with the GNU ARM Eclipse plugins. Similar steps can apply for other Eclipse distributions with GDB. A similar feature is present in OpenOCD (see "FreeRTOS Thread Debugging with Eclipse and OpenOCD").
Note: there seems to be some problems with the GNU compiler used, not sure why (yet?)?
Installation
Download the latest Segger J-Link software version from the Segger site. Currently, it is available on the beta site (V5.41h). Then run the setup. A dialog will ask to update existing IDE’s using Segger J-Link software on Windows:
For Mac OS X and Linux you have to copy the necessary files from the installation folder. The RTOS thread awareness is using DLLs/libraries from the ‘GDBServer’ subfolder.
In the beta installer, that GDBServer folder is not copied into Kinetis Design Studio (subfolder ‘segger’ inside KDS). I recommend to manually copy that folder into the ‘segger’ subfolder of KDS:
Using the FreeRTOS Plugin
To use the FreeRTOS plugin, specify which RTOS plugin to load with:
-rtos GDBServer/RTOSPlugin_FreeRTOS
The path is relative to the Segger GDB server. If you have located the plugins elsewhere, you have to adopt the path.
Below shows the command in the debug launch configuration for GDB and Segger using the GNU ARM Eclipse plugin:
With this, it shows the RTOS threads in the GDB debug view under Eclipse while debugging:
Troubleshooting
The implementation checks and accesses several symbols of FreeRTOS, for example:
Received symbol: pxCurrentTCB (20003A7C)
Received symbol: pxReadyTasksLists (20003A80)
Received symbol: xDelayedTaskList1 (20003AF8)
Received symbol: xDelayedTaskList2 (20003B0C)
Received symbol: pxDelayedTaskList (20003B20)
Received symbol: pxOverflowDelayedTaskList (20003B24)
Received symbol: xPendingReadyList (20003B28)
Received symbol: xTasksWaitingTermination (00000000)
Received symbol: xSuspendedTaskList (20003B3C)
Received symbol: uxCurrentNumberOfTasks (20003B50)
Received symbol: uxTopUsedPriority (2000002C)
Received symbol: vPortEnableVFP (0000FE24)
I had faced a problem where at high compiler optimization level the function vPortEnableVFP() was inlined. I have fixed that in my FreeRTOS port with a noinline attribute so it works with highest optimization too:
void __attribute__ ((noinline)) vPortEnableVFP(void) {
Summary
The Segger RTOS plugin provides a very convenient way to debug FreeRTOS (or Segger emBOS) threads with Eclipse and GDB using a Segger J-Link debug probe. A native J-Link or an embedded J-Link probe like OpenSDA on the NXP Freedom boards. It greatly simplifies the debug experience, and after using it I don’t know how I was able to debug RTOS applications before.
Happy Threading!
Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments