VSCodeでZephyrRTOSのbuild/debugする設定例

2024/04/17に公開

概ねこんな感じの設定にしておくと比較的ツブシ効くのではなかろうか。(PlatformIO使わない派 && WSL2を使う設定)

//settings.json
{
    "board": "nucleo_f302r8",
    "pristine": "auto",
}
//tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "West Build",
            "type": "shell",
            "group": {
                    "kind": "build",
            },
            "command": "west",
            "args": [
                    "build",
                    "-p",
                    "${config:pristine}",
                    "-b",
                    "${config:board}"
            ],
            "problemMatcher": [
                    "$gcc"
            ]
        },
        {
            "label": "West Flash",
            "type": "shell",
            "command": "west",
            "args": [
                    "flash"
            ],
            "problemMatcher": [
                    "$gcc"
            ]
        }
    ],
}
//launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/build/zephyr/zephyr.elf",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "/opt/zephyr-sdk-0.16.4/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb",
            "miDebuggerServerAddress": "localhost:3333",
            "debugServerPath": "sh",
            "debugServerArgs": "-c \"cd ${workspaceFolder} ; west debugserver\"",
            "setupCommands": [],
            "preLaunchTask": "West Build",
        },
    ]
}

ミソはdebugServerPath, debugServerArgsのあたり。

Discussion