Book Image

Embedded Linux Development Using Yocto Project - Third Edition

By : Otavio Salvador, Daiane Angolini
Book Image

Embedded Linux Development Using Yocto Project - Third Edition

By: Otavio Salvador, Daiane Angolini

Overview of this book

The Yocto Project is the industry standard for developing dependable embedded Linux projects. It stands out from other frameworks by offering time-efficient development with enhanced reliability and robustness. With Embedded Linux Development Using Yocto Project, you’ll acquire an understanding of Yocto Project tools, helping you perform different Linux-based tasks. You’ll gain a deep understanding of Poky and BitBake, explore practical use cases for building a Linux subsystem project, employ Yocto Project tools available for embedded Linux, and uncover the secrets of SDK, recipe tool, and others. This new edition is aligned with the latest long-term support release of the aforementioned technologies and introduces two new chapters, covering optimal emulation in QEMU for faster product development and best practices. By the end of this book, you’ll be well-equipped to generate and run an image for real hardware boards. You’ll gain hands-on experience in building efficient Linux systems using the Yocto Project.
Table of Contents (20 chapters)

Preparing the build host system

This section describes how to prepare Windows and Linux distribution host systems. Although we will describe the Windows steps, we will focus on using a Linux distribution host system.

Tip

The use of macOS as a host system is possible. Still, it involves using the CROss PlatformS (CROPS) framework, which leverages Docker, allowing the use of foreign operating systems, including macOS. For more information, you can refer to the Setting Up to Use CROss PlatformS (CROPS) section from the Yocto Project Development Tasks Manual (https://docs.yoctoproject.org/4.0.4/dev-manual/start.html#setting-up-to-use-cross-platforms-crops).

Next, we will provide the necessary information to start the build host system preparation.

Using Windows Subsystem for Linux (WSLv2)

You can set up a Linux distribution on Windows if you are a Windows user. WSLv2 is only available for Windows 10+ builds greater than 18917. WSLv2 allows development using the Yocto Project. You can install the Linux distribution from the Microsoft Store.

Please refer to the Setting Up to Use Windows Subsystem For Linux session (https://docs.yoctoproject.org/4.0.4/dev-manual/start.html#setting-up-to-use-windows-subsystem-for-linux-wslv2) from the Yocto Project Development Tasks Manual (https://docs.yoctoproject.org/4.0.4/dev-manual/index.html). Once you have WSLv2 set up, you can follow the next sections as if you were running on a native Linux machine.

Preparing a Linux-based system

The process needed to set up our host system depends on the Linux distribution we use. Poky has a set of supported Linux distributions. Let’s suppose we are new to embedded Linux development. In that case, it is advisable to use one of the supported Linux distributions to avoid wasting time debugging issues related to the host system support.

If you use the current release of one of the following distributions, you should be good to start using the Yocto Project on your machine:

  • Ubuntu
  • Fedora
  • CentOS
  • AlmaLinux
  • Debian
  • OpenSUSE Leap

To confirm whether your version is supported, it is advisable to check the official documentation online in the Required Packages for the Build Host section (https://docs.yoctoproject.org/4.0.4/ref-manual/system-requirements.html#required-packages-for-the-build-host).

If your preferred distribution is not in the preceding list, it doesn’t mean it is not possible to use Poky on it. Your host development system must meet some specific versions for Git, tar, Python, and GCC. Your Linux distributions should provide compatible versions of those base tools. However, there is a chance that your host development system does not meet all these requirements. In that case, you can resolve this by installing a buildtools tarball that contains these tools, as detailed in Required Git, tar, Python, and GCC Versions (https://docs.yoctoproject.org/4.0.4/ref-manual/system-requirements.html#required-git-tar-python-and-gcc-versions).

We must install a few packages on the host system. This book provides instructions for Debian and Fedora, our preferred distributions, which we will look at next. The set of packages for other supported distributions can be found in the Yocto Project Reference Manual (https://docs.yoctoproject.org/4.0.4/ref-manual/system-requirements.html#required-packages-for-the-build-host).

Debian-based distribution

To install the necessary packages for a headless host system, run the following command:

$ sudo apt install gawk wget git diffstat unzip texinfo gcc build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool

Fedora

To install the needed packages for a headless host system, run the following command:

$ sudo dnf install gawk make wget tar bzip2 gzip python3 unzip perl patch diffutils diffstat git cpp gcc gcc-c++ glibc-devel texinfo chrpath ccache perl-Data-Dumper perl-Text-ParseWords perl-Thread-Queue perl-bignum socat python3-pexpect findutils which file cpio python python3-pip xz python3-GitPython python3-jinja2 SDL-devel xterm rpcgen mesa-libGL-devel perl-FindBin perl-File-Compare perl-File-Copy perl-locale zstd lz4