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

MacOS下VSCode配置Raspberry Pico+Debug-Probe的OpenOCD调试求助

MacOS Monterey 12.6.7 + VSCode 1.79.2 下Raspberry Pico OpenOCD可视化调试有效配置

以下是同环境下验证可行的配置文件,配合marus25.cortex-debug插件使用:

1. launch.json(调试启动配置)

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Pico Debug",
            "type": "cortex-debug",
            "request": "launch",
            "servertype": "openocd",
            "cwd": "${workspaceRoot}",
            "executable": "${workspaceRoot}/build/blink.elf", // 替换为你的ELF文件实际路径
            "preLaunchTask": "Start OpenOCD",
            "device": "RP2040",
            "interface": "cmsis-dap",
            "gdbPath": "/usr/local/bin/arm-none-eabi-gdb", // 替换为你的gdb路径,可通过`which arm-none-eabi-gdb`获取
            "openOCDPath": "/usr/local/bin/openocd", // 替换为你的openocd路径,可通过`which openocd`获取
            "configFiles": [
                "interface/cmsis-dap.cfg",
                "target/rp2040.cfg"
            ],
            "openOCDLaunchCommands": [
                "adapter speed 5000"
            ],
            "runToEntryPoint": "main",
            "showDevDebugOutput": "none"
        }
    ]
}

2. tasks.json(预启动OpenOCD服务任务)

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Start OpenOCD",
            "type": "shell",
            "command": "sudo",
            "args": [
                "/usr/local/bin/openocd", // 替换为你的openocd实际路径
                "-f", "interface/cmsis-dap.cfg",
                "-f", "target/rp2040.cfg",
                "-c", "adapter speed 5000"
            ],
            "isBackground": true,
            "problemMatcher": [],
            "detail": "启动OpenOCD调试服务器"
        }
    ]
}

3. settings.json(工具路径全局配置)

{
    "cortex-debug.openocdPath": "/usr/local/bin/openocd",
    "cortex-debug.gdbPath": "/usr/local/bin/arm-none-eabi-gdb",
    "cmake.configureOnOpen": false // 若使用CMake构建项目,可根据需求调整
}

关键注意事项

  • 权限处理:因为OpenOCD需要访问USB调试探针,每次调试输入sudo密码会影响体验,可通过sudo visudo编辑/etc/sudoers文件,添加一行(替换为你的用户名和openocd路径):
    your_username ALL=(ALL) NOPASSWD: /usr/local/bin/openocd
    
  • 插件依赖:确保已在VSCode中安装marus25.cortex-debug插件,这是ARM Cortex-M系列芯片可视化调试的必备插件。
  • 路径验证:通过终端命令which arm-none-eabi-gdb和which openocd确认工具路径,替换配置中对应的字段。

内容的提问来源于stack exchange,提问作者Hans van Schaick

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.18 11:05:17