Yocto Tips & Tricks

4 Tips Make Yocto Easier to Use

By Vy Duong

Yocto can be intimidating for newcomers — even challenging for seasoned users. But, the benefits of gaining ease with Yacto far outweigh the pain endured. Here are four tips and tricks that can come in handy when working with Yocto. (If you’re brand new to Yacto, check out Yocto Quick Start for a solid introduction.)

1 Finding What’s Available

BitBake projects are generally organized in folders that contain metadata, configuration files, and recipes. These folders are generally referred to as a layer or a meta-layer. It is a common practice to prepend these project folder names with meta- .

There is a Qt 5 layer available through the OpenEmbedded repository. It’s important to note that this Qt 5 layer is not the same layer that is maintained by The Qt Company for their boot2qt version of Yocto. Certain hardware companies provide layers that are specific to their hardware, for instance a layer configured specifically for the Raspberry Pi (e.g. meta-raspberrypi).

Knowing what’s available when you’re creating a custom image is important. It will help you avoid the error messages and get to your endpoint faster. And it’s easy to find out what’s there. Simply search for available layers, recipes, and a list of supported machines provided by the OpenEmbedded repository here: http://layers.openembedded.org

2 Accessing Files in a Folder

To access files in a folder that is located above or in the same directory as the recipe file, you need to let the recipe know about it. SRC_URI searches the work directory and the current directory only, so you’ll need to append the following line to the top of your recipe file:

FILESEXTRAPATHS_prepend := “${THISDIR}/files”

This will allow the following line to be valid:

SRC_URI_append “file://file_1.png”

This assumes that there is a folder called “files” and inside that folder there is a file called “file_1.png”, where the folder “files” lives alongside the recipe file.

3 Modifying Rootfs Directly

There are cases where you may want to modify the rootfs files on the go, for instance to remove a service file or to add one. Yocto provides a few different approaches to achieve this:

ROOTFS_POSTPROCESS_COMMAND calls the given functions after bitbake has created the rootfs

ROOTFS_POSTINSTALL_COMMAND calls the given functions after bitbake has installed packages

ROOTFS_POSTUNINSTALL_COMMAND calls the given functions after bitbake has uninstalled packages

ROOTFS_PREPROCESS_COMMAND calls the given functions before OE creates the rootfs

In order to make use of these rootfs commands, you need to define the function. For example:

removeGettyService() {
// some instructions

Note that functions can be separated by a semicolon.

4 Adding Packages to SDK 

When generating an SDK, the Yocto build system will automatically include all the libraries and header files needed to build the applications running on the target in the target’s sysroot. If you need to add more packages, or if you discover that some development package’s libraries and header files are not included in your generated SDK, you’ll need to add the following:

(Note: In this example, we're adding cppzmq-dev to our image and SDK.)

a. Add the following to your image recipe or local.conf file :

IMAGE_INSTALL_append = " cppzmq-dev"
TOOLCHAIN_TARGET_TASK_append = " cppzmq-dev"

b. To add the SDK:

       i. The corresponding package needs to inherit the nativesdk class and usually the native class too:

BBCLASSEXTEND = “native nativesdk”

      ii. The package then needs to be added to the TOOLCHAIN_HOST_TASK variable.
          Append to the nativesdk-packagegroup-sdk-host recipe:

RDEPENDS_${PN} += “ \
nativesdk-zeromq-dev \


The above pointers will help ease some of the difficulty inherent in developing with Yocto, from reducing the time it takes to create recipes for pre-existing components to more easily adding packages to an SDK explicitly, quite useful when you have libraries and headers that are not included as part of default SDK generation.


Embedded Linux development Using Yocto Project Cookbook

Documentation for the latest release, Yocto Project 

Devshell, OpenEmbedded  


Have a question or want to add to the conversation?

You must be logged in to continue.

Log in Register