Skip to content
systemcoding.dev
Embedded Linux

Understanding local.conf and bblayers.conf in a Yocto Build

local.conf holds your per-build settings and bblayers.conf lists the layers to parse. Here is what each variable does and the order BitBake reads them.

6 min read
Summarize in AI
Flat illustration of a single-board computer with its SoC, memory, header and ports, with the Linux, Debian and NXP logos.

The first time you open a Yocto build directory you find a conf folder with two files in it, and everything you will change in the first month lives in one or the other. They look similar, since both are plain text files with VARIABLE = "value" lines, and beginners often put the same setting in the wrong one and wonder why nothing changes. They do different jobs. One says which layers exist, and the other says how to build with them. This post explains each file line by line, shows the order BitBake reads configuration in, and uses Scarthgap 5.0 LTS with BitBake 2.8 as the reference. The wider picture is in the Yocto cornerstone guide.

Where the two files come from

When you run source oe-init-build-env build, the script copies two templates into build/conf/ if the files do not exist. In Scarthgap those templates live under meta-poky/conf/templates/default/ as local.conf.sample and bblayers.conf.sample. After the first copy, the files in your build directory are yours: the script never overwrites them. If you delete the conf directory, the next source recreates the defaults. That is also the quickest way to see what a clean configuration looks like.

Both files are per build directory. If you want two different configurations, for example one for each board, keep two build directories, each with its own conf/local.conf and conf/bblayers.conf, and select one with source oe-init-build-env build-board-a.

bblayers.conf: which layers exist

bblayers.conf has one job: to tell BitBake which layers to include. A default file looks like this:

Text
POKY_BBLAYERS_CONF_VERSION = "2"

BBPATH = "${TOPDIR}"
BBFILES ?= ""

BBLAYERS ?= " \
  /home/builder/poky/meta \
  /home/builder/poky/meta-poky \
  /home/builder/poky/meta-yocto-bsp \
  "

Taking each variable in turn:

VariableMeaning
POKY_BBLAYERS_CONF_VERSIONA version stamp the sanity checker compares with the layer's expectation, so an old file is flagged after an upgrade
BBPATHThe directories BitBake searches for configuration, classes and includes; ${TOPDIR} is the build directory
BBFILESWhich recipe files to parse. It is empty here because each layer adds its own pattern from its layer.conf
BBLAYERSThe absolute paths of the layers to use, one per line, each ending with a backslash except the last quote

The trailing backslashes continue the string over several lines. Spaces and newlines separate the entries, and each path must be a directory containing conf/layer.conf. Use absolute paths. Relative paths are resolved against whatever BitBake considers the working directory and cause confusing errors.

Order inside BBLAYERS is not the priority of the layers. Priority comes from each layer's own BBFILE_PRIORITY in its layer.conf. The order matters in smaller ways, such as which layer.conf is processed first, so do not treat it as a way to override recipes.

You rarely edit this file by hand. The bitbake-layers add-layer command inserts a path in the right format, and the next section's neighbour post covers it. A layer you add has to satisfy its own dependencies, declared with LAYERDEPENDS in its layer.conf. If it does not, BitBake stops with an error naming the missing layer.

local.conf: how to build

local.conf holds the settings that apply to every recipe in this build. Strip the comments from the Scarthgap sample, and the active lines are few:

Text
MACHINE ??= "qemux86-64"
DISTRO ?= "poky"
PACKAGE_CLASSES ?= "package_rpm"
EXTRA_IMAGE_FEATURES ?= "debug-tweaks"
USER_CLASSES ?= "buildstats"
PATCHRESOLVE = "noop"
BB_DISKMON_DIRS ??= "\
    STOPTASKS,${TMPDIR},1G,100K \
    STOPTASKS,${DL_DIR},1G,100K \
    STOPTASKS,${SSTATE_DIR},1G,100K \
    STOPTASKS,/tmp,100M,100K \
    HALT,${TMPDIR},100M,1K \
    HALT,${DL_DIR},100M,1K \
    HALT,${SSTATE_DIR},100M,1K \
    HALT,/tmp,10M,1K"
CONF_VERSION = "2"

