Skip to content

Commit

Permalink
Fix GDB on minichlink. (#444)
Browse files Browse the repository at this point in the history
 * Redo mechanism for gdb in a variety of ways, tested in a virety of situations.
 * Update minichlink.exe
 * Add `make gdbclient` as a target and change single step behavior.
 * Further tweaks to vs code launch (need to backport to template). And, also, improvements to windows GDB.
 * Optimize pgm-esp32-s2-ch32xx.c
 * Improve VS Code build
 * Properly define flash memory section.
 * Cleanup and unify vscode projects.
 * Super unbrick mode now unlocked.  It just continuously tries to unbrick.
 * Working on trying to make the v307 unbrick work
 * Tested working unbrick for v30x (and by extension v20x)
 * Fix unaligned (start address) writes.
 * Add vCont support.
 * remove threads as a feature
 * Update with s/c parsing
 * Announce steps.
 * Fix debug break behavior.
 * Fixup debug tasks.json double variable.:
 * Fixed halt/resume on WCH-LinkE

---------

Co-authored-by: monte-monte <[email protected]>
  • Loading branch information
cnlohr and monte-monte authored Nov 25, 2024
1 parent dfa4d25 commit de24aea
Show file tree
Hide file tree
Showing 16 changed files with 633 additions and 191 deletions.
3 changes: 3 additions & 0 deletions ch32v003fun/ch32v003fun.mk
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ unbrick :
gdbserver :
-$(MINICHLINK)/minichlink -baG

gdbclient :
gdb-multiarch $(TARGET).elf -ex "target remote :2000"

clangd :
make clean
bear -- make build
Expand Down
19 changes: 17 additions & 2 deletions examples/debugprintfdemo/.vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,28 @@
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cppStandard": "c++14",
"cppStandard": "c++20",
"intelliSenseMode": "linux-clang-x64",
"compilerArgs": [
"-DCH32V003FUN_BASE"
],
"configurationProvider": "ms-vscode.makefile-tools"
},
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/../../ch32v003fun"
],
"defines": [],
"compilerPath": "riscv64-unknown-elf-gcc-10.1.0.exe",
"cppStandard": "c++20",
"compilerArgs": [
"-DCH32V003FUN_BASE"
],
"configurationProvider": "ms-vscode.makefile-tools"
}
],
"version": 4
"version": 4,
"enableConfigurationSquiggles": true
}
41 changes: 25 additions & 16 deletions examples/debugprintfdemo/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,48 @@
{
"configurations": [
{
"name": "GDB Debug Target",
"name": "Debug Target",
"type": "cppdbg",
"request": "launch",
"program": "debugprintfdemo.elf",
"program": "${workspaceFolder}/debugprintfdemo.elf",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"deploySteps": [
{
"type": "shell",
"continueOn": "GDBServer",
"command": "make --directory=${workspaceFolder} closechlink flash gdbserver"
},
],
"preLaunchTask": "run_flash_and_gdbserver",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"svdPath": "${workspaceFolder}/../../misc/CH32V003xx.svd", // extension 'Peripheral Viewer' by mcu-debug (cortex-debug)
"miDebuggerPath": "gdb-multiarch",
"miDebuggerServerAddress": "127.0.0.1:2000"
"miDebuggerServerAddress": "127.0.0.1:2000",
},
{
"name": "Run Only (In Terminal)",
"name": "Flash and run in terminal",
"type": "node-terminal",
"request": "launch",
"internalConsoleOptions": "neverOpen",
"command": "make closechlink clean; make flash monitor",
},
{
"name": "Compile and Flash",
"type": "node",
"request": "launch",
"program": "",
"preLaunchTask": "run_flash_and_gdbserver",
}
]
}
"internalConsoleOptions": "neverOpen",
"preLaunchTask" : "kill_all_tasks",
"postDebugTask": "run_flash",
"presentation": {
"hidden": false,
"group": "terminaloutput",
"order": 1
},
"runtimeExecutable": "echo"
}
]
}
6 changes: 3 additions & 3 deletions examples/debugprintfdemo/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"makefile.launchConfigurations": [
{
"cwd": "",
"sbinaryPath": "debugprintfdemo.elf",
"sbinaryPath": "debugprintf.elf",
"binaryArgs": []
}
],
"editor.insertSpaces": false,
"editor.tabSize": 4,
"files.associations": {
"ch32v003fun.h": "c"
}
}
},
}
116 changes: 96 additions & 20 deletions examples/debugprintfdemo/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,130 @@
"tasks": [
{
"type": "shell",
"label": "flash",
"presentation": {
"echo": true,
"focus": false,
"group": "build",
"panel": "shared",
"close": true,
"showReuseMessage" : false
},
"command": "make closechlink flash",
"command": "make closechlink clean; make flash monitor",
"label": "run_flash_and_monitor",
"group": {
"kind": "build",
"isDefault": true
},
"runOptions": {
"instanceLimit": 1,
},
"isBackground": true,
"problemMatcher": { // https://code.visualstudio.com/docs/editor/tasks#_defining-a-problem-matcher
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceFolder}"
],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
},
"background": {
"activeOnStart": false,
"beginsPattern": "^.*Image written.*",
"endsPattern": "^.*GDBServer*"
},
}
},
{
"type": "shell",
"label": "run_flash_and_gdbserver",
"command": "make closechlink flash gdbserver",

"command": "make clean closechlink; make flash gdbserver",
"presentation": {
"echo": true,
"focus": false,
"focus": true,
"group": "build",
"panel": "shared",
"reveal": "always",
"close": true,
"showReuseMessage" : false
"showReuseMessage": false
},

"isBackground": true,
"options": {
"cwd": "${workspaceFolder}",
},
"runOptions": {
"instanceLimit": 2,
},
"instanceLimit": 1,
},
"group": "build",
"problemMatcher": {
"pattern": [
{
"regexp": ".",
"file": 1,
"location": 2,
"message": 3
}
"problemMatcher": { // https://code.visualstudio.com/docs/editor/tasks#_defining-a-problem-matcher
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceFolder}"
],

"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
},
"background": {
"activeOnStart": false,
"beginsPattern": "^.*Image written.*",
"endsPattern": "^.*GDBServer*"
}
},
}
},
{
"type": "shell",
"label": "run_flash",
"command": "make clean closechlink; make flash",
"presentation": {
"echo": true,
"focus": true,
"group": "build",
"panel": "shared",
"close": true,
"reveal": "always",
"showReuseMessage": true
},
"isBackground": false,
"options": {
"cwd": "${workspaceFolder}",
},
"runOptions": {
"instanceLimit": 1,
},
"group": "build",
"problemMatcher": { // https://code.visualstudio.com/docs/editor/tasks#_defining-a-problem-matcher
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceFolder}"
],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
},
}
},
{
"type": "process",
"label" : "kill_all_tasks",
"command":[
"${command:workbench.action.tasks.terminate} terminateAll",
]
}
]
}
}
41 changes: 25 additions & 16 deletions examples/template/.vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
{
"configurations": [
{
"name": "RISCV32EC",
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/../../ch32v003fun",
"${workspaceFolder}/../../extralibs",
"/usr/include/newlib" //why? the configurationProvider ought to find this
"${workspaceFolder}/../../ch32v003fun"
],
"defines": [
"CH32V003",
"__riscv",
"USE_SIGNALS",
"CH32V003FUN_BASE"
"defines": [],
"compilerPath": "/usr/bin/clang",
"cppStandard": "c++20",
"intelliSenseMode": "linux-clang-x64",
"compilerArgs": [
"-DCH32V003FUN_BASE"
],
"configurationProvider": "ms-vscode.makefile-tools"
},
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/../../ch32v003fun"
],
"defines": [],
"compilerPath": "riscv64-unknown-elf-gcc-10.1.0.exe",
"cppStandard": "c++20",
"compilerArgs": [
"-DCH32V003FUN_BASE"
],
"compilerPath": "/usr/bin/riscv64-unknown-elf-gcc",
"cStandard": "gnu11",
"cppStandard": "gnu++17",
"intelliSenseMode": "gcc-x86", //works. Someday, intellisense might get riscv modes
"compilerArgs": [],
"configurationProvider": "ms-vscode.makefile-tools"
}
],
"version": 4
}
"version": 4,
"enableConfigurationSquiggles": true
}
43 changes: 22 additions & 21 deletions examples/template/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"configurations": [
{
"name": "cppdbg GDB Debug Target",
"name": "Debug Target",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/template.elf",
Expand All @@ -11,37 +11,38 @@
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"deploySteps": [ // 'make ...gdbserver' doesn't seem to work here. The Makefile calls 'minichlink -baG'... Needs -aG. Easier to add minichlink as a seperate step below
{
"type": "shell", //isn't there some way to call a task from tasks.json?
"command": "make --directory=${workspaceFolder} -j 1 closechlink flash",
},
{
"type": "shell",
"command": "${workspaceFolder}/../../minichlink/minichlink -aG",
"continueOn": "gdbserver running"
},
],
"preLaunchTask": "run_flash_and_gdbserver",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true,
},
"ignoreFailures": true
}
],
"svdPath": "${workspaceFolder}/../../misc/CH32V003xx.svd", // extension 'Peripheral Viewer' by mcu-debug (cortex-debug)
"miDebuggerPath": "gdb-multiarch",
"miDebuggerServerAddress": "localhost:2000",
"logging": {
"engineLogging": false
},
"miDebuggerServerAddress": "127.0.0.1:2000",
},
{
"name": "Run Only (In Terminal)",
"name": "Flash and run in terminal",
"type": "node-terminal",
"request": "launch",
"internalConsoleOptions": "neverOpen",
"command": "make closechlink clean; make flash monitor",
},
{
"name": "Compile and Flash",
"type": "node",
"request": "launch",
"program": "",
"preLaunchTask": "run_flash_and_gdbserver",
"internalConsoleOptions": "neverOpen",
"preLaunchTask" : "kill_all_tasks",
"postDebugTask": "run_flash",
"presentation": {
"hidden": false,
"group": "terminaloutput",
"order": 1
},
"runtimeExecutable": "echo"
}
]
}
Loading

0 comments on commit de24aea

Please sign in to comment.