2

I am trying to debug a raspberry pi pico from vscode using a picoprobe. After a lot of pain I managed to get everything running from a msys2 mingw64 shell (I built openocd in that shell). However, debugging from vscode results in a popup saying OpenOCD: GDB Server Quit Unexpectedly. My Debug console reads

Cortex-Debug: VSCode debugger extension version 1.6.7 git(b0f5563). Usage info: https://github.com/Marus/cortex-debug#usage
Reading symbols from arm-none-eabi-objdump --syms -C -h -w C:/VSARM/sdk/pico/pico-examples/build/blink/blink.elf
Reading symbols from arm-none-eabi-nm --defined-only -S -l -C -p C:/VSARM/sdk/pico/pico-examples/build/blink/blink.elf
Launching GDB: arm-none-eabi-gdb -q --interpreter=mi2
1-gdb-version
Launching gdb-server: "C:/VSARM/debug_tools/openocd/src/openocd.exe" -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s "C:V/SARM/debug_tools/openocd/tcl" -f "c:/Users/micha/.vscode/extensions/marus25.cortex-debug-1.6.7/support/openocd-helpers.tcl" -f interface/cmsis-dap.cfg -f target/rp2040.cfg
    Please check TERMINAL tab (gdb-server) for output from C:/VSARM/debug_tools/openocd/src/openocd.exe
Finished reading symbols from objdump: Time: 86 ms
Finished reading symbols from nm: Time: 115 ms
OpenOCD: GDB Server Quit Unexpectedly. See gdb-server output in TERMINAL tab for more details.

and my terminal (set to msys2 mingw64 terminal in the vscode settings) reads

[2022-12-05T14:08:43.239Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session connected. You can switch to "DEBUG CONSOLE" to see GDB interactions.
"C:/VSARM/debug_tools/openocd/src/openocd.exe" -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s "C:V/SARM/debug_tools/openocd/tcl" -f "c:/Users/micha/.vscode/extensions/marus25.cortex-debug-1.6.7/support/openocd-helpers.tcl" -f interface/cmsis-dap.cfg -f target/rp2040.cfg
[2022-12-05T14:08:43.310Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session closed
GDB server session ended. This terminal will be reused, waiting for next session to start...

My launch.json is

{
    "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" : "arm-none-eabi-gdb",
            "device": "RP2040",
            "configFiles": [
                "interface/cmsis-dap.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": ["C:/VSARM/debug_tools/openocd/tcl"],
            "showDevDebugOutput": "raw",
        }
    ]
}

Does somebody see a mistake in my setup?

Currently, my best guess is that there is some sort of dependency that is only satisfied in msys2 mingw64 and not in the terminal (windows power shell?) vscode uses to run the gdb/openocd server.

Does somebody know how I can force vscode (or the cortex-debug extension) to use the msys2 mingw64 shell to run openocd?

An other possible solution/workaround I see is to start the openocd server manually in msys2 mingw64. I could then connect to the openocd server from vscode. Does somebody know if and how I can do this? I only found solutions where vscode starts both the gdb and openocd server.

Thank you for your help.

mlx11
  • 170
  • 1
  • 8

0 Answers0