From a6c26b57c3bd714e810bfa35a7532bc9042c853c Mon Sep 17 00:00:00 2001 From: Wayne Ren Date: Sun, 20 Mar 2022 00:43:56 +0800 Subject: [PATCH 1/2] add .gitignore add .gitigore to ignore bulilt html files and .vscode configuration Signed-off-by: Wayne Ren --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index f6d04ee..b10e500 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ +doc/source/_build doc/_build +.vscode -- Gitee From 06ac3b699d18a85e28419c0beff1d8e7b7e864ea Mon Sep 17 00:00:00 2001 From: Wayne Ren Date: Sun, 20 Mar 2022 17:19:24 +0800 Subject: [PATCH 2/2] vscode: add vscode configuration template * zephyr.code-workspace: the vscode workspace template * tasks.json: zephyr related vscode tasks definition * launch.json: zephyr debug launch definition Signed-off-by: Wayne Ren --- vscode/.vscode/launch.json | 41 ++++++++++++++ vscode/.vscode/tasks.json | 105 +++++++++++++++++++++++++++++++++++ vscode/zephyr.code-workspace | 21 +++++++ 3 files changed, 167 insertions(+) create mode 100644 vscode/.vscode/launch.json create mode 100644 vscode/.vscode/tasks.json create mode 100644 vscode/zephyr.code-workspace diff --git a/vscode/.vscode/launch.json b/vscode/.vscode/launch.json new file mode 100644 index 0000000..464a128 --- /dev/null +++ b/vscode/.vscode/launch.json @@ -0,0 +1,41 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + + { + "name": "(gdb) Zephyr", + "type": "cppdbg", + "request": "launch", + // 需要调试的zephyr镜像地址,由于launch.json在build目录下,此处的${workspaceFolder}为build目录的 + //路径 + "program": "${workspaceFolder}/zephyr/zephyr.elf", + //嵌入式开发,一般无法指定参数所以为空 + "args": [], + //在程序入口中停止 + "stopAtEntry": true, + "cwd": "${workspaceFolder}", + //一般不用设,因为ninja已经处理好了 + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + // qemu的debugserver默认打开1234端口 + "miDebuggerServerAddress": "localhost:1234", + // gdb路径 + "miDebuggerPath": "/opt/zephyr-sdk/aarch64-zephyr-elf/bin/aarch64-zephyr-elf-gdb", + // -nx 意为不调用.gdbinit来进行初始化 + "miDebuggerArgs": "-nx", + // 基于qemu的调试需要首先启动qemu的debugserver, 所以需要preLanuchTask, 真实硬件调试可以不需要 + "preLaunchTask":"zephyr_debugserver", + }, + ] +} \ No newline at end of file diff --git a/vscode/.vscode/tasks.json b/vscode/.vscode/tasks.json new file mode 100644 index 0000000..75453b4 --- /dev/null +++ b/vscode/.vscode/tasks.json @@ -0,0 +1,105 @@ +{ + "options": { + "env": { + // 定义你的目标开发板 + "ZEPHYR_BOARD": "qemu_cortex_a53", + // 定义你的应用所在目录 + "ZEPHYR_APPLICATION": "${workspaceFolder}/../zephyr/samples/subsys/ipc/openamp_qemu_cortexa53", + } + }, + "tasks": [ + // 调用ninja 构建zephyr应用 + { + "type": "shell", + "label": "Zephyr 构建", + "command": "ninja", + "args": [ + ], + "options": { + "cwd": "${workspaceFolder}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + } + // 清楚Zephyr的目标文件,如.o, .a等等 + { + "type": "shell", + "label": "Zephyr 清除", + "command": "ninja", + "args": [ + "clean" + ], + "options": { + "cwd": "${workspaceFolder}" + }, + "problemMatcher": [ + ], + } + // 调用menuconfig 配置Zephyr + { + "type": "shell", + "label": "Zephyr Menuconfig", + "command": "ninja", + "args": [ + "menuconfig" + ], + "options": { + "cwd": "${workspaceFolder}" + }, + "problemMatcher": [ + ], + "detail": "Zephyr menuconfig" + } + //清楚所有工程文件 + { + "type": "shell", + "label": "Zephyr清除所有工程文件", + "command": "rm -r *", + "options": { + "cwd": "${workspaceFolder}" + }, + "problemMatcher": [ + ], + } + // Zephyr Cmake Configuration + { + "type": "shell", + "label": "Zephyr 配置", + "command": "cmake", + // cmake的额外参数在此添加 + "args": [ + "-GNinja", // 使用Ninja作为构建后端,Ninja比makefile速度更快 + "-DBOARD=$ZEPHYR_BOARD", + "$ZEPHYR_APPLICATION", + ], + "options": { + "cwd": "${workspaceFolder}" + }, + "problemMatcher": [ + ], + } + // 通过ninja debugserver, 调用qemu开始调试 + { + "type": "shell", + "label": "zephyr_debugserver", + "command": "ninja", + // cmake的额外参数在此添加 + "args": [ + "debugserver", + ], + //必须为true, 否则会阻塞gdb的运行 + "isBackground": true, + "options": { + "cwd": "${workspaceFolder}" + }, + "problemMatcher": [ + ], + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/vscode/zephyr.code-workspace b/vscode/zephyr.code-workspace new file mode 100644 index 0000000..1ab4c2a --- /dev/null +++ b/vscode/zephyr.code-workspace @@ -0,0 +1,21 @@ +{ + "folders": [ + { + "path": "zephyr" + }, + { + "path": "build" + }, + { + "path": "modules/lib/open-amp" + }, + { + "path": "modules/hal/libmetal" + } + ], + "settings": { + "C_Cpp.default.compileCommands": "${workspaceFolder}/../build/compile_commands.json", + "C_Cpp.default.cStandard": "c99", + "C_Cpp.default.cppStandard": "c++11", + } +} \ No newline at end of file -- Gitee