Introduction to the Yocto build system

The Yocto build system allows creating custom Linux distributions for embedded systems. This article will briefly introduce its concepts and notable features. If you want to find out more, the article also links to more in-depth comparisons with similar build systems.

Yocto key terms

The Yocto Project is a workgroup initiated by the Linux Foundation in 2010. Its goal is to make it easier to develop Linux-based systems for embedded products. Its main product is an open source build system for creating custom embedded Linux distributions. Since 2011, its core is jointly maintained with the OpenEmbedded Project.

Yocto is the umbrella term representing the whole project, its organization and the technical ecosystem it consists of. The term Poky refers to Yocto’s example Linux distribution. It is a starting point for your own use of Yocto to create a custom distribution for your hardware target.

Bitbake finally is the name of a build tool written in Python. The tool parses recipe files and performs the various build tasks. It caches both downloads and build results in order to speed up repeated builds. While the first full build of a system image can take several hours, the following build times easily collapse down to minutes.

Structure of the Yocto build system

A typical Yocto recipe file
A typical Yocto recipe file

The Yocto build system basically comprises recipes, layers, and configuration files that are parsed by the Bitbake tool to produce a Linux file system image that can later be run on the target hardware.

Recipes are the most common file type in a Yocto build description. They contain instructions on how to configure, compile and deploy a given piece of software. Recipes also contain the location of the source code. This location can either be a static release archive, or a reference to a Git repository. Custom modifications to the sources themselves or the build process can be provided in form of patches. To minimize repetition for common tasks in recipes, such behaviour is encapsulated in recipe class files, from which recipes can inherit.

Layers split recipes into four logical groups. In each, different parts of the build result are configured:

  1. The Base layer contains development tools and recipe classes for common behavior needed by most recipes. It is maintained by OpenEmbedded.
  2. The Software layer holds recipes for libraries and applications, ranging from server daemons to GUI toolkits.
  3. The Distribution layer contains recipes for generating system images, as well as definition of package groups.
  4. Finally, the Machine (BSP) layer bundles device-specific recipes. This includes not only drivers, but also overrides to software or distribution recipes.

Currently, the OpenEmbedded Layer Index lists a total of 269 layers, containing thousands of recipes.

Configuration files  contain build and user specific information. At a minimum, a user must select which layers to use, the machine configuration and the name of a recipe to be built (usually a system image).

Notable features

What sets Yocto apart from, say, a build environment based on Buildroot? To answer this question one may point to Yocto’s extensive tooling around the build system allows its users to tailor the build result to match exactly her needs. By changing a single line of configuration, you can support many different hardware platforms. Many hardware vendors have created the required board support packages (BSP).

Intelligent caching of build results is another key benefit of using the Yocto build system. While the first build takes several hours for fetching and compiling source code, all following builds only compile those software packages that did change in the meantime.

Further reading

The article Build custom embedded Linux distributions with the Yocto Project guides you through your first build with Yocto.

If you seek more advanced material: the blog post on an plenary comparison of two platforms Deciding between Buildroot and Yocto summarizes their similarities and differences. As a bonus, the talk’s video recording and slides are available online as well.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.