Adding custom software to Bitbake / OE-Core

This tutorial is aimed at developers who are already comfortable using Bitbake and want to add their own software to a recipe. It will cover how to create a basic recipe and how to point that recipe's source to a Git repository. In addition, I will briefly touch up compile and install directions to get your custom software installed in the rootfs generated by Bitbake to flash onto an embedded Linux device.

I am assuming you already have your own meta layer that houses your recipes. If not, find a meta layer that works for you and copy it. In my work, I copied a meta layer provided by Toradex for their Colibri T20 system-on-chip. You will likely have a similar meta layer that is designed for your hardware. Unlike my software repository, I will not share my meta layer since it is unlikely to work properly on your hardware.

The first step is to create a custom recipe for your software. In the recipes directory of your meta layer, create a folder called bb-example. Note that you cannot use underscores in recipe names, due to conflicts with Bitbake using underscores to separate version numbers. Inside this folder, create a file called with the following:

# bb-example .bb build file
# place this in your meta- layer folder under
# recipes/bb-example/

DESCRIPTION = "bb-example code"
LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58"

# change this URI if you plan to fork the repository or use an alternate repository
SRC_URI = "git://;protocol=git"
# this SRCREV determines the branch or tag to be used
SRCREV = "master"

# this is a revision number that should be updated every time you alter this recipe
PR = "r0" 

# this indicates the folder to run do_compile from.

# this command will be run to compile your source code. it assumes you are in the
# directory indicated by S. i'm just going to use make and rely on my Makefile
do_compile () {
# this will copy the compiled file and place it in ${bindir}, which is /usr/bin
do_install () {
  install -d ${D}${bindir}
  install -m 0755 bb-example ${D}${bindir}

This .bb file tells Bitbake what to do with your recipe and how to fetch, compile and install the files. Whenever you run Bitbake, it will now clone the repository, compile the code, and copy the compiled bb-example file into the /usr/bin directory of the generated rootfs.

Next, modify your image recipe to add a requirement for your recipe. Open up the image file and add my-project to the IMAGE_INSTALL section. Here is a sample:

    angstrom-packagegroup-boot \
    task-basic \
    bb-example \

Now that Bitbake knows about my-project, and knows how to find my-project, you'll need a place to host your software. For this tutorial, I will use Github. You can fork my bb-example repository, or use it directly. If you fork it, be sure to update your recipe file to point to your own repository.

Once this is done, run Bitbake normally and upload the images to your device. You should now have a file at /usr/bin/bb-example. This setup saves you from having to install the software after flashing, which can save a lot of time during final production of your hardware.