准备工作
硬件连接
JTAG Pin | WB2 Pin |
---|---|
TDO | IO 11 |
TMS | IO 12 |
TCK | IO 14 |
TDI | IO 17 |
GND | GND |
Visual Studio Code 安装 Cortex-Debug 扩展
编译并烧写固件
以调试安信可 WB2 SDK 的例程 demo_adc 为例,编译该项目后将生成固件烧录进 WB2 模组中。
添加调试配置
编写 launch.json
文件:
{
"version": "0.2.0",
"configurations": [
{
"name": "BL602 Debug",
"cwd": "${workspaceFolder}",
"executable": "${workspaceFolder}/applications/peripherals/demo_adc/build_out/demo_adc.elf",
"request": "attach",
"type": "cortex-debug",
"runToEntryPoint": "main",
"servertype": "external",
"toolchainPrefix": "riscv64-unknown-elf",
"armToolchainPath": "${workspaceFolder}/toolchain/riscv/MSYS/bin",
"gdbTarget": "localhost:2331",
"showDevDebugOutput": "raw"
}
]
}
其中 executable
指向被调试固件的 ELF 文件(非 bin 文件), armToolchainPath
指向工具链目录。
启动 J-Link GDB Server
在开始菜单中找到 J-Link GDB Server 并启动。
开始调试
在 VS Code 中启动调试即可进行单步调试和查看变量等操作。