Hint: PlatformIO/Segger JLink RTOS Task Debugging

It was not obvious to me at first, but the underlying PlatformIO runtime that WisBlock uses is using a version of FreeRtos. The runtime main() creates, I think it is four separate tasks (think like threads in the desktop world)

  • rtos required idle thread, runs when nothing else does
  • a USB handler thread, not sure what all it does
  • a callback handler thread
  • our standard user loop() thread that we are used to with bare metal apps.

When specifying JTLink as the debug_tool in platformio.ini, PIO will install and use JLink’s version of a GDB server (JLinkGDBServer on Linux) as the process the PIO GUI connects to in order to communication with your board.

By default the JLinkGDBServer is “not” configured with RTOS support, thus if when you hit a break point within the PIO Debug Console you enter

> info threads

you will only see the currently executing task. If you want to see all tasks we must update the configuration arguments used when JLinkGDBServer is launched from within PIO.

On Linux. for WisBlock support, this is done in ~/.platformio/platforms/nordicnrf52/platform.py. (it should be a similar location in Mac and Windows once you locate the PIO installation directory.)

In this file, within the function:

_add_default_debug_tools(self, board):

In the section defining arguments for server/package “tool-jlink” add the following line to the list of arguments:

“-rtos”, “GDBServer/RTOSPlugin_FreeRT

the results should look something like:

debug[“tools”][link] = {
“server”: {
“package”: “tool-jlink”,
“arguments”: [
“-rtos”, “GDBServer/RTOSPlugin_FreeRTOS”,
“-if”, “SWD”,
“-select”, “USB”,
“-device”, debug.get(“jlink_device”),
“-port”, “2331”
“executable”: (“JLinkGDBServerCL.exe”
if platform.system() == “Windows” else

Now when you start a debug session and hit a break point you should be able to see the active tasks by executing within the PIO Debug Console

> info threads

I’m sure there is much more RTOS debugging functionality to be explored but this is as far as I’ve taken it at this point.

I do not know if this RTOS functionality is available within STLink/OpenOcd debug configurations or not. I think I toasted my STLink device before I got to this.

FYI: This thread details a JLink debugger startup issue that you may encounter within PlatformIO.

And if you compile with


when using Platformio you can, with a Segger JLink debug tool, run Seggers SystemViewer UI tool to do some analysis of your running tasks.
The default PIO framework runtime as detailed in the quick start guide for WisBlock has the necessary code changes in place to support SystemViewer, you should only need to add the -D define mentioned above, rebuild your app and your ready to go from the device side.

You will of course need to download the Segger SystemViewer tool. You should not need to do any code modifications to your device app as mentioned within the Segger docs, those changes should all be in place in the framework files, would not hurt to verify though.

If that flag does not do it, check the

(where xxx is your target PIO framework)

runtime startup main() function for the exact flag to enable


Segger SystemViewer