Yocto Project
This article introduces the Yocto project.
Yocto Project
The Yocto Project is an open source collaboration project that provides templates, tools and methods to help you create custom Linux-based systems for embedded products regardless of the hardware architecture. It was founded in 2010 as a collaboration among many hardware manufacturers, open-source operating systems vendors, and electronics companies to bring some order to the chaos of embedded Linux development.
Why use the Yocto Project? It’s a complete embedded Linux development environment with tools, metadata, and documentation - everything you need. The free tools are easy to get started with, powerful to work with (including emulation environments, debuggers, an Application Toolkit Generator, etc.) and they allow projects to be carried forward over time without causing you to lose optimizations and investments made during the project’s prototype phase. The Yocto Project fosters community adoption of this open source technology allowing its users to focus on their specific product features and development.
The Yocto Project provides resources and information catering to both new and experienced users, and includes core system component recipes provided by the OpenEmbedded project. The Yocto Project also provides pointers to example code built demonstrating its capabilities. These community-tested images include the Yocto Project kernel and cover several build profiles across multiple architectures including ARM, PPC, MIPS, x86, and x86-64. Specific platform support takes the form of Board Support Package (BSP) layers for which a standard format has been developed. The project also provides an Eclipse IDE plug-in and a graphical user interface to the build system called Hob.
The Yocto Project Development Environment:
The following figure shows the temporary file structure created on your host system when the build occurs:
Poky
Poky is a reference distribution of the Yocto Project. It contains the OpenEmbedded Build System (BitBake and OpenEmbedded Core) as well as a set of metadata to get you started building your own distro. To use the Yocto Project tools, you can download Poky and use it to bootstrap your own distribution. Note that Poky does not contain binary files – it is a working example of how to build your own custom Linux distribution from source.
OpenEmbedded
OpenEmbedded is a software framework used for creating Linux distributions aimed for, but not restricted to, embedded devices. The build system is based on BitBake recipes, which behave like Gentoo Linux ebuilds.
BitBake
BitBake is a build engine that follows recipes in a specific format in order to perform sets of tasks. BitBake is a core component of the Yocto Project.
BitBake is a make-like build tool with the special focus of distributions and packages for embedded Linux cross compilation although it is not limited to that. It is inspired by Portage, which is the package management system used by the Gentoo Linux distribution. BitBake existed for some time in the OpenEmbedded project until it was separated out into a standalone, maintained, distribution-independent tool. BitBake is co-maintained by the Yocto Project and the OpenEmbedded project.
BitBake recipes specify how a particular package is built. It includes all the package dependencies, source code locations, configuration, compilation, build, install and remove instructions. It also stores the metadata for the package in standard variables.
The BitBake recipes consist of the source URL (http, https, ftp, cvs, svn, git, local file system) of the package, dependencies and compile or install options. During the build process they are used to track dependencies, performing native or cross-compilation of the package and package it so that it is suitable for installation on the local or a target device. It is also possible to create complete images consisting of a root file system and kernel. As a first step in a cross-build setup, the framework will attempt to create a cross-compiler toolchain suited for the target platform.
Example
bitbake-layers show-recipes
bitbake-layers show-recipes "<image_name>"
chenwx@chenwx:~/repo/poky/build$ bitbake-layers show-recipes *image*
NOTE: Starting bitbake server...
WARNING: Host distribution "linuxmint-20.1" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
Loading cache: 100% |################################################################################| Time: 0:00:00
Loaded 1433 entries from dependency cache.
Summary: There was 1 WARNING message shown.
=== Matching recipes: ===
build-appliance-image:
meta 15.0.0
core-image-base:
meta 1.0
core-image-clutter:
meta 1.0
core-image-full-cmdline:
meta 1.0
core-image-kernel-dev:
meta 1.0
core-image-minimal:
meta 1.0
core-image-minimal-dev:
meta 1.0
core-image-minimal-initramfs:
meta 1.0
core-image-minimal-mtdutils:
meta 1.0
core-image-rt:
meta unknown (skipped)
core-image-rt-sdk:
meta unknown (skipped)
core-image-sato:
meta 1.0
core-image-sato-dev:
meta 1.0
core-image-sato-ptest-fast:
meta 1.0
core-image-sato-sdk:
meta 1.0
core-image-sato-sdk-ptest:
meta 1.0
core-image-testmaster:
meta 1.0
core-image-testmaster-initramfs:
meta 1.0
core-image-tiny-initramfs:
meta 1.0
core-image-weston:
meta 1.0
core-image-x11:
meta 1.0
ovmf-shell-image:
meta 1.0
xcb-util-image:
meta 0.4.0
core-image-minimal
chenwx@chenwx:~/repo/poky$ ff *core-image-minimal*
./meta/recipes-core/images/core-image-minimal.bb
./meta/recipes-core/images/core-image-minimal-dev.bb
./meta/recipes-core/images/core-image-minimal-initramfs.bb
./meta/recipes-core/images/core-image-minimal-mtdutils.bb
bitbake -c compile core-image-minimal
References
- Yocto Project
- Yocto Project Documentation
- Yocto Project Overview and Concepts Manual
- OpenEmbedded Official Site
- Yocto Project Cheatsheet
- BitBake Cheat Sheet