Skip to content

Viewing threads in openocd

Matthew McGowan edited this page Sep 14, 2015 · 1 revision

When debugging the photon/electron, it's useful to see all threads that are executing, and not just the current thread.

Configure Your Code for Thread Views

To make the thread detection in OpenOCD work, the code should export a uxTopUsedPriority symbol. This used to be present in FreeRTOS, but has since been removed. This is needed so OpenOCD can display the threads running.

We've already added this to the Photon/Electron codebases, so if you're debugging those then no need to add this:

#include "FreeRTOS.h"
const int  __attribute__((used)) uxTopUsedPriority = configMAX_PRIORITIES;

(info sourced from http://openocd.zylin.com/#/c/2347/4/contrib/rtos-helpers/FreeRTOS-openocd.c)

Launch openocd

openocd -f interface/ftdi/particle-ftdi.cfg -f target/stm32f2x.cfg -c "stm32f2x.cpu configure -rtos auto" 

Then connect with your IDE's arm-none-eabi-gdb client and you should see a list of threads in the debugger!

Clone this wiki locally