Marus / cortex-debug

Visual Studio Code extension for enhancing debug capabilities for Cortex-M Microcontrollers
MIT License
1k stars 238 forks source link

Failed to launch OpenOCD GDB Server: Error: spawn /usr/local/bin EACCES #650

Closed VBruceHunt closed 2 years ago

VBruceHunt commented 2 years ago

Issue Type: Bug

1. Environment:

  1. Raspberry Pi 4 up-to-date Raspberry Pi OS with development essentials package installed.
  2. installed Raspberry Pi Pico SDK for C/C++
  3. installed Raspberry Pi version of OpenOCD
  4. installed Raspberry Pi Picoprobe.
  5. Pi 4 connected via USB to Pico with Picoprobe software loaded.
  6. Picoprobe connected to target Raspberry Pi Pico via SWD interface
  7. Target Application compiled on Pi4 using GCC 8.3.1 arm-none-eabi using VScode IDE 1.66.2
  8. VScode click on "Run and Debug" icon.
  9. Click on Pico Debug to start up and debug the application.
  10. Summary: Compiled and ran debugger many times up until mid April developing myproject. I am fairly new at using vscode so I've worked to isolate the problem to VScode as the following shows. I can run each of the individual steps ( gdb-multiarch and openocd ) so the components work fine manually using the (displayed) parameters that VScode used according to the DEBUG CONSOLE.

2.The following shows the suspected error output:

VSCode Debug Console Output:

Reading symbols from objdump-multiarch --syms -C -h -w /home/myself/projects/myproject/build/pico-sdk/src/rp2_common/boot_stage2/bs2_default.elf Reading symbols from nm-multiarch --defined-only -S -l -C -p /home/myself/projects/myproject/build/pico-sdk/src/rp2_common/boot_stage2/bs2_default.elf Launching GDB: gdb-multiarch -q --interpreter=mi2 /home/myself/projects/myproject/build/pico-sdk/src/rp2_common/boot_stage2/bs2_default.elf 1-gdb-set target-async on Launching gdb-server: /usr/local/bin -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s ~/pico/openocd/tcl -f /home/myself/.vscode/extensions/marus25.cortex-debug-1.4.4/support/openocd-helpers.tcl -f interface/picoprobe.cfg -f target/rp2040.cfg Please check TERMINAL tab (gdb-server) for output from /usr/local/bin Finished reading symbols from objdump: Time: 257 ms Finished reading symbols from nm: Time: 238 ms Failed to launch OpenOCD GDB Server: Error: spawn /usr/local/bin EACCES ----------------------------------------------------------End -------------------------------------

VSCode Terminal Output::

