From 4e259f666c53e92f957e8c4d8243d941f7c3c918 Mon Sep 17 00:00:00 2001 From: LokLiang Date: Tue, 30 Apr 2024 15:07:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20VSCode=20=E7=9A=84?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/c_cpp_properties.json | 46 ++++++++++ .vscode/launch.json | 106 +++++++++++++++++++++++ .vscode/tasks.json | 156 ++++++++++++++++++++++++++++++++++ 3 files changed, 308 insertions(+) create mode 100755 .vscode/c_cpp_properties.json create mode 100755 .vscode/launch.json create mode 100755 .vscode/tasks.json diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100755 index 0000000..b251a7e --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,46 @@ +{ + "configurations": [ + { + "name": "linux-gcc-x64", + "includePath": [ + "${workspaceRoot}/**", + "${workspaceRoot}/esp-idf/components/newlib/platform_include", + "${workspaceRoot}/esp-idf/components/esp_common/include", + "${workspaceRoot}/esp-idf/components/nvs_flash/include", + "${workspaceRoot}/esp-idf/components/esp_partition/include", + "${workspaceRoot}/esp-idf/components/esp_rom/include", + "${workspaceRoot}/esp-idf/components/esp_system/include", + "${workspaceRoot}/esp-idf/components/esp_timer/include", + "${workspaceRoot}/esp-idf/components/driver/uart/include", + "${workspaceRoot}/esp-idf/components/esp_hw_support/include", + "${workspaceRoot}/esp-idf/components/esp_netif/linux/stubs/include", + "${workspaceRoot}/esp-idf/components/freertos/FreeRTOS-Kernel/include", + "${workspaceRoot}/esp-idf/components/freertos/esp_additions/include", + "${workspaceRoot}/esp-idf/components/freertos/esp_additions/include/freertos", + "${workspaceRoot}/esp-idf/components/freertos/esp_additions/arch/riscv/include", + "${workspaceRoot}/esp-idf/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos", + "${workspaceRoot}/esp-idf/components/soc/esp32/include", + "${workspaceRoot}/esp-idf/components/soc/esp32s3/include", + "${workspaceRoot}/project/components/system/include", + ], + "forcedInclude": [ + "${workspaceRoot}/project/build/config/sdkconfig.h" + ], + "defines": [ + "DEBUG_BUILD=1", + "__XTENSA__", + "CONFIG_EXAMPLE_CONNECT_WIFI" + ], + "compilerPath": "${default}", + "cStandard": "${default}", + "cppStandard": "${default}", + "intelliSenseMode": "${default}", + "compilerArgs": [ + "-Wall", + "-Wextra", + "-Wpedantic" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100755 index 0000000..fe3a0fe --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,106 @@ +{ + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + + { // 使用 JLinkGDBServer 的服务调试 + "name": "(gdb) JLinkGDBServer", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/debug/project.elf", + "args": [], + "stopAtEntry": true, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": true, + "MIMode": "gdb", + // "miDebuggerPath": "gdb-multiarch", + "miDebuggerPath": "arm-none-eabi-gdb", + "miDebuggerServerAddress": "localhost:2331", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + "preLaunchTask": "JLinkGDBServer", + "postDebugTask": "killallJLinkGDBServer", + }, + + { // 直接仿真本机程序 + "name": "gdb", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/debug/project.elf", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + }, + + { // 使用 qemu 远程调试 + "name": "(gdb) qemu-cm3", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/debug/project.elf", + "args": [], + "stopAtEntry": true, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": true, + "miDebuggerPath": "gdb-multiarch", + "miDebuggerServerAddress": "localhost:1234", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + "preLaunchTask": "qemu", + // "postDebugTask": "killallqemu", + }, + + { // TODO: 使用 openocd 的服务调试,打印命令 openocd -f interface/jlink.cfg -f target/stm32f4x.cfg -c 'init' -c 'targets' -c 'reset halt' + "name": "ARM Debug", + "type": "cppdbg", + "request": "launch", + "miDebuggerPath": "gdb-multiarch", + "targetArchitecture": "arm", + "program": "${workspaceFolder}/debug/project.elf", + "setupCommands": [ + { + "text": "file '${workspaceFolder}/debug/project.elf'" + }, + { + "text": "target remote localhost:3333" + }, + { + "text": "monitor reset" + }, + { + "text": "monitor halt" + }, + { + "text": "load" + } + ], + //"preLaunchTask": "build", + //"launchCompleteCommand": "None", + //"externalConsole": true, + "cwd": "${workspaceRoot}" + }, + + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100755 index 0000000..5b1ce2c --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,156 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + + { + "label": "build-extras", + "type": "shell", + "command": "./build.sh", + "args": ["debug_build"], + "problemMatcher": { + "owner": "cpp", + "fileLocation": ["relative", "/"], + "pattern": [ + { + "regexp": ".", + "file": 1, + "location": 2, + "message": 3 + } + ] + }, + "group": { + "kind": "build", + "isDefault": true + }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "dedicated", + "showReuseMessage": true, + "clear": true, + } + }, + + { + "label": "qemu", + // "dependsOn": "build-extras", + "type":"shell", + "isBackground":true, + "runOptions": { + "instanceLimit": 1 + }, + "command": [ + "qemu-system-arm", + "-kernel ./debug/project.elf", + "-machine mps2-an385", + "-d cpu_reset", + "-nographic", + "-monitor null", + "-semihosting", + "--semihosting-config enable=on,target=native", + "-serial stdio", + "-s", + "-S", + ], + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "dedicated", + "showReuseMessage": true, + "clear": true, + }, + "problemMatcher": + { + "owner": "external", + "pattern": [ + { + "regexp": ".", + "file": 1, + "location": 2, + "message": 3 + } + ], + "background": { + "activeOnStart": true, + "beginsPattern": ".", + "endsPattern": "." + } + } + }, + + { + "label": "killallqemu", + "type":"shell", + "isBackground": true, + "command": "killall", + "args": ["qemu-system-arm"], + "presentation": { + "echo": false, + "reveal": "never", + "focus": false, + "showReuseMessage": false, + "clear": true, + }, + }, + + { + "label": "JLinkGDBServer", + "type": "shell", + "isBackground": true, + "command": "./build.sh", + "args": [ + // "flash", + "debug_cmd", + ], + + // This task is run before some debug tasks. + // Problem is, it's a watch script, and since it never exits, VSCode + // complains. All this is needed so VSCode just lets it run. + "problemMatcher": { + "owner": "external", + "pattern": [ + { + "regexp": ".", + "file": 1, + "location": 2, + "message": 3 + } + ], + "background": { + "activeOnStart": true, + "beginsPattern": ".", + "endsPattern": "." + } + }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "dedicated", + "showReuseMessage": true, + "clear": true, + }, + }, + + { + "label": "killallJLinkGDBServer", + "type":"shell", + "isBackground": true, + "command": "killall", + "args": ["JLinkGDBServer"], + "presentation": { + "echo": false, + "reveal": "never", + "focus": false, + "showReuseMessage": false, + "clear": true, + }, + }, + + ] +}