Layers

Groups of recipes that belong together are grouped into layers. For example meta-ost is the layer that contains all the things needed to support the our needs for our linux images.

Setting up the Environment

First, set up a build environment. If in doubt, follow Setting Up the Build Environment . This guide will assume that the environment matches the one set up there.

Creating a Custom Layer

To create a new layer, create a new directory in the yocto directory. Since this is the OST wiki, this guide will use meta-ost. The directory name can be anything, but it should start with meta-. Now change into that directory and create another folder called conf. In conf, create a file named layer.conf with the following content:

BBPATH := "${BBPATH}:${LAYERDIR}"

BBFILES := "${BBFILES} ${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bappend"

BBFILE_COLLECTIONS += "ost"

BBFILE_PATTERN_ost := "^${LAYERDIR}/"
BBFILE_PRIORITY_ost := "5"

This file configures the layer and where to look for recipes. In this case it will look for a file in meta-ost/recipes-<some name>/<some other name>/<file name>.bb. .bb is the file extension used by bitbake. Finally, create a folder named recipes-xyz inside meta-ost. This folder will store all the recipes for this layer. The directory structure should now look like this:

  • meta-ost
    • conf
      • layer.conf
    • recipes-xyz

Finally, add the new layer to the build by adding it to build/conf/bblayers.conf (see here for more info) :

BBLAYERS ?= "\
...
  /home/ubuntu/meta-ost \
"
...

Adding Machines

Machines are the way to go to set machine/hardware specific settings. This includes things like setting the bootloader and kernel.

Machine configurations live in conf/machine inside the layer. The full path is <layer name>/conf/machine/<machine name>.conf.

Example:

DESCRIPTION = "generic x86_64 machine with RT kernel"

require conf/machine/genericx86-64.conf

PREFERRED_PROVIDER_virtual/kernel = "linux-yocto-rt"
KMACHINE_x86-rt = "qemux86-64"
COMPATIBLE_MACHINE_x86-rt = "x86-rt"

This example uses the genericx86_64 (included in poky) as a basis to set everything up for the architecture. While it is possible to set up everything from scratch, that job is best left to the vendor/BSP provider. Additionally this machine specifies it's kernel and sets KMACHINE so bitbake knows what architecture to use for the kernel build. Note that KMACHINE needs to be suffixed with the machine name, and thus is not part of the genericx86_64 machine.

Adding Recipes