[2022-05-10T23:58:00.145Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session connected. You can switch to "DEBUG CONSOLE" to see GDB interactions. /usr/local/bin -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s ~/pico/openocd/tcl -f /home/myself/.vscode/extensions/marus25.cortex-debug-1.4.4/support/openocd-helpers.tcl -f interface/picoprobe.cfg -f target/rp2040.cfg [2022-05-10T23:58:01.216Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session closed GDB server session ended. This terminal will be reused, waiting for next session to start... ----------------------------------------------------End -------------------------------------------

The file in ~/projects/myproject/.vscode/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 depending on your system "gdbPath" : "gdb-multiarch", // was arm-none-eabi-gdb "device": "RP2040", "configFiles": [ "interface/picoprobe.cfg", "target/rp2040.cfg" ], "svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd", "runToMain": true, // Work around for stopping at main on restart "postRestartCommands": [ "break main", "continue" ], "searchDir": ["~/pico/openocd/tcl"], "showDevDebugOutput": "both", } ] } ----------------------------------------------------End -------------------------------------------

.The file , ~/project/myproject/vscode/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", "cortex-debug.openocdPath": "/usr/local/bin", "code-runner.commands": { "cmake-gui": "cmake-gui ${workspaceFolder}/build" }, "cmake.launchTargetPath": "${workspaceFolder}/build" } ----------------------------------------------------End -------------------------------------------

3. Manul runs of openOCD and gdb:

openocd running at myself@mycomputer:

/usr/local/bin/openocd -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s ~/pico/openocd/tcl -f /home/myself/.vscode/extensions/marus25.cortex-debug-1.4.4/support/openocd-helpers.tcl -f interface/picoprobe.cfg -f target/rp2040.cfg Open On-Chip Debugger 0.11.0-g610f137-dirty (2022-05-06-12:52) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html CDRTOSConfigure Info : only one transport option; autoselect 'swd' adapter speed: 5000 kHz

Info : Hardware thread awareness created Info : Hardware thread awareness created Info : RP2040 Flash Bank Command Info : Listening on port 50001 for tcl connections Info : Listening on port 50002 for telnet connections Info : clock speed 5000 kHz Info : SWD DPIDR 0x0bc12477 Info : SWD DLPIDR 0x00000001 Info : SWD DPIDR 0x0bc12477 Info : SWD DLPIDR 0x10000001 Info : rp2040.core0: hardware has 4 breakpoints, 2 watchpoints Info : rp2040.core1: hardware has 4 breakpoints, 2 watchpoints Error: rp2040.core0 -- clearing lockup after double fault Info : starting gdb server for rp2040.core0 on 50000 Info : Listening on port 50000 for gdb connections ----------------------------------------------------End -------------------------------------------

gdb running at myself@mycomputer:

gdb-multiarch -q --interpreter=mi2 /home/myself/projects/myproject/build/pico-sdk/src/rp2_common/boot_stage2/bs2_default.elf =thread-group-added,id="i1" ~"Reading symbols from /home/myself/projects/myproject/build/pico-sdk/src/rp2_common/boot_stage2/bs2_default.elf...\n" (gdb) help &"help\n" ~"List of classes of commands:\n\n" ~"aliases -- User-defined aliases of other commands.\n" ~"breakpoints -- Making program stop at certain points.\n" ~"data -- Examining data.\n" ~"files -- Specifying and examining files.\n" ~"internals -- Maintenance commands.\n" ~"obscure -- Obscure features.\n" ~"running -- Running the program.\n" ~"stack -- Examining the stack.\n" ~"status -- Status inquiries.\n" ~"support -- Support facilities.\n" ~"text-user-interface -- TUI is the GDB text based interface.\n" ~"tracepoints -- Tracing of program execution without stopping the program.\n" ~"user-defined -- User-defined commands.\n" ~"\nType \"help" ~"\" followed by a class name for a list of commands in that class.\nType \"help all\" for the list of all commands." ~"\nType \"help" ~"\" followed by command name for full documentation.\n" ~"Type \"apropos word\" to search for commands related to \"word\".\n" ~"Type \"apropos -v word\" for full documentation of commands related to \"word\".\n" ~"Command name abbreviations are allowed if unambiguous.\n" ^done (gdb) ----------------------------------------------------End -------------------------------------------

VScode About:

Version: 1.66.2 Commit: dfd34e8260c270da74b5c2d86d61aee4b6d56977 Date: 2022-04-11T07:45:25.488Z Electron: 17.2.0 Chromium: 98.0.4758.109 Node.js: 16.13.0 V8: 9.8.177.11-electron.0 OS: Linux arm 5.15.32-v7l+

----------------------------------------------------End -------------------------------------------

Extensions:

Better C++ Syntax Better Comments C/C++ C/C++ Extension Pack CMake CMake Tools Code Runner Cortext-Debug Doxygen Documentation Generator ----------------------------------------------------End -------------------------------------------

ls -al on /usr/local/bin :

total 14708 drwxr-xr-x 2 root root 4096 May 11 23:25 . drwxr-xr-x 10 root root 4096 Apr 4 04:45 .. -rwxr-xr-x 1 root root 15050860 May 11 23:25 openocd

----------------------------------------------------End -------------------------------------------

System Info |Item|Value| |---|---| |CPUs|ARMv7 Processor rev 3 (v7l) (4 x 1500)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: enabled_on
rasterization: disabled_software
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|1, 1, 0| |Memory (System)|3.75GB (0.73GB free)| |Process Argv|--unity-launch --crash-reporter-id 287cf0da-90f5-4a95-b743-33ad58f1cc3e| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|LXDE-pi| |XDG_CURRENT_DESKTOP|LXDE| |XDG_SESSION_DESKTOP|lightdm-xsession| |XDG_SESSION_TYPE|x11|
Extensions (9) Extension|Author (truncated)|Version ---|---|--- better-comments|aar|3.0.0 doxdocgen|csc|1.4.0 code-runner|for|0.11.7 better-cpp-syntax|jef|1.15.13 cortex-debug|mar|1.4.4 cmake-tools|ms-|1.10.5 cpptools|ms-|1.9.8 cpptools-extension-pack|ms-|1.2.0 cmake|twx|0.0.17 (1 theme extensions excluded)
A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492cf:30256860 pythonvspyl392:30443607 pythontb:30283811 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscorecescf:30445987 pythondataviewer:30285071 vscod805:30301674 pythonvspyt200:30340761 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 vsc1dst:30438360 pythonvs932:30410667 wslgetstarted:30449410 pythonvsnew555:30457759 vscscmwlcmt:30465135 cppdebugcf:30475217 vsclangdf:30486550 ```
haneefdm commented 2 years ago

your OpenOCDPath is incomplete...pointing to a directory rather than an executable

"cortex-debug.openocdPath": "/usr/local/bin",

Which resulted in this a bad launch

Launching gdb-server: /usr/local/bin -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s ~/pico/openocd/tcl -f /home/myself/.vscode/extensions/marus25.cortex-debug-1.4.4/support/openocd-helpers.tcl -f interface/picoprobe.cfg -f target/rp2040.cfg

Change it to

"cortex-debug.openocdPath": "/usr/local/bin/openocd",
image
VBruceHunt commented 2 years ago

Thank you for the assistance and quick response. I was confused by the overloaded term "Path". Sometimes it means the pathways only excluding the endpoint(i.e. just the directory sequence leading to the endpoint) and sometimes (like this time) it includes the endpoint. Perhaps the term "path" could be reserved for the pathway to the endpoint and a new term such as "pathend" could be introduced to be the "path" including the endpoint. Note that the sentence "Path to the OpenOCD GDB Server executable." is ambiguous and in light of the following sentence it seems logical that the OpenOCD path would follow the same pattern as the system path. Clarity in this documentation would have saved time for both of us. Again my thanks for your quick observation and response.