You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VSCode调试Raspberry Pi Pico时OpenOCD意外退出问题求助

Raspberry Pi Pico VSCode调试问题:OpenOCD意外退出

问题背景

我正尝试使用Picoprobe在VSCode中调试Raspberry Pi Pico。已在MSYS2 Mingw64 Shell中编译OpenOCD并能正常运行所有调试流程,但在VSCode中调试时弹出提示OpenOCD: GDB Server Quit Unexpectedly。

调试控制台输出

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.

VSCode终端输出(已设置为MSYS2 Mingw64终端)

[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...

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" : "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",
        }
    ]
}

疑问与求助

  • 我的配置是否存在错误?
  • 猜测原因:部分依赖仅在MSYS2 Mingw64环境中满足,VSCode运行GDB/OpenOCD时可能未使用该环境(比如用了Windows PowerShell),如何强制VSCode或Cortex-Debug扩展使用MSYS2 Mingw64 Shell运行OpenOCD?
  • 另一种方案:在MSYS2 Mingw64中手动启动OpenOCD服务器,再让VSCode连接到该服务器,是否可行?具体如何配置?目前只找到VSCode同时启动GDB和OpenOCD的方案。

内容的提问来源于stack exchange,提问作者mlx11

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 22:20:27