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
OS”,
the results should look something like:
debug[“tools”][link] = {
“server”: {
“package”: “tool-jlink”,
“arguments”: [
“-singlerun”,
“-rtos”, “GDBServer/RTOSPlugin_FreeRTOS”,
“-if”, “SWD”,
“-select”, “USB”,
“-device”, debug.get(“jlink_device”),
“-port”, “2331”
],
“executable”: (“JLinkGDBServerCL.exe”
if platform.system() == “Windows” else
“JLinkGDBServer”)
}
}
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.