WorkFlow Guide: Leveraging the power of YOCTO for Linux OS porting projects
October 02, 2018
This document is created for the community of developers working on embedded Linux applications. It will guide you through the steps of building an image for Linux distribution, using Yocto Framework.
This document is created for the community of developers working on embedded Linux applications. The purpose of the document is to guide you through the steps of building an image for Linux distribution, using the Yocto Framework.
P.S. – In order to best utilize the information in this document, the following know-how is a must:
- Familiarity with basic Linux OS operations and Admin tasks
- Understanding of the Yocto Project and OpenEmbedded Project
- Understanding of the basics of the build systems
Understanding System Requirements and the OpenEmbedded (OE) Build System:
Before we discuss the workflow, it is imperative to develop a basic understanding regarding the system requirements and OE Build System. Here are the necessary details.
a. System Requirements:
1. A Host System: Ideally a system with a minimum free disk space of 50 Gbytes that runs on any Linux distribution (i.e. Ubuntu, Fedora, CentOS, openSUSE, or Debian). Most often a native Linux machine function is used as the development host.
2. Packages for Builds: Do ensure that your host development system has the following packages (with respect to Linux Distribution – Ubuntu, Fedora, CentOS & more)
- Essentials to build image on a headless system
- Graphical and Eclipse Plug-In Extras
- OpenEmbedded Self-Test
3. Any release of the Yocto Project
b. OpenEmbedded Build System and BitBake Tool
OpenEmbedded (OE) is the build system for the Yocto Project. The central component of this build system is BitBake.
BitBake performs tasks like parsing the Metadata, Creating task lists from the Metadata and more.
The BitBake tool consists of the following functional blocks:
- User Configuration: This includes the metadata for managing the YOCTO build process. As a developer, you can define the build environment by specifying target architecture, location to store the downloaded source, and other build properties using User Configuration file.
- Metadata, Machine & Policy Configuration Layers: These layers consist of data critical for the management of the build process.
- Metadata: This layer consists of user-supplied recipe files, patches, and append files.
- Machine Configuration (BSP): This layer consists of information specific to your target architecture for which the image is being built. The information specific to the machine configuration is provided by the BSP layer of the Yocto layered architecture model.
- Distro Layer/Policy Configuration: This layer consists of data that specify the policy configurations for the specific distribution. This layer includes class files, configuration files and recipes. These recipes would include custom image recipes, distribution-specific configuration, initialization scripts.
- Source Files: These include sources such as Upstream releases, local projects, and Source Control Manager (SCMs), from where the build system downloads source files to build an image.
- Build System: This block specifies the processes during which the BitBake fetches source, applies patches, executes compilation, analyzes output for package generation, generates and tests these packages, generates images and cross-development tools.
- Package Feeds: This module consists of directories with various types of output packages in RPM, DEB or IPK format. Package feeds are used while building an image or SDK, produced by the build system. They are also used for extending or updating existing images on devices at runtime by copying and sharing them on web server.
- Images: This is an output module that manages the Linux Images created by the Build System.
- Application Development SDK: The module consists of various cross-development tools, which are built either along with the image or separately with BitBake.
Workflow for using Yocto project as a build system for Embedded Linux:
- Setup the Host System for YOCTO Build System: The host system should comply with the minimum system requirements, as mentioned before. Additionally, you should test your host build system for the following:
a. Required Packages
b. Build system is meeting the Minimal Version Requirements of Git, tar, and Python
c. If not, install Pre-Built build tools like Tarball, or
d. Build your own build tools similar to Tarball, provided your build host can run BitBake.
- Download the required version of the YOCTO release: Set up the latest Yocto Project files on your host development system by cloning a local copy of the Poky Git repository.
- Download the vendor provided meta for the BSP: Depending on the processor platform (ARM, MIPS, PowerPC, and x86), you can download the meta data for BSP provided by the specific vendor.
- Add the Vendor meta to the Yocto build system: Add the Vendor meta to your build host environment by creating a local copy of the repository. For example, meta-intel is the metadata for the Intel specific target architecture.
- Make the Build configuration changes: Check the local configuration file and make the build configuration changes by editing the bblayers.conf and local.conf files. This should be done before calling the BitBake command to initialize the build.
- Initialize the Build Environment: To define the OpenEmbedded build environment, the specific setup script on the build host is executed.
The script creates a Build Directory, which is located in the Source Directory. After that, the current working directory is set to the Build Directory. Once the build is completed, the Build Directory will have all the files created during the build.
- Start Building the image: Now the YOCTO IDE/ framework has received all the commands necessary for it to build the Linux image. Next through a series of actions Yocto (IDE) will build the image as per the information/specifications in the metadata.
- Emulating and Testing the Linux Image using QEMU: QEMU as an emulator and virtualization machine supports testing of Linux images and applications, built using Yocto Project architectures, without having to run it on the actual hardware.
To run the Linux Image on the QEMU Emulator, please use the runqemu command
- Writing the Linux image: Depending on the information provided in the TARGET_DEVICE command, you can write the Linux image on any of the target devices like SATA drive, SD card or even USB key with the help of mkefidisk.sh script included in the poky repository.
Why Use Yocto framework for Linux projects?
- Easy customization: Yocto has a very robust and powerful customization architecture that offers numerous customization options such as footprint sizes, enabling/ disabling of components like graphics subsystems, visualization middleware, and services.
- Vendor Support: Yocto Project enjoys the support of most of the semiconductor and OS vendors and major electronic manufacturing firms. Thus with Yocto, you can leverage a solid support ecosystem and achieve your project goals.
- Reusability: The Yocto project facilitates this through shared state mechanism. This allows for reuse of resources across similar builds.
- Simplified Build operations for Embedded Linux applications: Single common framework of Yocto has helped get rid of the dependencies on discrete build systems wherein each of the SoC vendors created their own build framework compatible only with their microprocessor platforms.
- Seamless addition of UI components: Support for enhancing user experience for devices with display. This is facilitated by system components like Qt, Clutter, such as X11, GTK+, and SDL.
- Emulator support: It supports hardware and device emulation with the QEMU Emulator. Thus, an image built through Yocto Project can boot inside a QEMU emulator, with the development environment acting as a test platform for embedded software.
- Added Convenience: With its customizable recipes, tools and templates for building systems and porting OS, Yocto enables the developers to focus on other core development tasks.
- Systematically Managed & Updated: Every 6 months, a new release of Yocto including kernel (LTSI), toolchain, and package versions is released.
- Reduced Time To Market for Crucial Embedded Linux applications: With Yocto, a developer can build the entire Linux system from scratch in a couple of hours (as low as 1-2 hours depending on the project components).
- Readily Available Development Tools: As a Yocto user, you get access to a wide array of development tools like Application development Toolkit (ADT), ECLIPSE IDE Plug-in, Graphical UI for Embedded devices (Matchbox), tools for QA – among others.
Sreedevi Vamanan is a content professional who works with Embitel Technologies, a Bangalore-based company that has carved a niche of its own in the realms of automotive, IoT and e-commerce.