Home » Development and Build » Yocto Embedded Linux » Create meta layer using yocto scripts

Create meta layer using yocto scripts

The yocto-layer script simplifies creating a new general layer.

The default mode of the script’s operation is to prompt you for information needed to generate the layer:

  • The layer priority.
  • Whether or not to create a sample recipe.
  • Whether or not to create a sample append file.

Use the yocto-layer create sub-command to create a new general layer. In its simplest form, you can create a layer as follows,

$ yocto-layer create lynxbee

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] helloworld
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] helloworld
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-lynxbee.

Don’t forget to add it to your BBLAYERS (for details see meta-lynxbee\README).

$ tree meta-lynxbee/

meta-lynxbee/
├── conf
│   └── layer.conf
├── COPYING.MIT
├── README
├── recipes-example
│   └── example
│       ├── helloworld-0.1
│       │   ├── example.patch
│       │   └── helloworld.c
│       └── helloworld_0.1.bb
└── recipes-example-bbappend
└── example-bbappend
├── helloworld-0.1
│   └── example.patch
└── helloworld_0.1.bbappend

7 directories, 8 files

——————————————————–

The previous example creates a layer named meta-lynxbee in the current directory.

As the yocto-layer create command runs, default values for the prompts appear in brackets. Pressing enter without supplying anything for the prompts or pressing enter and providing an invalid response causes the script to accept the default value. Once the script completes, the new layer is created in the current working directory. The script names the layer by prepending meta- to the name you provide.

Minimally, the script creates the following within the layer:

The conf directory: This directory contains the layer’s configuration file. The root name for the file is the same as the root name your provided for the layer (e.g. layer.conf).

The COPYING.MIT file: The copyright and use notice for the software.

The README file: A file describing the contents of your new layer.

If you choose to generate a sample recipe file, the script prompts you for the name for the recipe and then creates it in layer/recipes-example/example/. The script creates a .bb file and a directory, which contains a sample helloworld.c source file, along with a sample patch file. If you do not provide a recipe name, the script uses “example”.

If you choose to generate a sample append file, the script prompts you for the name for the file and then creates it in layer/recipes-example-bbappend/example-bbappend/. The script creates a .bbappend file and a directory, which contains a sample patch file. If you do not provide a recipe name, the script uses “example”. The script also prompts you for the version of the append file. The version should match the recipe to which the append file is associated.

The easiest way to see how the yocto-layer script works is to experiment with the script. You can also read the usage information by entering the following:

$ yocto-layer help

Once you create your general layer, you must add it to your bblayers.conf file. Here is an example where a layer named meta-lynxbee is added:

BBLAYERS = ?” \
/usr/local/src/yocto/meta \
/usr/local/src/yocto/meta-yocto \
/usr/local/src/yocto/meta-yocto-bsp \
/usr/local/src/yocto/meta-lynxbee \

Adding the layer to this file enables the build system to locate the layer during the build.


Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

Leave a Comment