FreeRTOS is probably the number one RTOS used, and Eclipse is likely the most popular IDE I can think of. But debugging FreeRTOS applications with Eclipse and GDB is somewhat limited? What I would like to get at the minimum is this: ability to see all the different threads in the Eclipse debug view like this:
As you might guess from that screenshot: this post is about how to make FreeRTOS tread debugging possible with Eclipse and GDB :-).
I wrote in “DIY Free Toolchain for Kinetis: Part 5 – FreeRTOS Eclipse Kernel Awareness with GDB” how to add task list and other views to Eclipse which is very useful. Still, it is not possible to switch easily between FreeRTOS threads.
Then I wrote in “FreeRTOS ARM Thread Debugging with Eclipse and GDB” how to use GDB scripts at least manually between threads. Still ok, but not very usesr friendly.
There is a better way, but as far as I know for the moment only for OpenOCD. With this I’m able to show all the FreeRTOS threads in the Eclipse debug view and can switch between them:
WhatI need is this:
- OpenOCD (e.g. with CMSIS-DAP). For using this with Segger J-Link see http://jacobjennin.gs/post/142301106015/eclipse-thread-awareness-with-freertos-and-j-link
- The correct OpenOCD settings
- and a small tweak in FreeRTOS
Download the OpenOCD (binaries, or sources if you want to build it yourself) from http://gnuarmeclipse.github.io/openocd/releases/
In this article I’m using it Kinetis Design Studio V3.2.0 () and with the “v0.10.0-20160110*-dev” version:
I have used the binary files with the installer. Then run the installer.
OpenOCD Binaries Location
The OpenOCD which comes with Kinetis Design Studio is installed in
<KDS Installation Path>\OpenOCD
Because I want to use that version of OpenOCD in parallel to the new openOCD v0.10.0, I have installed it here:
<KDS Installation Path>\openocd_0_10_0
OpenOCD Debug Configurations
There are multiple ways how to configure the path to the OpenOCD binary, see http://gnuarmeclipse.github.io/debug/openocd/ for details.
I’m using this configuration:
This is the path to the openOCD executable:
As configuration I specify the board configuration file:
In this article, I’m debugging a FreeRTOS application on a NXP FRDM-KL46Z Board with CMSIS-DAP as OpenSDA application:
In order to show the FreeRTOS tasks, I need to tell OpenOCD that I’m using an RTOS. For this I need to add
to the $_TARGETNAME configure line (see “RTOS Support” in http://openocd.org/doc/html/GDB-and-OpenOCD.html):
For the RTOS support in OpenOCD to work, the OpenOCD needs to know about RTOS symbols.
If you are getting this error message:
Error: FreeRTOS: uxTopUsedPriority is not defined, consult the OpenOCD manual for a work-around
Earlier versions of FreeRTOS had this symbol defined. So either add a helper file to your application (see https://github.com/gnuarmeclipse/openocd/tree/gnuarmeclipse-dev/contrib/rtos-helpers) or use the FreeRTOS I have released a few days ago. This release includes that symbol defined.
With this all the FreeRTOS tasks/threads are shown in the Eclipse Debug view. Clicking on the task will show the thread in the Source view:
With using OpenOCD I’m now able to do FreeRTOS thread debugging with GDB and Eclipse. I’m not very happy with the stability and speed of OpenOCD: both P&E and Segger are much faster and stable solutions. But they do not (yet?) provide that thread feature. I can switch back and forth the debugging connection, but long-term this is kind of painful. So I hope that professional debug solutions would pick that feature up to make me and many others happy :-).
- Using RTOS support in OpenOCD: http://electronics.stackexchange.com/questions/112931/using-rtos-support-in-openocd
- GNU ARM Eclipse OpenOCD releases: http://gnuarmeclipse.github.io/openocd/releases/
- OpenOCD FreeRTOS Helper: https://github.com/gnuarmeclipse/openocd/tree/gnuarmeclipse-dev/contrib/rtos-helpers
- OpenOCD Debugging with GNU ARM Eclipse: http://gnuarmeclipse.github.io/debug/openocd/
- OpenOCD FreeRTOS Tread debugging with J-Link and OpenOCD: http://jacobjennin.gs/post/142301106015/eclipse-thread-awareness-with-freertos-and-j-link
- NXP Kinetis Design Studio: http://www.nxp.com/kds
- RTOS Support in OpenOCD: http://openocd.org/doc/html/GDB-and-OpenOCD.html