VS Code + DevContainer¶
Here’s a guide for using Visual Studio Code (VS Code) to develop with Yocto in a containerized environment. If your host is already a Yocto-supported Linux distribution, you can also build natively — see Native Build Environment.
Linux distribution
When using a containerized environment for building yocto, the host does not have to be a Yocto-supported distro.
Requirements¶
Linux system (Ubuntu-based distribution recommended)
Docker Engine installed and running (see Docker Engine Installation Guide)
VS Code installed (see VS Code Setup Guide)
VS Code Dev Containers extension
Setup¶
1. Check out the BSP as described in the BSP Setup page.
2. Open the BSP root folder with VS Code.
Starting from the
scarthgapbranch, VS Code should directly prompt you to reopen the current directory in a Container. If that is the case, skip to step 4.
3. Create the folder:
.devcontainer
4. Add these files inside .devcontainer:
Dockerfile:
Keep it as it is.
devcontainer.json:
Replace the
<YOCTO_VERSION>placeholder with the codename of the Yocto version used.Replace the
<SUPPORTED_DISTRO>placeholder with a supported Ubuntu Version of the used Yocto version.
Shared Yocto files
This setups uses shared docker volumes for Yocto cache files. For each Yocto release (e.g. mickledore, scarthgap) a different volume needs to be used to avoid cache corruption between versions.
5. In VS Code reopen the folder in a Container. If not prompted, search for Dev Container: Reopen in Container command using strg + shift + P.
The container is setup automatically to be able to build Yocto. Furthermore it configures VS Code and the environment to develop with Yocto more easily. Key aspects include:
Supported Linux distribution for building with Yocto
Shared Yocto downloads and sstate-cache in docker volume.
Yocto Project BitBake VS Code Extension
Pre-configured VS Code for Yocto Development
Finally you can set up the build directory and build images as described on the Building Images page.
Yocto Project BitBake Extension¶
The Dev Container comes with the Yocto Project BitBake VS Code Extension preinstalled. It is configured to automatically detect the build folder by the name build-karo. The extension provides a GUI to manage, build and develop recipes.
A devtool workspace can be created to directly edit a recipe’s source and also create patches automatically. For more information on how to use the Yocto Project Extension see Yocto Project BitBake.
The Yocto Project extension is configured to use
build-karoas the build directory. If needed change it in the extension settings. It is also possible to define multiple build-directories, see official documentation.When creating a new devtool workspace via the Yocto Project extension, skip SDK toolkit configuration for now, as it may cause errors in this setup.
If a build fails while using a devtool workspace, try adding the following in the
local.conf:PACKAGE_DEBUG_SPLIT_STYLE = "debug-without-src"