一、目的
在博文《HPM5300系列--第一篇 命令行开发调试环境搭建》、《HPM6750系列--第四篇 搭建Visual Studio Code开发调试环境》中我们介绍了命令行方式开发环境,也介绍了HPM6750evkmini开发板如何使用Visual Studio Code进行开发调试(其中调试方式使用openocd + ft2232的组合方式)。
本篇我们主要介绍HPM5300evk开发板在vscode如何开发调试,其中关于编译环境的构建请参考 《HPM6750系列--第四篇 搭建Visual Studio Code开发调试环境》(必须要看)。
二、介绍
必须查看 《HPM6750系列--第四篇 搭建Visual Studio Code开发调试环境》章节创建工程目录并拷贝示例工程之前的内容。
1.打开工程
cd ~/workspace/work/hpm/hpm5300evk/hello_world
code .
由于HPM5300evk开发板有FT2232芯片,故可以使用openocd进行调试;另外板载有JTAG接口,可以配合Jlink调试器进行调试。
2.配置调试器启动文件
使用openocd + ft2232模式
使用openocd + jlink模式(板子上的跳线帽需要都取消掉)
使用jlink调试器模式(板子上的跳线帽需要都取消掉)
完整的launch.json文件内容
{"version": "0.2.0","configurations": [{"name": "HPM Debug OpenOCD FT2232","cwd": "${workspaceRoot}","executable": "${command:cmake.launchTargetPath}","request": "launch","type": "cortex-debug","servertype": "openocd","gdbPath" : "${env:GNURISCV_TOOLCHAIN_PATH}/bin/riscv32-unknown-elf-gdb","searchDir": ["${env:OPENOCD_SCRIPTS}"],"device": "HPM5361","configFiles": ["probes/ft2232.cfg","soc/hpm5361.cfg","boards/hpm5300evk.cfg"],"interface": "jtag",//"svdFile":"${env:HPM_SDK_BASE}/soc/HPM5361/HPM5361_svd.xml","runToEntryPoint": "main",// Work around for stopping at main on restart"postRestartCommands": ["break main","continue"]},{"name": "HPM Debug OpenOCD JLINK","cwd": "${workspaceRoot}","executable": "${command:cmake.launchTargetPath}","request": "launch","type": "cortex-debug","servertype": "openocd","gdbPath" : "${env:GNURISCV_TOOLCHAIN_PATH}/bin/riscv32-unknown-elf-gdb","searchDir": ["${env:OPENOCD_SCRIPTS}","${env:HPM_OPENOCD_PATH}/tcl"],"device": "HPM5361","configFiles": ["probes/jlink.cfg","soc/hpm5361.cfg","boards/hpm5300evk.cfg"],"interface": "jtag","svdFile":"${env:HPM_SDK_BASE}/soc/HPM5361/HPM5361_svd.xml","runToEntryPoint": "main",// Work around for stopping at main on restart"postRestartCommands": ["break main","continue"]},{"name": "HPM Debug Jlink","cwd": "${workspaceRoot}","executable": "${command:cmake.launchTargetPath}","request": "launch","type": "cortex-debug","servertype": "jlink","gdbPath" : "${env:GNURISCV_TOOLCHAIN_PATH}/bin/riscv32-unknown-elf-gdb","device": "HPM5361xCBx","interface": "jtag","svdFile":"${env:HPM_SDK_BASE}/soc/HPM5361/HPM5361_svd.xml","runToEntryPoint": "main",// Work around for stopping at main on restart"postRestartCommands": ["break main","continue"]}]
}
有了以上的配置后,三种方式都可以根据需要自行选择。
如果你觉得有用,麻烦关注一下公众号哈。