Template
feat(vscode): add connect-under-reset tasks
This commit is contained in:
Vendored
+88
@@ -120,6 +120,94 @@
|
|||||||
"tooltip": "Erase MCU"
|
"tooltip": "Erase MCU"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": "Build and Flash (Connect Under Reset)",
|
||||||
|
"dependsOn": [
|
||||||
|
"Build",
|
||||||
|
"Flash MCU (Connect Under Reset)"
|
||||||
|
],
|
||||||
|
"dependsOrder": "sequence",
|
||||||
|
"group": "build",
|
||||||
|
"icon": {
|
||||||
|
"id": "insert",
|
||||||
|
"tooltip": "Build and Flash (Connect Under Reset)"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Flash MCU (Connect Under Reset)",
|
||||||
|
"type": "process",
|
||||||
|
"command": "${env:GD32_OPENOCD_BIN}/openocd.exe",
|
||||||
|
"args": [
|
||||||
|
"-s", "${env:GD32_OPENOCD_SCRIPTS}",
|
||||||
|
"-f", "${env:GD32_OPENOCD_SCRIPTS}/${config:gd32.openocd.targetConfig}",
|
||||||
|
"-c", "adapter srst delay 100; reset_config srst_only srst_nogate connect_assert_srst; init; adapter deassert srst; sleep 200; catch {reset halt}; reset halt; flash write_image erase ${command:cmake.launchTargetFilename}; reset; exit"
|
||||||
|
],
|
||||||
|
"group": "build",
|
||||||
|
"problemMatcher": [],
|
||||||
|
"options": {
|
||||||
|
"cwd": "${command:cmake.buildDirectory}/Application",
|
||||||
|
"environment": {
|
||||||
|
"OPENOCD_SCRIPTS": "${env:GD32_OPENOCD_SCRIPTS}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"presentation": {
|
||||||
|
"clear": true
|
||||||
|
},
|
||||||
|
"icon": {
|
||||||
|
"id": "gather",
|
||||||
|
"tooltip": "Flash MCU (Connect Under Reset)"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Reset MCU (Connect Under Reset)",
|
||||||
|
"type": "process",
|
||||||
|
"command": "${env:GD32_OPENOCD_BIN}/openocd.exe",
|
||||||
|
"args": [
|
||||||
|
"-s", "${env:GD32_OPENOCD_SCRIPTS}",
|
||||||
|
"-f", "${env:GD32_OPENOCD_SCRIPTS}/${config:gd32.openocd.targetConfig}",
|
||||||
|
"-c", "adapter srst delay 100; reset_config srst_only srst_nogate connect_assert_srst; init; adapter deassert srst; sleep 200; reset; exit"
|
||||||
|
],
|
||||||
|
"group": "build",
|
||||||
|
"problemMatcher": [],
|
||||||
|
"options": {
|
||||||
|
"cwd": "${command:cmake.buildDirectory}/Application",
|
||||||
|
"environment": {
|
||||||
|
"OPENOCD_SCRIPTS": "${env:GD32_OPENOCD_SCRIPTS}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"presentation": {
|
||||||
|
"clear": true
|
||||||
|
},
|
||||||
|
"icon": {
|
||||||
|
"id": "discard",
|
||||||
|
"tooltip": "Reset MCU (Connect Under Reset)"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Mass Erase MCU (Connect Under Reset)",
|
||||||
|
"type": "process",
|
||||||
|
"command": "${env:GD32_OPENOCD_BIN}/openocd.exe",
|
||||||
|
"args": [
|
||||||
|
"-s", "${env:GD32_OPENOCD_SCRIPTS}",
|
||||||
|
"-f", "${env:GD32_OPENOCD_SCRIPTS}/${config:gd32.openocd.targetConfig}",
|
||||||
|
"-c", "adapter srst delay 100; reset_config srst_only srst_nogate connect_assert_srst; init; adapter deassert srst; sleep 200; catch {reset halt}; reset halt; ${config:gd32.openocd.massEraseCommand}; exit"
|
||||||
|
],
|
||||||
|
"group": "build",
|
||||||
|
"problemMatcher": [],
|
||||||
|
"options": {
|
||||||
|
"cwd": "${command:cmake.buildDirectory}/Application",
|
||||||
|
"environment": {
|
||||||
|
"OPENOCD_SCRIPTS": "${env:GD32_OPENOCD_SCRIPTS}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"presentation": {
|
||||||
|
"clear": true
|
||||||
|
},
|
||||||
|
"icon": {
|
||||||
|
"id": "clear-all",
|
||||||
|
"tooltip": "Erase MCU (Connect Under Reset)"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": "OpenOCD Server",
|
"label": "OpenOCD Server",
|
||||||
"type": "process",
|
"type": "process",
|
||||||
|
|||||||
@@ -306,6 +306,12 @@ source [find interface/cmsis-dap.cfg]
|
|||||||
source [find target/gd32e23x.cfg]
|
source [find target/gd32e23x.cfg]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
模板同时提供 `Flash MCU (Connect Under Reset)`、`Reset MCU (Connect Under Reset)` 和
|
||||||
|
`Mass Erase MCU (Connect Under Reset)` 三个可选任务,用于固件复用 SWD 引脚后普通方式无法连接的场景。
|
||||||
|
这些任务会在启动 OpenOCD 时临时设置 `connect_assert_srst`,不需要修改工具链目录中的 cfg 文件。
|
||||||
|
使用前必须将调试器的 RST 线连接到 MCU 的 NRST;若固件会复用 SWD 引脚,还应在松开复位后保留至少
|
||||||
|
2 秒的调试挂接窗口。未连接 RST 线时继续使用不带 `Connect Under Reset` 后缀的普通任务。
|
||||||
|
|
||||||
每台开发电脑配置一次用户环境变量(路径按本机实际位置填写):
|
每台开发电脑配置一次用户环境变量(路径按本机实际位置填写):
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
@@ -375,10 +381,11 @@ cmake --build Build/Release
|
|||||||
|
|
||||||
### 烧录
|
### 烧录
|
||||||
|
|
||||||
通过 VSCode 任务栏运行 `Flash MCU` 任务,或命令行:
|
通过 VSCode 任务栏运行 `Flash MCU` 任务。若固件运行后会复用 SWD 引脚,且调试器的 RST 已连接到
|
||||||
|
MCU 的 NRST,则改用 `Build and Flash (Connect Under Reset)`。普通模式也可通过命令行烧录:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
openocd -f interface/cmsis-dap.cfg -f target/gd32e23x.cfg -c "program Build/Debug/Application.elf verify reset exit"
|
openocd -f interface/cmsis-dap.cfg -f target/gd32e23x.cfg -c "program Build/Debug/Application/Application.elf verify reset exit"
|
||||||
```
|
```
|
||||||
|
|
||||||
### 产物
|
### 产物
|
||||||
|
|||||||
Reference in New Issue
Block a user