Create a Custom Meta Layer

At some point during application development it will become advantageous to consolidate the changes you made to the stock BSP into a meta layer in order to have them applied automatically by the build system. This makes it easier to reproduce the production image in new build environments and also allows you to version control your changes to the BSP, since meta layers are themselves repositories. As PHYTEC comes out with new BSP releases over time to improve our products, having your changes all in one meta layer also makes it easier to upgrade to the latest BSP and kernel when your development allows.

Note

In order to follow this guide, you must have first built the BSP in its entirety and have your BSP environment initialized. Checkout the Build the BSP guide if you haven’t yet!

bitbake-layers Tool

The easiest way to introduce new meta layers to the build system is by leveraging the ‘bitbake-layers’ tool in the poky distribution of The Yocto Project:

Example Output
phytec@phytec-virtual-machine:~/BSP-Yocto-FSL-i.MX8X-PD21.1.0/build$ bitbake-layers -h
NOTE: Starting bitbake server...
usage: bitbake-layers [-d] [-q] [-F] [--color COLOR] [-h] <subcommand> ...

BitBake layers utility

optional arguments:
  -d, --debug           Enable debug output
  -q, --quiet           Print only errors
  -F, --force           Force add without recipe parse verification
  --color COLOR         Colorize output (where COLOR is auto, always, never)
  -h, --help            show this help message and exit

subcommands:
  <subcommand>
    show-layers         show current configured layers.
    show-overlayed      list overlayed recipes (where the same recipe exists
                      in another layer)
    show-recipes        list available recipes, showing the layer they are
                      provided by
    show-appends        list bbappend files and recipe files they apply to
    show-cross-depends  Show dependencies between recipes that cross layer
                      boundaries.
    layerindex-fetch    Fetches a layer from a layer index along with its
                      dependent layers, and adds them to conf/bblayers.conf.
    layerindex-show-depends
                      Find layer dependencies from layer index.
    add-layer           Add one or more layers to bblayers.conf.
    remove-layer        Remove one or more layers from bblayers.conf.
    flatten             flatten layer configuration into a separate output
                      directory.
    create-layer        Create a basic layer

Use bitbake-layers <subcommand> --help to get help on a specific command

Check Existing Layers

Before creating a new layer, you should be sure someone in the Yocto community hasn’t already created a layer containing the metadata you need. You can see the OpenEmbedded Metadata Index for a list of layers from the OpenEmbedded community that can be used in the Yocto Project.

Note

Not all community layers are going to be compatible with the phyCORE-i.MX8X, the i.MX8X soc, or the Linux BSP PD21.1.0.

If you are familiar with Yocto and have used the workflow for a previous project, perhaps you already have a meta layer setup. In either case, you should find the repo URL of the meta layer and clone it locally to your Host Machine:

Host (Ubuntu)
cd ~
git clone <meta layer URL>

You’ll also want to ensure that the appropriate branch of the layer is checked out, if applicable.

Note

This guide we will work through an example by creating a meta-custom layer but the commands here should still serve as a reference for when working with existing meta layers you manually cloned to the local file system.

Create a Layer

Use the following command to create a new meta layer from scratch, named ‘meta-custom’:

Host (Ubuntu)
cd $BUILDDIR
bitbake-layers create-layer meta-custom

Note

It is not a requirement that a layer name begin with the prefix ‘meta-’, but it is a commonly accepted standard in the Yocto Project community.

This command sets up a meta-custom layer directory and automatically populates it with examples a configuration and recipe for an example, in the current working directory.

Add Layers

Now that you have a meta layer (perhaps you manually cloned an existing layer), we can add it to the build system:

Host (Ubuntu)
bitbake-layers add-layer meta-custom

You have officially added a custom meta layer to the BSP! Congratulations! At this point, the best resource for further customizing this meta layer according to the specific needs of your project is to work through The Yocto Project Development Tasks Manual and The Yocto Project Board Support Package Developer’s Guide. We know that its a lot of manuals!

Tip

Remember, you can always ask questions in the PHYTEC’s Support Portal! We want your projects to succeed!