Debugging - oeps in VisualStudioCode
This page was last updated : 01-Feb-21 10:00:07
One of the things I was very curious about was the possibility to do some real in-circuit debugging in combination with Visual Studio Code.
Raspberry Pi - VisualStudioCode - Compiling ok, but no debugging . . .
After setting up my Raspberry PI as a development environment, I found out that the VisualStudioCode IDE compiled the code without a problem, but debugging gave a error.
"OpenOCD GDB executable "arm-none-eabi-gdb" was not found. Please configure "cortex-debug.armToolchainPath" correctly."
The reason for this error is that the parameter cortex-debug.* doesn't exist in format for launch.json and should be set in settings.json
This can be fixed by editing the file /home/<youruser>/pico/pico-examples/.vscode/launch.json
"gdbpath" : "gdb-multiarch",
Comment out the line like this :
// "gdbpath" : "gdb-multiarch",
Now you edit the file /home/<youruser>/pico/pico-examples/.vscode/settings.json and add the cortex-debug.armToolchainPath parameter by :
"cortex-debug.gdbPath": "gdb-multiarch",
Then I could debug.
Link to zip containing my launch.json and settings.json files hope it helps you.
Debugging on your Linux laptop
I already had my Linux laptop setup based on the Getting started with Raspberry Pi Pico PDF file and commandline build stuff was working. Debugging a Pi Pico on your linux laptop is (i believe, correct me if i'm wrong) only possible by using another Pi Pico loaded with the PicoProbe program. This will turn you Pi Pico into a ISP / debugger to program and debug a target Pi Pico (see : Appendix A: Using PicoProbe in the Getting started with Raspberry Pi Pico PDF file ).
Following the instructions I programmed a Pi Pico with the PicoProbe software and hooked up a other Pi Pico as the debug target (now you know why I ordered 5 of them). And after a little playing around I got debugging working by commandline (small steps).
To start openocb I use a shell script in my ~/bin directory called openocd_picoprobe containing the following lines :
cd ~/pico/openocd/
sudo src/openocd -f interface/picoprobe.cfg -f target/rp2040.cfg -s tcl
That way I only have to execute that shell script when I want to debug my Pi Pico using the openocd on my linux laptop.
Linux laptop - VisualStudioCode - Again compiling ok, but no debugging . . .
I already had my Linux laptop setup based on the Getting started with Raspberry Pi Pico PDF file and commandline build stuff and debugging was working. For debugging your Raspberry Pi PICO you need a PicoProbe which is just a Pi Pico with a special program in it which allows it to use it as a ISP / debugger with a other Pi Pico (see : Appendix A: Using Picoprobe ).
Just like the VisualStudioCode IDE on my Raspberry Pi 3B+ it compiled the code without a problem, but debugging gave the same error.
"OpenOCD GDB executable "arm-none-eabi-gdb" was not found. Please configure "cortex-debug.armToolchainPath" correctly."
The reason for this error is that the parameter cortex-debug.* doesn't exist in format for launch.json and should be set in settings.json
This can be fixed by editing the file /home/<youruser>/pico/pico-examples/.vscode/launch.json
"gdbpath" : "gdb-multiarch",
Comment out the line like this :
// "gdbpath" : "gdb-multiarch",
And change the line :
"gdbTarget": "your-openocd:3333",
into this (when you run openocd localhost on port 3333) :
"gdbTarget": "localhost:3333",
Now you edit the file /home/<youruser>/pico/pico-examples/.vscode/settings.json and add the cortex-debug.armToolchainPath parameter by :
"cortex-debug.gdbPath": "gdb-multiarch",
Using a modified hello_serial.c I check if everything works.
When hitting the breakpoint, the led stopt blinking staying in the on state and the output in my terminal window running minicom stopped.
So Debug with Visual Studio Code on my Linux laptop also working .
Link to zip containing my launch.json and settings.json files of my laptop using localhost openocd on port 3333 hope it helps you.
Previous page: Where to start . .
Next page: My PicoProbe