dreamcmi / CH32V307-CMake

WCH CH32V307 Series CMake Project
MIT License
4 stars 2 forks source link

请教一下在vscode调试下载的问题 #1

Open zgjsntsm opened 1 year ago

zgjsntsm commented 1 year ago

您好,目前在按照大佬提供的模板已经编译成功;想请教一下在vscode下该如何配置调试与下载

dreamcmi commented 1 year ago

首先非常抱歉回复晚了,最近在忙学业。

vscode下载可以使用tasks.json功能 以下我分享一个示例

{
  "version": "2.0.0",
  "tasks": [
    {
        "label": "build",
        "type": "shell",
        "command": "./build.bat",
    },
    {
        "label": "flash",
        "type": "shell",
        "command":[
            "C:/IDE/MounRiver/MounRiver_Studio/toolchain/OpenOCD/bin/openocd.exe -f C:/IDE/MounRiver/MounRiver_Studio/toolchain/OpenOCD/bin/wch-riscv.cfg -c init -c halt  -c 'program ./build/ch32v203-ninja.hex' -c exit"
        ]
    }
  ]
}

接下来是调试部分,推荐使用cortex-debug插件,配置一下lunch.json (PS:推荐插件版本1.6.0 高版本会检查gdb版本大于等于9,而沁恒给的版本是8,会导致不能调试)

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "cortex-debug",
            "type": "cortex-debug",
            "request": "launch",
            "armToolchainPath": "C:\\IDE\\MounRiver\\MounRiver_Studio\\toolchain\\RISC-V Embedded GCC\\bin",
            "toolchainPrefix": "riscv-none-embed",
            "servertype": "openocd",
            "cwd": "${workspaceFolder}",
            "runToMain": true,
            "executable": "./build/ch32v203-ninja.elf",
            "device": "CH32V203",
            "svdFile": "CH32V203xx.svd",
            "configFiles": [
                "C:\\IDE\\MounRiver\\MounRiver_Studio\\toolchain\\OpenOCD\\bin\\wch-riscv.cfg"
            ]
        }
    ]
}
zgjsntsm commented 1 year ago

感谢答复,我尝试一下。