Yocto Project: Components, Use Cases, and a Quick Tutorial

Igal Zeifman
Igal Zeifman

8  min read | min read | 01/08/2023

What Is the Yocto Project

The Yocto Project is an open-source initiative that enables developers to create custom Linux distributions, commonly used for embedded systems and IoT devices. It provides a flexible framework that simplifies the process of developing and maintaining custom Linux distributions.

The Yocto Project is not a Linux distribution itself, but a tool to create one. It’s built from the ground up to support embedded systems development, providing developers with a high degree of control over their software stack. This is particularly advantageous for developers working on devices with specific hardware requirements or performance constraints.

The Yocto Project supports numerous hardware architectures, including x86, ARM, MIPS, and PowerPC. Its standardized build system and extensive cross-compiling support make it an ideal choice for multi-platform development.

Yocto Project Architecture and Components

Here are the primary components that make up the Yocto project framework.

BitBake

At the heart of the Yocto Project is BitBake, a powerful task executor and scheduler. BitBake reads and interprets metadata, then executes the necessary tasks to build a Linux distribution, such as compiling source code and packaging software.

OpenEmbedded-Core

The OpenEmbedded-Core (OE-Core) is a layer in the Yocto Project that provides the basic functionality for building a Linux distribution. It contains essential metadata, such as machine configurations, distro configurations, and class definitions.

Layers

Layers are a fundamental aspect of the Yocto Project’s architecture. They allow developers to organize and separate different parts of a Linux distribution, such as system software, applications, and device drivers.

Poky

Poky serves as the reference system of the Yocto Project. It’s a pre-configured build environment that includes BitBake, OE-Core, and a selection of metadata to help developers get started with the Yocto Project.

Metadata

Metadata in the Yocto Project describes everything needed to build a Linux distribution. This includes information about software packages, configurations, dependencies, and build instructions.

Recipes

Recipes are one of the most critical types of metadata in the Yocto Project. A recipe describes how to build a software package, including where to fetch the source code, how to configure and compile it, and how to package the resulting binaries.

Toolchains

In the context of the Yocto Project, a toolchain refers to a set of tools used to compile, link, and debug software. The Yocto Project can generate custom toolchains tailored to specific hardware architectures and software configurations.

Use Cases and Applications of the Yocto Project

The Yocto Project is commonly used for:

  • Customized Linux distribution development: Yocto provides developers with the tools and resources they need to build a Linux distribution from scratch, tailored to their specific requirements. This is particularly useful in scenarios where commercial Linux distributions are either too bloated or lack the necessary features.
  • Embedded systems development: Embedded systems have unique requirements, such as specific hardware compatibility, performance constraints, and limited resources. The Yocto Project supports these needs by supporting numerous hardware architectures and enabling minimal footprint, highly optimized Linux distributions.
  • IoT devices: These have similar constraints as embedded systems, such as limited resources and specific performance requirements. The Yocto Project’s ability to create lightweight, customized Linux distributions makes it an excellent choice for IoT device development.
  • Automotive systems: The automotive industry has specific requirements for software systems, such as real-time capabilities, robustness, and security. Yocto can support these environments with its flexible architecture and advanced customization.

Benefits and Challenges

Let’s start with the benefits:

  1. Exceptional flexibility and customizability: Enables the creation of unique Linux distributions tailored to project-specific needs. It lets you include or exclude individual software components to shape the operating system according to the specific hardware or application requirements.
  2. In-depth customization: Goes beyond software-level customizability by providing control over the configuration of the Linux kernel itself. This granular control is beneficial for projects with unique hardware specifications or distinct performance requirements.
  3. Adaptability: Allows for quick adjustments to changing project requirements. Users can iterate on their designs, adding or removing software components as the project’s needs evolve, contributing to the project’s success.
  4. Scalability: Can handle projects of any size, from single embedded device applications to large-scale deployments involving thousands of devices, providing a reliable platform for growth.
  5. Extensive hardware support: Works with a wide array of processors and devices, including ARM, x86, PowerPC, and MIPS, among others. This allows for the use of the same tool to create customized Linux distributions for diverse hardware architectures, enhancing development efficiency.
  6. Complex software stacks: Can manage intricate software stacks and applications, from simple web servers to sophisticated IoT devices, with all the necessary tools for complex development tasks.
  7. Community support: Backed by an active developer community that contributes to its evolution and offers valuable resources for new users. This community support plays a critical role in navigating the learning curve associated with the Yocto Project.
  8. Compatibility and interoperability: Designed to work seamlessly with a wide variety of open-source projects. This compatibility simplifies the development process and allows users to leverage the capabilities of other projects.

And here are some potential challenges:

  1. Learning curve: Despite its many benefits, the Yocto Project does come with a steep learning curve. Its complexity and flexibility mean that it can take some time to become comfortable with its usage.
  2. Time and resource intensive: Building a custom Linux distribution from scratch is not a trivial task. It requires a deep understanding of Linux and embedded systems, as well as significant time to configure and test your distribution.
  3. The complexity of customization: While the customization offered by the Yocto Project is one of its strengths, it can also be a source of complexity. You need to be careful when customizing your distribution, as changes can have unintended side effects. It requires careful planning and testing to ensure that your custom distribution works as expected.

