Reader small image

You're reading from  Using Yocto Project with BeagleBone Black

Product typeBook
Published inJun 2015
Reading LevelIntermediate
Publisher
ISBN-139781785289736
Edition1st Edition
Languages
Right arrow
Authors (2):
Irfan Sadiq
Irfan Sadiq
author image
Irfan Sadiq

H M Irfan Sadiq was a Linux enthusiast as a graduate student. He started his career as an embedded system development engineer and has been working as an H.264 Decoder developer and optimizer for the VLIW architecture. He got an opportunity to work on multiple multimedia frameworks that are open source as well as proprietary. He tried to work in a start-up in the entirely different domain of web development. He has been working on OpenEmbedded and Yocto Project technologies since he joined Mentor Graphics as the technical lead back in 2010. He has been working on derivative technologies of Yocto Project and OpenEmbedded for quite some time now, spanning more than 4 years. He has also been working on various hardware platforms based on the ARM, PPC, and x86 architecture. The diverse nature of subsequent BSPs has challenges in the context of QA. One of the challenges was to keep the QA packages in one place in such a way that they could be applied to all different product/platform combinations. He addressed this by creating a Yocto Project-based layer for which he is a maintainer as well as a gatekeeper.
Read more about Irfan Sadiq

View More author details
Right arrow

Chapter 5. Creating and Exploring Layers

In this chapter, we will discuss layers, a powerful mechanism for the organization and reuse of metadata. We will also discuss the creation of layers using the script yocto-layer. Then, we will move on to various configuration options to organize the metadata and types of layers. We will cover aiding techniques of append files usage and packagegroups. We will discuss image customization as well.

Layer creation using script


We should always start with something easy, in order to keep things simple. So, a simple way to create a layer is to execute the following command from the script directory, under the poky directory:

$  ./scripts/yocto-layer create test

This will create a directory named meta-test in the poky directory, from where we invoke this command. However, before that, you have to answer some questions. The answers are discussed in these steps:

  • Enter the layer priority you'd like to use for this layer: [default: 6] 7

  • Check whether you would like to have an example recipe created: (y/n) [default: n]

  • Check whether you would you like to have an example bbappend file created: (y/n) [default: n] y

  • Enter the name you'd like to use for your bbappend file: [default: example] helloworld

  • Enter the version number you'd like to use for your bbappend file, (this should match the recipe you're appending the file to): [default: 0.1]

Then, this script will notify us about enabling our newly...

Contents of layers


We have already discussed, layers are a way of organizing our metadata. To use these layers, we have to follow a well-defined directory structure to keep the metadata as well as code, for the organization of this metadata. In this section, we will discuss how this organization is accomplished, what the minimum requirements of the directory structure are, and what contents are available under each directory. To talk about the directories in any layer, the layer should have at least two directories, which are discussed in the upcoming sections.

The conf directory

The minimal content in this directory is the configuration file named layer.conf. Basically, there are two types of layers:

  • General layers

  • BSP layers

We have created a general layer in the previous experimentation, using the yocto-layer command with its create option. BSP layers can be created using the yocto-bsp command, in a manner that is similar to using some extra options, which are not very different. This file...

Conditional selection based on layers


We can use BBFILE_COLLECTIONS to conditionally decide which recipes to include in our BBFILES. To do this, we need to use logic that is similar to the following in our layer.conf:

  1. Firstly, add the following two lines to our layer.conf file:

    BBFILES += "${@' '.join('${LAYERDIR}/%s/recipes-*/*/*.bbappend' % layer \
                   for layer in BBFILE_COLLECTIONS.split())}"
    BBFILES += "${@' '.join('${LAYERDIR}/%s/recipes-*/*/*.bb' % layer \
                   for layer in BBFILE_COLLECTIONS.split())}"
  2. Secondly, arrange your recipes-* directories under directories named according to other layers found in BBFILE_COLLECTION. For example, we might need to add some metadata that is specific only to it, and we want it applied only when we have meta-ti included in our bblayers.conf file. What we will do in this case is create a directory under our layer—say, test/meta-t/—and move all of the recipe-* directories specific to it under this directory. In the current configuration...

Append files


We did not create a recipe file while creating the meta-test layer. Instead, we created an append file for the helloworld recipe, which we already have in the meta-ybdevelop layer. Append files are a mechanism used to override/enhance existing functionality in the recipe to which the append is being applied. This is the recommended way to do things. According to the guidelines, it is suggested that you use append files instead of copying the full recipe files to your layers. These files should have bbappend as an extension, and the name should be the same as the recipe to which we are applying modifications. Also, you should only be modifying the contents required by you. In this append file, we used two lines. In the first line, we extended the file lookup path to be used, as follows:

FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PV}:"

In the next line, we picked the patch file to be applied to the source code file of our helloworld recipe. This is a simple patch file, which...

Packagegroups


We have discussed how to customize images using the append file on images, or using configuration files. These techniques are useful in some use cases, yet they could become a hassle in cases where we are dealing with logs of packages and we want to use these packages with more than one image type. In such cases, we will be performing duplications, which are certainly not clean. To avoid such cases, packagegroups comes into play. The idea is to keep these lists of packages separate from image append files so that they can be used across multiple images.

This is a specialized recipe .bb file with the following features. Again, it will reside in the top-level directory of our layer/recipes-*/packagegroups/<packagegroup>.bb file:

  • It inherits package groups, that is, the packagegroup.bbclass class is used from meta/classes. This should be the first line of the code:

    Inherit packagegroup
  • All of the packagegroups that need to be created are added to the PACKAGES variable:

    PACKAGES...

Summary


In this chapter, we created one more meta-test layer. We also performed some experimentation on this layer so that we could discuss related concepts. We discussed the contents of layers in detail, and we also discussed image customization techniques using simple configuration, bbappend, and packagegroups.

In next chapter, we will discuss some console-based games. For this purpose, we will select a console-based version of the popular game PAC-MAN.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Using Yocto Project with BeagleBone Black
Published in: Jun 2015Publisher: ISBN-13: 9781785289736
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.
undefined
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

Authors (2)

author image
Irfan Sadiq

H M Irfan Sadiq was a Linux enthusiast as a graduate student. He started his career as an embedded system development engineer and has been working as an H.264 Decoder developer and optimizer for the VLIW architecture. He got an opportunity to work on multiple multimedia frameworks that are open source as well as proprietary. He tried to work in a start-up in the entirely different domain of web development. He has been working on OpenEmbedded and Yocto Project technologies since he joined Mentor Graphics as the technical lead back in 2010. He has been working on derivative technologies of Yocto Project and OpenEmbedded for quite some time now, spanning more than 4 years. He has also been working on various hardware platforms based on the ARM, PPC, and x86 architecture. The diverse nature of subsequent BSPs has challenges in the context of QA. One of the challenges was to keep the QA packages in one place in such a way that they could be applied to all different product/platform combinations. He addressed this by creating a Yocto Project-based layer for which he is a maintainer as well as a gatekeeper.
Read more about Irfan Sadiq