i am trying to integrate OpenOCD and GDB with VS-Code in order to debug a raspberry pi pico, with the official pico debug probe. I roughly followed Shawn Hymels tutorial in youtube.
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Pico Debug",
"cwd": "${workspaceRoot}",
"executable": "${command:cmake.launchTargetPath}",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
// This may need to be "arm-none-eabi-gdb" or "gdb-multiarch" for some previous builds
"gdbPath" : "gdb-multiarch",
"device": "RP2040",
"configFiles": [
// This may need to be "interface/picoprobe.cfg" for some previous builds
"interface/cmsis-dap.cfg",
"target/rp2040.cfg"
],
"svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd",
"runToEntryPoint": "main",
// Work around for stopping at main on restart
"postRestartCommands": [
"break main",
"continue"
],
"openOCDLaunchCommands": ["adapter speed 5000"],
}
] }
settings.json:
{
// These settings tweaks to the cmake plugin will ensure
// that you debug using cortex-debug instead of trying to launch
// a Pico binary on the host
"cmake.statusbar.advanced": {
"debug": {
"visibility": "hidden"
},
"launch": {
"visibility": "hidden"
},
"build": {
"visibility": "default"
},
"buildTarget": {
"visibility": "hidden"
}
},
"cmake.buildBeforeRun": true,
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
}
The build of my project works fine, but when I want to start debugging, I get the following error:
OpenOCD: GDB Server Quit unexpectedly Failed to launch OpenOCD GDB Server: Error: spawn /usr/local/bin EACCES
When I run OpenOCD from a terminal like so, everything works just fine:
sudo openocd -f interface/cmsis-dap.cfg -f target/rp2040.cfg -c "adpater speed 5000" -c "program blink.elf verify reset exit"
Note that I require the "sudo". Could it be that VS-Code is missing the permissions to run OpenOCD or GDB? Or is there some other kind of error?
I guess you are working on some kind of Linux. Then i think the answer you are looking for is (for instance) here:
https://elinux.org/Accessing_Devices_without_Sudo
Basically you (and the OpenOcd started by the VSCode started by you) do not have the rights to access the USB device you are using for debugging. The article describes what to do against this.