Pyocd+vscode调试mcu

原料:

  • vscode
  • vscode cortex-debug插件
  • pyocd

参考:

配置:

  1. 先找到目标的名字,比如stm32f412xe,填入launch配置:
$ pyocd list --target

这和flash烧录算法有关,如果没有对应的target请参考pyOCD文档,下载对应的pack

  1. vscode的launch.json:
{
    "version": "0.2.0",
    "configurations": [
      {
        "name": "Release",
        "cwd": "${workspaceRoot}",
        "executable": "./build/rrr.elf",
        "request": "launch",
        "type": "cortex-debug",
        "servertype": "pyocd",
        "interface": "swd",
        "targetId": "stm32f412xe",
        "runToMain": true,
        "preLaunchCommands": [
          "load",
        ],
        "preRestartCommands": [
          "monitor reset"
        ]
      }
    ]
  }