Skip to content

NemesisXB/Zephyr-VSCode-Setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 

Repository files navigation

Zephyr-VSCode-Setup

Setup guide for Zephyr in VS Code

Links

Debug in VS Code (bus710)
Debug in VS Code (Simon Wijk)
Ubuntu Update Device Tree Compiler(DTC)
Fix OpenOCD gdb-attach Error

Example vscode files

launch.json

{
    // 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": "Zephyr STM32F401",
            "cwd": "${workspaceRoot}",
            "executable": "build/zephyr/zephyr.elf",
            "request": "launch",
            "type": "cortex-debug",
            "servertype": "openocd",
            "device": "STM32F401RE",
            "interface" : "swd",
            "armToolchainPath": "${HOME}/zephyr-sdk/arm-zephyr-eabi/bin",
            "gdbpath": "/usr/bin/gdb-multiarch",
            "configFiles": [
                 "/usr/share/openocd/scripts/board/st_nucleo_f4.cfg"
             ],
             "preLaunchTask": "Build"
        }
    ]

tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "SetEnv",
            "type": "shell",
            "command": "west",
            "args": [
                "config",
                "zephyr.base","${env:HOME}/zephyr/stm32f401_test/zephyr"
            ],
            "options": {
                "statusbar": {
                  "hide" : true
                }
              },
            "group": "test"
        },
        {
            "label": "Build",
            "dependsOn": [
				"SetEnv"
			],
            "type": "shell",
            "command": "west",
            "args": [
                "build",
                "-p","auto",
                "-b","nucleo_f401re",
                "--force"
            ],
            "options": 
            {
                "cwd": "${workspaceFolder}",
                "env": {
                    "ZEPHYR_TOOLCHAIN_VARIANT": "zephyr",
                    "ZEPHYR_SDK_INSTALL_DIR": "${env:HOME}/zephyr-sdk"
                }
            },
            "problemMatcher": {
                "base": "$gcc",
                "fileLocation": [
                    "absolute"
                ]
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        },
        {
            "label": "Build Verbose",
            "dependsOn": [
				"SetEnv"
			],
            "type": "shell",
            "command": "west",
            "args": [
                "-v",
                "build",
                "-p","auto",
                "-b","nucleo_f401re",
                "--force",
                "--",
                "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
            ],
            "options": 
            {
                "cwd": "${workspaceFolder}",
                "env": {
                    "ZEPHYR_TOOLCHAIN_VARIANT": "zephyr",
                    "ZEPHYR_SDK_INSTALL_DIR": "${env:HOME}/zephyr-sdk"
                }
            },
            "problemMatcher": {
                "base": "$gcc",
                "fileLocation": [
                    "absolute"
                ]
            },
            "group": "build"
        },
        {
            "label": "Clean",
            "dependsOn": [
				"SetEnv"
			],
            "type": "shell",
            "command": "west",
            "args": [
                "build",
                "-p","auto",
                "-b","nucleo_f401re",
                "-t","clean",
                "--force"
            ],
            "options": 
            {
                "cwd": "${workspaceFolder}",
                "env": {
                    "ZEPHYR_TOOLCHAIN_VARIANT": "zephyr",
                    "ZEPHYR_SDK_INSTALL_DIR": "${env:HOME}/zephyr-sdk"
                }
            },
            "group": "build"
        },
        {
            "label": "Flash",
            "dependsOn": [
				"Build"
			],
            "type": "shell",
            "command": "west",
            "args": [
                "flash"
            ],
            "options": 
            {
                "cwd": "${workspaceFolder}",
                "env": {
                    "ZEPHYR_TOOLCHAIN_VARIANT": "zephyr",
                    "ZEPHYR_SDK_INSTALL_DIR": "${env:HOME}/zephyr-sdk"
                }
            },
            "problemMatcher": {
                "base": "$gcc",
                "fileLocation": [
                    "absolute"
                ]
            },
            "group": "build",
        },
    ]
}

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "${HOME}/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc",
            "cStandard": "c99",
            "cppStandard": "c++17",
            "intelliSenseMode": "${default}",
            "compileCommands": "${workspaceFolder}/build/compile_commands.json"
        }
    ],
    "version": 4
}

Add tasks to VS Code Taskbar

Install VS Code plugin: actboy168.tasks:
Name: Tasks
Id: actboy168.tasks
Description: Load VSCode Tasks into Status Bar.
Version: 0.3.6
Publisher: actboy168
VS Marketplace Link

About

Setup guide for Zephyr in VS Code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published