What the lines do:

  • MACHINE selects the hardware target. Changing it switches the whole build to another board or architecture.

  • DISTRO selects the distribution policy.

  • PACKAGE_CLASSES picks the package manager's format: package_rpm, package_ipk or package_deb. The first listed also decides which one is used for the root filesystem's package database.

  • EXTRA_IMAGE_FEATURES adds features to every image, here debug-tweaks (empty root password and other development conveniences).

  • USER_CLASSES inherits extra classes into every recipe. buildstats records task timings under tmp/buildstats/.

  • PATCHRESOLVE controls what happens when a patch fails to apply interactively. noop makes it fail instead of opening a prompt.

  • BB_DISKMON_DIRS makes BitBake watch free disk space and stop or halt the build before the disk is full.

  • CONF_VERSION is again a version stamp.

The sample file also holds commented lines for DL_DIR, SSTATE_DIR, TMPDIR and SSTATE_MIRRORS. Uncomment and edit these when you move the downloads or the cache somewhere else.

The assignment operators you will see

The first thing that surprises beginners is ??=, ?=, =, += and the rest. They are not decoration: they decide who wins when two files set the same variable.

OperatorMeaning
=Assign, replacing any earlier value
?=Assign only if the variable has no value yet
??=Assign only if no value exists after everything else is parsed, a weak default
+= and =+Append or prepend with a space
:append and :prependAppend or prepend without adding a space, applied late
:removeRemove a word from a list

The practical rule: a ??= line in a distribution or sample file is a default that anything else can override, a ?= line is a firmer default, and a plain = wins unless something later reassigns it. Because MACHINE ??= "qemux86-64" is the weakest form, setting MACHINE = "raspberrypi4-64" in local.conf below it, or even exporting MACHINE in the shell environment, overrides it. The override syntax in the colon form (:append) is the one introduced in Honister, and the migration post in this series covers it.

The order BitBake reads configuration

Configuration is parsed in a fixed order, and understanding it explains why a setting sometimes appears ignored. In outline:

  1. bblayers.conf is read first, from the build directory's conf/, because BitBake must know the layers before it can read anything else.

  2. Each layer's conf/layer.conf is read, in the order of BBLAYERS.

  3. conf/bitbake.conf from OE-Core is read next. It defines the large baseline of variables, directories and defaults.

  4. The machine configuration conf/machine/<MACHINE>.conf and the distribution conf/distro/<DISTRO>.conf are read.

  5. conf/local.conf is read, and then, if present, conf/site.conf.

  6. Classes listed in INHERIT and USER_CLASSES are loaded, and then recipes are parsed.

The actual order is more subtle than this list, and the BitBake manual's section on configuration files describes it precisely at https://docs.yoctoproject.org/bitbake/. The consequence you need now is simple: local.conf is read late, so its plain assignments override the machine and distribution defaults, and bitbake.conf is read early, so it sets what everything else builds on.

A small worked example

Suppose you want a different package format and an extra image feature for this build only. In conf/local.conf:

Text
PACKAGE_CLASSES = "package_ipk"
EXTRA_IMAGE_FEATURES += "ssh-server-dropbear"

After changing PACKAGE_CLASSES, the next bitbake core-image-minimal rebuilds the packaging steps for every recipe, because the output format is part of the task signature. It will not recompile the sources. The second line appends a feature, which adds the Dropbear SSH server to the image. You can confirm the final values with the technique in the bitbake -e post:

Shell
bitbake -e core-image-minimal | grep -E '^(PACKAGE_CLASSES|EXTRA_IMAGE_FEATURES)='
Text
EXTRA_IMAGE_FEATURES="debug-tweaks ssh-server-dropbear"
PACKAGE_CLASSES="package_ipk"

What does not belong in these files

Product-specific settings belong in your own layer, not in local.conf. local.conf is not under version control in most projects, and anything a colleague must reproduce has to live in a layer or a distribution configuration. A good split is: bblayers.conf and local.conf describe one developer's build directory, and recipes, machine files and distro files describe the product. Teams that want even those two files reproducible often generate them from a template or from a tool such as kas, which a later post covers.

Share

Keep reading

Flat illustration of user space above the system call boundary, the kernel and the hardware, with the Linux, C and GNU logos.
Kernels

Write a Pin Controller Driver With pinctrl

Write a Linux 6.12 pin controller driver: pinctrl_desc, pins, groups and functions, the set_mux callback, and the device tree states that consumers select.

8 min read

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.