Yocto Project allows developers to create custom layers to organize and manage modifications, custom recipes, and configurations. Creating a new layer in Yocto helps maintain a modular and organized structure for embedded Linux development. Layers allow for clean separation of vendor-specific changes, board support packages (BSPs), and custom application software.
Set up the environment
Before creating a new layer, ensure that you have set up your Digi Embedded Yocto environment.
-
If you haven’t done so, create a Digi Embedded Yocto project. See Create and build projects.
-
Go to your project folder and source the build environment:
$ cd <my-project> $ source dey-setup-environment
Create the layer directory
Use the bitbake-layers
tool to create a new layer at your desired path.
For instance, to create a layer called meta-custom:
$ bitbake-layers create-layer /<yourpath>/meta-custom -a
This command:
-
Creates the basic layer structure at the given path, including an example recipe:
/<yourpath>/meta-custom/ ├── conf │ └── layer.conf ├── COPYING.MIT ├── README └── recipes-example └── example └── example_0.1.bb
-
Automatically adds your new layer to your project’s
conf/bblayers.conf
file (option-a
)conf/bblayers.confBBLAYERS ?= " \ [...] /<yourpath>/meta-custom \ "
Layer priority
Each layer can define its priority using the BBFILE_PRIORITY_<layer-name>
variable.
Priorities allow managing conflicts between multiple layers providing the same recipe or configuration.
To set the priority for your custom layer, edit /<yourpath>/meta-custom/conf/layer.conf
and add, for example:
BBFILE_PRIORITY_meta-custom = "10"
A higher number means a higher priority. If another layer provides the same recipe but has a lower priority, the recipe from meta-custom will be used.
Create recipes
A recipe defines how a package is built.
The command you used to create the new layer, already generated an example recipe called example
.
Refer to the official Yocto documentation for information on creating recipes: https://docs.yoctoproject.org/dev-manual/new-recipe.html
Verify and test the layer
You can check if the new layer is recognized by running:
$ bitbake-layers show-layers