# Layers

Groups of recipes that belong together are grouped into layers. For example meta-ntb 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 that set up there.

## Creating a custom layer

To create a new layer, create a new directory in the yocto directory. Since this is the NTB wiki, this guide will use meta-ntb. 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 += "ntb" BBFILE_PATTERN_ntb := "^${LAYERDIR}/"
BBFILE_PRIORITY_ntb := "5"

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

• meta-ntb
• conf
• layer.conf
• recipes-ntb

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-ntb \
"
...

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 = "Beckhoff CX2020 PLC"

require conf/machine/genericx86-64.conf

PREFERRED_PROVIDER_virtual/kernel = "linux-yocto-custom-rt"
KMACHINE_cx2020 = "qemux86-64"


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 sratch, 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.