Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fix_gdb #453

Merged
merged 10 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions ch32v003fun/ch32v003fun.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
#define FUNCONF_TINYVECTOR 0 // If enabled, Does not allow normal interrupts.
#define FUNCONF_UART_PRINTF_BAUD 115200 // Only used if FUNCONF_USE_UARTPRINTF is set.
#define FUNCONF_DEBUGPRINTF_TIMEOUT 0x80000 // Arbitrary time units, this is around 120ms.
#define FUNCONF_ENABLE_HPE 1 // Enable hardware interrupt stack. Very good on QingKeV4, i.e. x035, v10x, v20x, v30x, but questionable on 003.
#define FUNCONF_ENABLE_HPE 1 // Enable hardware interrupt stack. Very good on QingKeV4, i.e. x035, v10x, v20x, v30x, but questionable on 003.
// If you are using that, consider using INTERRUPT_DECORATOR as an attribute to your interrupt handlers.
#define FUNCONF_USE_5V_VDD 0 // Enable this if you plan to use your part at 5V - affects USB and PD configration on the x035.
#define FUNCONF_DEBUG_HARDFAULT 1 // Log fatal errors with "printf"
*/
Expand Down Expand Up @@ -132,11 +133,13 @@
#endif

#ifndef FUNCONF_ENABLE_HPE
#if defined( CH32V003 )
#define FUNCONF_ENABLE_HPE 0
#else
#define FUNCONF_ENABLE_HPE 1
#endif
#define FUNCONF_ENABLE_HPE 0
#endif

#if FUNCONF_ENABLE_HPE == 1
#define INTERRUPT_DECORATOR __attribute__((interrupt("WCH-Interrupt-fast")))
#else
#define INTERRUPT_DECORATOR __attribute__((interrupt))
#endif


Expand Down
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
}
Loading
Loading