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

Fixes debugging, flashing, updates docs and note-c #16

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
20 changes: 17 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"twxs.cmake",
"ms-python.python",
"ms-vscode.vscode-serial-monitor",
"shardulm94.trailing-spaces",
"trond-snekvik.devicetree"
"trond-snekvik.devicetree",
"marus25.cortex-debug",
"marus25.cortex-debug-dp-stm32l4"
],
"settings": {
"devicetree.defaultBoard": "swan_r5"
Expand All @@ -25,8 +26,21 @@
"--privileged"
],

// TODO: Uncomment if you are using Linux and want to use the native USB debugger
// "mounts": [
// {
// "type": "bind",
// "source": "/dev/bus/usb",
// "target": "/dev/bus/usb"
// }
// ],

"workspaceMount": "source=${localWorkspaceFolder},target=/workdir/note-zephyr,type=bind,consistency=cached",
"workspaceFolder": "/workdir/note-zephyr",

"onCreateCommand": "bash -i ${containerWorkspaceFolder}/.devcontainer/onCreateCommand.sh"
"onCreateCommand": "bash -i ${containerWorkspaceFolder}/.devcontainer/onCreateCommand.sh",

"appPort": [
"3333:3333"
]
}
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ updates:
- package-ecosystem: gitsubmodule
schedule:
interval: "daily"
directory: "/note-c"
directory: /
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "note-c"]
path = note-c
url = ../note-c.git
url = https://github.com/blues/note-c.git
branch = master
2 changes: 1 addition & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${config:zephyr_base}/build/zephyr/include/**",
"${workspaceFolder}/build/zephyr/include/**",
"${config:zephyr_base}/include/zephyr/**"
],
"defines": [],
Expand Down
12 changes: 12 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"recommendations": [
"ms-vscode.cpptools",
"ms-vscode.cmake-tools",
"twxs.cmake",
"ms-python.python",
"ms-vscode.vscode-serial-monitor",
"trond-snekvik.devicetree",
"marus25.cortex-debug",
"marus25.cortex-debug-dp-stm32l4"
]
}
118 changes: 42 additions & 76 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,88 +1,54 @@
{
// 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
// Valid `device` names are listed here: https://www.segger.com/supported-devices/jlink/st/stm32wl
"version": "0.2.0",
"inputs": [
{
"id": "selectBoard",
"type": "pickString",
"description": "Select the target board",
"options": [
"swan_r5",
],
"default": "swan_r5"
}
],
"configurations": [
{
"name": "Swan Debug (Container)",
"type": "cppdbg",
"name": "Debug (Local)",
"type": "cortex-debug",
"request": "launch",
"program": "${workspaceFolder}/build/zephyr/zephyr.elf",
"args": [],
"cwd": "${config:zephyr_base}",
"MIMode": "gdb",
"miDebuggerPath": "arm-zephyr-eabi-gdb",
"miDebuggerServerAddress": ":3333",
"useExtendedRemote": true,
"debugServerPath": "openocd",
"debugServerArgs": "-s ${config:zephyr_sdk_path}/sysroots/x86_64-pokysdk-linux/usr/share/openocd/scripts -s ${config:zephyr_base}/boards/${config:vendor}/${config:board}/support -f openocd.cfg",
"serverStarted": "Listening on port [0-9]+ for gdb connections",
"filterStderr": true,
"filterStdout": false,
"launchCompleteCommand": "None",
"postRemoteConnectCommands": [
{
"description": "Hard Reset and Immediately Halt",
"text": "monitor reset halt",
"ignoreFailures": false
},
{
"description": "Flush Internal Register Cache",
"text": "flushregs",
"ignoreFailures": false
},
{
"description": "Shutdown GDB Server on GDB Detach",
"text": "monitor [target current] configure -event gdb-detach { shutdown }",
"ignoreFailures": false
},
"device": "${input:selectBoard}",
"rtos": "Zephyr",
"cwd": "${workspaceFolder}",
"executable": "${workspaceFolder}/build/zephyr/zephyr.elf",
"serverpath": "${config:zephyr_sdk_path}/sysroots/${config:zephyr_sdk_arch}-pokysdk-linux/usr/bin/openocd",
"runToEntryPoint": "main",
"servertype": "openocd",
"interface": "swd",
"configFiles": [
"${workspaceFolder}/tools/openocd/${input:selectBoard}.cfg"
],
"gdbPath": "${config:zephyr_sdk_path}/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb",
"postLaunchCommands": [
"monitor reset halt",
"maintenance flush register-cache",
],
"stopAtConnect": false,
"logging": {
"exceptions": true,
"engineLogging": false,
"moduleLoad": true,
"programOutput": true,
"trace": true,
"traceResponse": false
}
},
{
"name": "Swan Debug (External)",
"type": "cppdbg",
"name": "Debug (External)",
"type": "cortex-debug",
"request": "launch",
"program": "${workspaceFolder}/build/zephyr/zephyr.elf",
"args": [],
"cwd": "${config:zephyr_base}",
"MIMode": "gdb",
"miDebuggerPath": "arm-zephyr-eabi-gdb",
"miDebuggerServerAddress": "host.docker.internal:3333",
"useExtendedRemote": true,
"filterStderr": true,
"filterStdout": false,
"postRemoteConnectCommands": [
{
"description": "Hard Reset and Immediately Halt",
"text": "monitor reset halt",
"ignoreFailures": false
},
{
"description": "Flush Internal Register Cache",
"text": "flushregs",
"ignoreFailures": false
}
"device": "${input:selectBoard}",
"rtos": "Zephyr",
"executable": "${workspaceFolder}/build/zephyr/zephyr.elf",
"cwd": "${workspaceFolder}",
"servertype": "external",
"runToEntryPoint": "main",
"gdbTarget": "host.docker.internal:3333",
"gdbPath": "${config:zephyr_sdk_path}/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb",
"postLaunchCommands": [
"monitor reset halt",
"maintenance flush register-cache",
],
"stopAtConnect": false,
"logging": {
"exceptions": true,
"engineLogging": false,
"moduleLoad": true,
"programOutput": true,
"trace": true,
"traceResponse": false
}
}
},
]
}
12 changes: 4 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
// For a list of supported boards, run the "Zephyr: List Boards" task.
"board":"swan_r5",

// Update the `vendor` value to the vendor of the board you wish to target.
// This value is used to locate the board support files during debugging.
// If you are unsure of the vendor, you can find it in the `boards` folder
// of the Zephyr base directory.
"vendor":"blues",

// If necessary, update the value of `zephyr_base` to match your
// environment. The value provided has been selected based on the
// instructions provided by the Zephyr Project regarding tool
Expand All @@ -17,10 +11,12 @@
// https://docs.zephyrproject.org/latest/develop/west/config.html#built-in-configuration-options
"zephyr_base":"/workdir/zephyr",

// If necessary, update the value of `zephyr_sdk_path` to match your
// If necessary, update the value of `zephyr_sdk_path`, `zephyr_sdk_arch`, and `zephyr_sdk_os` to match your
// environment. The value provided has been selected based on the
// instructions provided by the Zephyr Project regarding tool
// installation, see:
// https://docs.zephyrproject.org/latest/develop/getting_started/index.html#install-zephyr-sdk
"zephyr_sdk_path": "/usr/local/zephyr-sdk-0.16.3",
"zephyr_sdk_path": "/opt/toolchains/zephyr-sdk-0.16.9",
"zephyr_sdk_arch": "aarch64", // aarch64, arm, x86_64
"zephyr_sdk_os": "linux", // linux, windows, macos
}
82 changes: 48 additions & 34 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "2.0.0",
"tasks": [
{
"label": "Zephyr: Build Example Application",
"label": "Zephyr: Build",
"type": "shell",
"problemMatcher": [
"$gcc"
Expand All @@ -14,68 +14,54 @@
"isDefault": true
},
"command": [
"west build --board ${config:board} --pristine=always ${workspaceFolder}/examples/${input:project}"
]
"west build --board ${input:board} --pristine=always ${input:app_dir}"
],
"detail": "Builds the project"
},
{
"label": "Zephyr: Rebuild Example Application",
"label": "Zephyr: Rebuild",
"type": "shell",
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build"
"kind": "build",
"isDefault": true
},
"command": [
"west build --board ${config:board} ${workspaceFolder}/examples/${input:project}"
]
"west build --board ${input:board} --pristine=auto ${input:app_dir}"
],
"detail": "Rebuilds the project"
},
{
"label": "Zephyr: Flash Firmware (Container)",
"label": "Zephyr: Flash Firmware",
"type": "shell",
"problemMatcher": [],
"command": [
"west flash"
]
],
"detail": "Flashes firmware to a board"
},
{
"label": "Zephyr: Flash Firmware (External)",
"type": "shell",
"problemMatcher": [],
"command": [
"{ echo \"reset halt; program {${hostWorkspaceFolder}/build/zephyr/zephyr.elf} verify reset; sleep 0; exit;\" >&3; cat <&3-; } 3<> /dev/tcp/host.docker.internal/4444"
]
},
{
"label": "Zephyr: Rebuild and Flash Firmware (Container)",
"type": "shell",
"problemMatcher": [],
"dependsOn": [
"Zephyr: Rebuild Application",
"Zephyr: Flash Firmware (Container)"
],
"dependsOrder": "sequence"
},
{
"label": "Zephyr: Rebuild and Flash Firmware (External)",
"type": "shell",
"problemMatcher": [],
"dependsOn": [
"Zephyr: Rebuild Application",
"Zephyr: Flash Firmware (External)"
"{ echo \"reset halt; program build/zephyr/zephyr.elf verify reset; sleep 0; exit;\" >&3; cat <&3-; } 3<> /dev/tcp/host.docker.internal/4444"
],
"dependsOrder": "sequence"
"detail": "Flashes firmware to a board via the external programmer"
},
{
"label": "Zephyr: List Boards",
"type": "shell",
"problemMatcher": [],
"command": [
"west boards"
]
],
"detail": "Lists all available boards"
},
{
"label": "Zephyr: Menu Config",
"label": "Zephyr: Menuconfig",
"type": "shell",
"options": {
"cwd": "${workspaceFolder}/build",
Expand All @@ -87,8 +73,21 @@
"problemMatcher": [],
"command": [
"ninja menuconfig"
]
}
],
"detail": "Opens the Zephyr menuconfig"
},
{
"label": "Zephyr: Generate SBOM",
"type": "shell",
"command": "west spdx --init -d build && west build -b ${input:board} ${input:app_dir} -- -DCONFIG_BUILD_OUTPUT_META=y && west spdx -d build && echo 'SBOM generated successfully in build/spdx/' && ls -la build/spdx/",
"group": "build",
"problemMatcher": [],
"presentation": {
"reveal": "always",
"panel": "new"
},
"detail": "Builds the project with metadata enabled and generates SPDX SBOM documents"
},
],
"inputs": [
{
Expand All @@ -97,5 +96,20 @@
"default": "blinky",
"type": "promptString"
},
{
"id": "board",
"type": "pickString",
"description": "Select the target board",
"options": [
"swan_r5",
],
"default": "swan_r5"
},
{
"id": "app_dir",
"type": "promptString",
"description": "Application directory (e.g. 'app', 'examples/blinky')",
"default": "app"
}
]
}
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,12 @@ This will create a new workspace (`my-workspace`) with the `note-zephyr` project

### VSCode

You can also use VSCode & a Dev Container to develop with this module.
You can also use VSCode with or without a devcontainer to develop with this module.
`git clone` the repository and open the directory in VSCode.

You'll then want to open the directory in a Dev Container, which will allow you to use the Zephyr SDK and other dependencies (without having to install them on your host machine).

Opening the directory in VSCode, you should see a popup asking if you want to open the folder in a Dev Container.
Opening the directory in VSCode, you should see a popup asking if you want to open the folder in a devcontainer.
Click `Open in Container`.

You can then build an example application by opening the command palette and selecting `Zephyr: Build Example Application`.
You can then build an example application by opening the command palette and selecting `Zephyr: Build` and specifying the board you want to build for, e.g. `swan_r5`, then the example you want to build, e.g. `blinky`.

See [docs/development.md](docs/development.md) for more information about the Dev Container.
See the [docs](docs/README.md) for more information about the Dev Container.
Loading