Chapter 10. Exploring External Layers
One of the most charming features of Poky is the flexibility of using external layers. In this chapter, we will look at why this is a strong capability and how we can take advantage of this. We will look at the different layer types and how their directory trees are organized. Finally, we will learn how to include a new layer in our project.
Powering flexibility with layers
Poky contains a great amount of metadata spread over machine definition files, classes, and recipes. This metadata covers everything from simple applications to full graphical stacks and frameworks. BitBake has the ability to load metadata from multiple places, and those multiple metadata sets are known as metadata layers.
The biggest strength of using layers is the ability to split the metadata into logical units, which enables users to pick only the metadata set needed for the project. Using metadata layers improves the reuse of code and the ability to share work across different teams, communities, and vendors, increasing the code quality of the Yocto Project community as multiple entities are working together on the same metadata.
We may want to configure the system for different reasons, such as the need to enable/disable a feature or change build flags to enable architecture-specific optimizations. These are examples of customizations that can be done...
Detailing the layer's source code
Usually, a layer has a directory tree, as shown in the following screenshot:
The layer name should start with meta-
; it is not a requirement, but the advised naming convention. Inside this directory, there are two files, <layer>/COPYING
and <layer>/README
, a license, and a message to the user. In <layer>/README
, we must specify any other dependency and information that the layer's users need to know.
The classes
folder should hold both the classes provided the classes that are specific to that layer (the .bbclass
files). It is an optional directory.
The <layer>/conf
folderis mandatory and should provide the configuration files (the.conf
files). Primarily, the layer configuration file<layer>/conf/layer.conf
, to be detailed in the next chapter, is the file with the layer definition.
When the <layer>/conf
folder is from a BSP layer, the directory structure should look like the following screenshot:
If the <layer>/conf
folder...
There are hundreds of meta layers from the Yocto Project, OpenEmbedded, communities, and companies that should be manually cloned inside the project source directory to be used. We can find them at http://git.yoctoproject.org/ or http://layers.openembedded.org.
In order to include, for example, meta-openembedded
in our project, we can change the content of the configuration files or use BitBake command lines. To do so, we need first to fetch the layer's source code. Please run the following command from your Poky source directory:
$ git clone git://git.openembedded.org/meta-openembedded -b rocko
We can now add a new layer by changing the build/conf/bblayer.conf
fileand adding the absolute path to the new meta layer directory, as shown in the following source code. The highlightedlineis the one to be added. The others are the default values for this file:
An alternative to manually editing build/conf/bblayers.conf
is to use the bitbake-layers
tool to do the inclusion for us...
The Yocto Project layer ecosystem
Because of the convenience of making a layer, there are a huge number of layers to use. To make all those available layers easier to access, the OpenEmbedded community has developed an index where most of them can be found.
Let’s say we just ordered a Raspberry Pi 3 board; we can use the link to https://layers.openembedded.org and search for it in the M
achines
tab, as shown in the following screenshot:
Another very handy use case for the tools is to search for a specific software type or a recipe. It can save the day! We can see some commonly used layers in the following screenshot:
In this chapter, we introduced the concept of layering. We learned about the directory structure in detail and the content of each layer type. In addition, we saw how to add an external layer to our project manually or by using the BitBake command line, as well as how to make use of the OpenEmbedded Layer index to easily find the available layers that we need.
In the next chapter, we will learn more about why we need to create new layers and what the common metadata included in them is (such as machine definition files, recipes, and images), and wrap it all up with an example of distribution customization.