Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Embedded Linux Development using Yocto Projects - Second Edition

You're reading from  Embedded Linux Development using Yocto Projects - Second Edition

Product type Book
Published in Nov 2017
Publisher
ISBN-13 9781788470469
Pages 162 pages
Edition 2nd Edition
Languages
Authors (2):
Otavio Salvador Otavio Salvador
Profile icon Otavio Salvador
Daiane Angolini Daiane Angolini
Profile icon Daiane Angolini
View More author details

Table of Contents (22) Chapters

Title Page
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
Meeting the Yocto Project Baking Our Poky-Based System Using Toaster to Bake an Image Grasping the BitBake Tool Detailing the Temporary Build Directory Assimilating Packaging Support Diving into BitBake Metadata Developing with the Yocto Project Debugging with the Yocto Project Exploring External Layers Creating Custom Layers Customizing Existing Recipes Achieving GPL Compliance Booting Our Custom Embedded Linux Index

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>/conffolderis mandatory and should provide the configuration files (the.conffiles). 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...

Adding meta layers


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.conffileand 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 Machines 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:

Summary


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.

lock icon The rest of the chapter is locked
You have been reading a chapter from
Embedded Linux Development using Yocto Projects - Second Edition
Published in: Nov 2017 Publisher: ISBN-13: 9781788470469
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}