In this chapter you will learn how to generate a custom layer with the different tools the Yocto Project offers. First of all, you'll discover how to generate a layer; then, you will integrate a recipe to the layer. In addition, to finish this chapter, we will generate a custom image. Reading this chapter will enable you to better organize your source code within the Yocto Project.
To create our custom layer, we can use two different methods:
meta-*
) and create the layer configuration file (conf/layer.conf
)yocto-layer
script provided by the Poky environment
To
gain flexibility
and avoid
mishandling, we'll use
the second option. To use
it,
we must
initially source all variables
to gain
access
through our
shell
in the
yocto-layer
script,
as shown in
the following command:
$ source oe-init-build-env rpi-build
Now that our
environment is set up, we have access
to the
yocto-layer
script,
and so,
we can begin
the
process of creating the layer.
Note that this script (yocto-layer
) creates the layer in the current directory by default. That is
why we must
place it
at the root
of our environment:
$ cd /where/you/want/to/stored/your/layer
We can now launch the script using the following command:
$ yocto-layer create <layer_name> -o <dest_dir>
For our example, we will call our layer meta-packt_rpi. Here is the command:
$ yocto-layer create packt_rpi Please enter the layer priority you'd like to use for the layer: [default: 6] Would you like to have an example recipe created? (y/n) [default: n] y Please enter the name you'd like to use for your example recipe: [default: example] example-packt Would you like to have an example bbappend file created? (y/n) [default: n] y Please enter the name you'd like to use for your bbappend file: [default: example] example-packt Please enter the version number you'd like to use for your bbappend file (this should match the recipe you're appending to): [default: 0.1] New layer created in meta-packt_rpi. Don't forget to add it to your BBLAYERS (for details see meta- packt_rpiREADME).
We have, through
this script, generated
our own
layer,
meta-packt_rpi
, and inside this layer is a sample recipe, an example of
bbappend
file, and so on. An example of our generated layer is shown in the following command:
$ tree meta-packt_rpi/ meta-packt_rpi/ ├── conf │ └── layer.conf ├── COPYING.MIT ├── README ├── recipes-example │ └── example │ ├── example-packt-0.1 │ │ ├── example.patch │ │ └── helloworld.c │ └── example-packt_0.1.bb └── recipes-example-bbappend └── example-bbappend ├── example-packt-0.1 │ └── example.patch └── example-packt_0.1.bbappend
If we want to install our layer, we just have to integrate the absolute path inside the
bblayers.conf
file, as it says in the README file:
I. Adding the packt_rpi layer to your build
=================================================
In order to use this layer, you need to make the build system aware of it.
Assuming the packt_rpi layer exists at the top-level of your
yocto build tree, you can add it to the build system by adding the
location of the packt_rpi layer to bblayers.conf, along with any
other layers needed. e.g.:
BBLAYERS ?= "
/path/to/yocto/meta
/path/to/yocto/meta-yocto
/path/to/yocto/meta-yocto-bsp
/path/to/yocto/meta-packt_rpi
"
We can
add our
layer
to our
bblayers.conf
file:
# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
LCONF_VERSION = "6"
BBPATH = "${TOPDIR}"
BBFILES ?= ""
BBLAYERS ?= "
/home/packt/RASPBERRYPI/poky/meta
/home/packt/RASPBERRYPI/poky/meta-yocto
/home/packt/RASPBERRYPI/poky/meta-yocto-bsp
/home/packt/RASPBERRYPI/poky/meta-raspberrypi
/home/packt/RASPBERRYPI/poky/meta-openembedded/meta-webserver
/home/packt/RASPBERRYPI/poky/meta-packt_rpi "
BBLAYERS_NON_REMOVABLE ?= "
/home/packt/RASPBERRYPI/poky/meta
/home/packt/RASPBERRYPI/poky/meta-yocto
After this, our layer is fully integrated with the Yocto Project, and so, it can be parsed by BitBake (the meta scheduler).
For further information, you can read the official documentation at http://www.yoctoproject.org/docs/1.8/dev-manual/dev-manual.html#yocto-project-layers .
18.117.107.90