What is the Yocto Project?

Building a Linux distribution from scratch is complex without a build system. Developers have to manually manage hundreds of dependencies, often resulting in conflicts and errors that make the task tedious and frustrating, not to mention the fact that maintaining consistent versions across teams becomes impossible without automation, which is why build systems such as the Yocto project are essential for obtaining reliable, reproducible versions.

What is The Yocto Project?

What is the Yocto Project?

Yocto Project is an open-source initiative under the Linux Foundation; it provides a robust framework for developing custom Linux-based embedded systems, independent of hardware architectures such as ARM, MIPS, PowerPC, and x86/x86-64. 

Yocto is built on the OpenEmbedded build system and cross-compilation environment. Since 2003, it has gained wide support within the embedded development community, allowing for the creation of custom embedded Linux distributions across various hardware platforms.

The Yocto Project: main components

The Yocto Project is structured around several components, each designed to streamline and automate the building of embedded Linux systems.

Yocto layers

Metadata: The layer model

Yocto organizes its build configuration and recipes (metadata) into layers that keep software builds isolated, organized, and modular. It is a collection of configuration files (.conf), recipes (.bb and .bbappend), classes (.bbclass), and include files (.inc).

Once parsed, each recipe gets its own “kitchen,” a dedicated working directory containing only the dependencies the recipe needs. This separation ensures that libraries, headers, and dependencies don’t unexpectedly overlap, reducing “dependency hell”, and making debugging simpler by having the sources, logs of all tasks, dependencies, and artifacts of the build grouped together and isolated from the rest of the build.

Bitbake: The Yocto’s build engine

Yocto uses Bitbake, a powerful tool responsible for parsing and executing metadata, which includes instructions for fetching, configuring, building, and packaging software. Bitbake is a core component of the Yocto Project; it reads and processes the “recipes,” as well as various configuration files, to manage every aspect of the build, ensuring that all required tasks are scheduled and all dependencies are handled correctly.

Poky: The blueprint

Yocto provides a reference distribution called Poky, which is a complete build environment that combines Bitbake, the OpenEmbedded build framework, and a set of core layers that include essential recipes and configurations, providing a basic setup for building custom Linux distributions.

It’s a model that illustrates the power of the Yocto project by showing how the layers and Bitbake enable highly modular and reproducible builds, supporting everything from small single-board computers to complex, customized embedded systems.

Fine-Grained Control with Yocto Packages

Mainstream Linux distributions are typically composed of pre-built binary packages. In the Yocto Project, packages similarly serve as the fundamental software units, but with a key difference: each package is built from source, managed, and deployed specifically for the embedded Linux environment.

Every software component is defined by a recipe, and after compilation, it is split into separate packages, like libraries, headers, or debugging symbols, offering fine-grained control over what is included in the final image. This packaging approach is especially valuable in embedded systems, where storage and resource constraints call for highly optimized, minimal deployments.

Image: Building the final product

Image is a top-level recipe; building an image creates an entire Linux distribution (compiler, tools, libraries, BSP (bootloader, kernel, root filesystem, init manager, etc.). An image inherits the core-image class or the image class itself. It defines a set of packages to be installed in an image using soft assignment operators, including the core-boot package group that defines a set of recipes/packages that are required to boot an image.

Yocto build workflow: layer parsing, fetching, and packaging

At the very beginning, Bitbake parses the layers listed in the bblayers.conf file, identifying the recipes and configuration files to be considered. Layer priorities manage recipe priority, building a dependency map based on build-time and run-time dependency directives.

The construction of each layer begins with the retrieval of the source code. Bitbake supports git, svn, https, ftp, and local file fetchers. Patches are then applied, aligning the source files with the target’s specifications. Then, during the configuration task, Bitbake sets up cross-compilation options, specifying architecture flags and sysroot paths adapted to the target. Compilation follows, with the recipe isolated in its working directory and dependencies precisely managed by the sysroot.

Finally, the files are packaged and ready for installation. As each recipe can generate a set of packages, it’s the image recipe that decides which packages to install in the final image root filesystem.

Yocto build workflow

Targeting hardware with Yocto: the role of BSP layers

When building an embedded Linux distribution, the build artifacts must be adapted to the chosen hardware by specifying the essential configurations, drivers, kernel modifications, and hardware-specific packages required for this hardware.

This metadata is provided to the build in the form of a BSP (Board Support Package) layer. This layer is added to the build environment and allows Bitbake to build an image that aligns with the architecture and peripherals of the target hardware. This layer is provided by the hardware manufacturer. In most cases, the targeted hardware does not quite match the one supported by the official BSP (an evaluation board in general), so adjustment work is to be done on the BSP layer to support this specific hardware.

So, why should you choose Yocto?

The Yocto Project differentiates itself from other build systems, such as Buildroot or traditional package managers, through its highly modular and customizable architecture, which emphasizes a comprehensive approach to embedded Linux development.

Unlike simpler systems that primarily focus on generating a static root filesystem from precompiled binaries, Yocto provides a flexible framework utilizing layers and recipes to finely tune every aspect of the build process, from kernel configurations and bootloader settings to user-space applications and package management. This complexity allows for precise control over dependencies, versioning, and build options, facilitating the creation of highly optimized images tailored for specific hardware platforms and use cases.

Accelerate your embedded Linux development with Welma Yocto Linux

Welma Yocto Linux is a software solution designed to streamline the development process for clients seeking customized Yocto builds tailored to their specific hardware requirements. By leveraging Welma, device makers can accelerate their development cycles through automated build configurations, significantly reducing the time and effort required to set up and optimize their embedded Linux systems.

Welma Yocto Linux incorporates essential features such as A/B update mechanisms for seamless system upgrades, alongside enhanced security measures including secure updates, secure boot, and secure storage, ensuring that client applications not only perform optimally but also adhere to industry standards for security and reliability. With our Linux distribution, device manufacturers benefit from a comprehensive framework that simplifies the complexities of Yocto, enabling them to focus on innovation while confidently deploying their customized solutions. 

Discover more from The Embedded Kit

Subscribe now to keep reading and get access to the full archive.

Continue reading