Yocto Project Quick Start Tutorial

This tutorial is abbreviated from the official Yocto quick start tutorial.

Prerequisites

Your YOCTO build host must adhere to the following requisites:

  • Minimum free disk space of 90 GB
  • Minimum of 8 GB RAM.
  • Multi-core processor is highly recommended.
  • Build host must run a supported Linux distribution:
    • Ubuntu 18.04 (LTS), 20.04 (LTS), 22.04 (LTS)
    • Fedora 36, Fedora 37
    • AlmaLinux 8.7, 9.1
    • Debian GNU/Linux 11.x (Bullseye)
    • OpenSUSE Leap 15.3, 15.4
  • Git 1.8.3.1 or newer
  • tar 1.28  or newer
  • Python 3.8.0  or newer
  • gcc 8.0  or newer
  • GNU make 4.0 or newer

In addition, you need to install some packages on your build host. See the official documentation for a command that will install the required packages on your Linux distribution.

Step 1: Cloning the Poky Repository

After getting your machine ready, you’ll need to get a clone of the Poky repository on your build host. Use the command below to clone the Poky repository:

git clone git://git.yoctoproject.org/poky

The output looks like this:

Cloning the Poky Repository

Visit the Releases wiki page, and pick a release codename, aligning with either the latest stable release or a Long Term Support release. This tutorial will use the Mickledore release.

Navigate to the poky directory and look at existing branches:

cd pokygit 
branch -a

The output looks like this:

cd poky git branch -a

Because this tutorial uses the Mickledore release, use this command to check out the Mickledore branch. This will generate a local branch labeled my-mickledore.

git checkout -t origin/mickledore -b my-mickledore

The output looks like this:
 check out the Mickledore branch

Note: You also should use git pull to regularly update your local files to remain in sync with the release branch by typing the following command in the same directory.

Step 2: Building Your Image

Follow these steps to building your operating system image:

  1. From within the poky directory, execute the oe-init-build-env environment setup script which establishes the Yocto Project’s build environment on your build host. Among several other tasks, the script generates the Build Directory, in this case called build, located in the source directory. After the execution of the script, your current working directory becomes the Build Directory.
  2. When you set up the build environment, a local configuration file named local.conf becomes accessible in the conf subdirectory of the Build Directory. This tutorial will use the default configuration, which builds a qemux86 target, suitable for emulation. By default, the RPM package manager is selected as the package manager.
  3. Run the following command to construct an OS image for the target core-image-sato:
    bitbake core-image-sato

    The output looks like this:
    bitbake core-image-sato

    Note: On Ubuntu, we need to install additional development libraries using these commands:

    sudo apt update && sudo apt install -y zstd liblz4-tool
    sudo apt install -y chrpath diffstat
  4. Lastly, upon building this specific image, you can initiate QEMU, the Quick EMUlator bundled with the Yocto Project.
    runqemu qemux86-64

    The output looks like this:
    initiate QEMU, the Quick EMUlator

When you are done, you can exit QEMU by either clicking on the shutdown icon or pressing Ctrl-C.

Step 3: Tailoring the Build for Specific Hardware

Up to this point, we built an image that is suitable only for emulation. Let’s see how to tailor your build to specific hardware by integrating a hardware layer. Layers are repositories containing sets of directives and configurations that instruct the Yocto Project on how to proceed.

To integrate a hardware layer:

  1. Find the most appropriate layer for your needs. There are many hardware layers available in the Yocto Project Source Repositories. This tutorial will add the meta-altera hardware layer, which integrates your operating system image with Intel Altera hardware.
  2. Clone the Layer: Utilize Git to make a local copy of the layer on your machine. You can place the copy at the top level of the Poky repository created earlier by running this command:
    cd pokygit clone https://github.com/kraj/meta-altera.git
  3. The hardware layer can now be found alongside other layers inside the Poky reference repository on your build host under the title meta-altera. It contains all the metadata needed to support Altera hardware.
  4. You can modify the configuration to build for a specific machine, using the MACHINE variable in the local.conf file. Let’s set this variable to cyclone5, the machine configuration for Cyclone V SoC.
  5. Finally, add your layer to the bblayers.conf file, which is found in the conf subdirectory of the Build Directory, in order to use it during your builds. You can do this with the following command:
    bitbake-layers add-layer ../meta-altera

    The output looks like this:
    bitbake-layers add-layer

Step 4: Creating Your Own Layer

In the previous section, we showed how to create a hardware integration layer based on an existing layer from the Yocto community. In some cases, you might have an application or specific set of behaviors that require a custom layer.

You can use Yocto to create your own general layer. Yocto automates layer creation by setting up a subdirectory with a layer.conf configuration file, a recipes-example subdirectory that contains an example.bb recipe, a licensing file, and a README.

The following command creates a layer named meta-mylayer in the poky directory:

cd pokybitbake-layers add-layer meta-mylayer

The output looks like this:
create a layer named in the poky directory

JUMP TO SECTION

Enter data to download case study

By submitting this form, you agree to our Privacy Policy.