Book Image

Yocto for Raspberry Pi

By : TEXIER Pierre-Jean, Petter Mabäcker
Book Image

Yocto for Raspberry Pi

By: TEXIER Pierre-Jean, Petter Mabäcker

Overview of this book

The Yocto Project is a Linux Foundation workgroup, which produces tools (SDK) and processes (configuration, compilation, installation) that will enable the creation of Linux distributions for embedded software, independent of the architecture of embedded software (Raspberry Pi, i.MX6, and so on). It is a powerful build system that allows you to master your personal or professional development. This book presents you with the configuration of the Yocto Framework for the Raspberry Pi, allowing you to create amazing and innovative projects using the Yocto/ OpenEmbedded eco-system. It starts with the basic introduction of Yocto's build system, and takes you through the setup and deployment steps for Yocto. It then helps you to develop an understanding of Bitbake (the task scheduler), and learn how to create a basic recipe through a GPIO application example. You can then explore the different types of Yocto recipe elements (LICENSE, FILES, SRC_URI, and so on). Next, you will learn how to customize existing recipes in Yocto/OE layers and add layers to your custom environment (qt5 for example).
Table of Contents (18 chapters)
Yocto for Raspberry Pi
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
3
Mastering Baking with Hob and Toaster

The core components


The core components (other available tools are optional) of the Yocto Project are:

  • BitBake

  • OpenEmbedded-Core

  • Poky

  • The BSP layer (meta-raspberry, meta-fsl-arm, meta-ti, meta-intel, meta-sunxi, and so on)

The following diagram shows all the layers that we will discover through this book. We will study all the tools through various examples, allowing better comprehension.

What is Poky?

Poky is the reference Yocto Project distribution. It contains some of basic components (called the build system) of OpenEmbedded and a set of metadata for creating embedded distributions for a number of targets. It is platform independent and performs cross-compiling using the BitBake tool (a task scheduler), OpenEmbedded-Core, and a default set of metadata, as shown in the following figure. It provides the mechanism to build and combine thousands of distributed open source projects.

The Poky build system is poised to become the reference in the industrial world as evinces by industry leaders such as Wind River, Intel, Montavista, and Mentor Graphics.

Note

Angstrom ( http://www.angstrom-distribution.org/ ) is another distribution based on OpenEmbedded-Core. You might consider Angstrom and Poky to be close cousins, because Poky is also based on OpenEmbedded-Core.

The Chief - BitBake

BitBake, the build engine, is a task scheduler (like GNU Make) which parses several scripts (shell and Python, for example).

Once the environment is built, BitBake will execute the task that has been requested. If no task is provided, BitBake will run the default task, called build.

To run a task, BitBake will first look for an environment variable called do_ <task name>, which will contain the task code to execute (in Python or a shell). So, to compile a Yocto recipe, use the code contained in the do_compile variable.

In short, from the information contained in the recipes (or metadata), it downloads the sources of projects from the Internet, a local directory, or a version-control system (such as Git), and then builds in the order determined by the dependency graph generated dynamically. Finally, it installs binaries, generates the corresponding package, and builds the final image, which can be installed on the target (Raspberry Pi for us).

The following picture shows how BitBake works:

OpenEmbedded-Core

The OpenEmbedded-Core metadata collection (meta in the following diagram) provides the engine of the Poky build tool. It is designed to provide the core features (several recipes). It provides support for six different processor architectures (ARM, x86, x86-64, PowerPC, MIPS, and MIPS64), supporting only QEMU-emulated machines.

The organization of OpenEmbedded-Core is depicted here:

This layer includes different recipes, which describe how to fetch, configure, compile and package applications and images.

Note

For the rest of the book, we will mix this layer with the BSP layer of the Raspberry Pi, meta-raspberrypi.

Exploring metadata

Metadata, which is composed of a mix of Python and shell script text files (.conf, .bb, .bbclass, and .inc), provides a tremendously flexible system. Metadata refers to the build instructions themselves as well as the data used to control what things get built and to affect how they are built. The metadata also includes commands and data used to indicate which versions of software are used and where they are obtained from. Poky uses this to extend OpenEmbedded-Core and includes two different layers, which are another metadata subset. Here are their details:

  • * meta-yocto: This layer provides the default and supported distributions, visual branding, and metadata tracking information (maintainers, upstream status, and so on)

  • * meta-yocto-bsp: This layer, on top of it, provides the hardware reference board support (BSP) for use in Poky

We will discover metadata in depth through Chapter 4, Understanding the BitBake tool.