Skip to content

Commit 6d2bafb

Browse files
committed
[add] 添加vscode环境下调试烧录固件的方法
1 parent 77ff90b commit 6d2bafb

File tree

2 files changed

+86
-5
lines changed

2 files changed

+86
-5
lines changed

bsp/gd32/risc-v/gd32vw553h-eval/README.md

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,55 @@ msh >
124124
BSP 默认只开启了 GPIO 和 串口0的功能,如果需使用高级功能,需要利用 ENV 工具对BSP 进行配置,步骤如下:
125125

126126
1. 在 bsp 下打开 env 工具。
127-
128127
2. 输入`menuconfig`命令配置工程,配置好之后保存退出。
129-
130128
3. 输入`pkgs --update`命令更新软件包。
131-
132129
4. 输入`scons `命令重新编译工程。
133130

134-
## 3 注意事项
131+
## 3 调试下载(VSCode)
132+
133+
首先在BSP根目录下执行下述命令,生成VSCode工程所需文件。
134+
135+
> scons --target=vs
136+
137+
在VSCode安装扩展插件Cortex-Debug,版本v1.4.4。
138+
139+
完成上述工作后,点击运行和调试选项,创建一个launch.json配置文件,配置文件示例如下:
140+
141+
```json
142+
{
143+
"version": "0.2.0",
144+
"configurations":
145+
[
146+
{
147+
"name": "Cortex Debug",
148+
"cwd": "${workspaceFolder}",
149+
"executable": "${workspaceFolder}/rtthread.elf",
150+
"request": "launch",
151+
"type": "cortex-debug",
152+
"servertype": "openocd",
153+
"serverpath": "E:/GD32/GD32VW5/Tools/GD32EmbeddedBuilder_v1.5.2.30854/Tools/OpenOCD/xpack-openocd-0.11.0-3/bin/openocd",
154+
"configFiles":
155+
[
156+
"${workspaceFolder}/openocd_gdlink.cfg"
157+
],
158+
"runToEntryPoint": "main",
159+
"showDevDebugOutput": "raw",
160+
"toolchainPrefix": "E:/GD32/GD32VW5/Tools/GD32EmbeddedBuilder_v1.5.2.30854/Tools/RISC-V Embedded GCC/8.2.0-2.2-20190521-0004/bin/riscv-none-embed"
161+
}
162+
]
163+
}
164+
```
165+
166+
上述文件中的部分字段需要根据用户环境进行修改,格式需与示例一致:
167+
168+
- "serverpath”:该字段需要改为用户的openocd所在路径,openocd工具位于GD32EmbeddedBuilder工具包中。
169+
- "toolchainPrefix":该字段需修改为用户的工具链所在路径,工具链位于GD32EmbeddedBuilder工具包中。
170+
171+
完成上述配置后即可点击调试选项进行调试,调试时boot管脚均置为低电平即可,调试时同样会进行固件下载。
172+
173+
## 4 注意事项
135174

136-
暂无
175+
- Cortex-Debug插件优先选用v1.4.4版本,高版本可能会出现与GDB版本不匹配的问题。
137176

138177
## 联系人信息
139178

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#
2+
# GigaDevice GD32VW55x target
3+
#
4+
adapter driver cmsis-dap
5+
6+
adapter speed 8000000
7+
reset_config trst_only
8+
adapter srst pulse_width 100
9+
10+
transport select jtag
11+
12+
set _CHIPNAME riscv
13+
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x10307a6d
14+
15+
set _TARGETNAME $_CHIPNAME.cpu
16+
target create $_TARGETNAME riscv -chain-position $_TARGETNAME
17+
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size 20480 -work-area-backup 0
18+
19+
20+
# Work-area is a space in RAM used for flash programming
21+
if { [info exists WORKAREASIZE] } {
22+
set _WORKAREASIZE $WORKAREASIZE
23+
} else {
24+
set _WORKAREASIZE 0x5000
25+
}
26+
27+
# Allow overriding the Flash bank size
28+
if { [info exists FLASH_SIZE] } {
29+
set _FLASH_SIZE $FLASH_SIZE
30+
} else {
31+
# autodetect size
32+
set _FLASH_SIZE 0
33+
}
34+
35+
# flash size will be probed
36+
set _FLASHNAME $_CHIPNAME.flash
37+
38+
flash bank $_FLASHNAME gd32vw55x 0x08000000 0x400000 0 0 $_TARGETNAME
39+
riscv set_reset_timeout_sec 1
40+
init
41+
42+
halt

0 commit comments

Comments
 (0)