Before we dig deeper into yocto and poky we will configure some things to make our lifes easier further down the road. This part of our multi-part yocto tutorial covers system configuration for building yocto systems for multiple embedded systems.

Initialising the build system

One yocto/poky installation can support any number of targeted builds for different embedded devices. Each of these builds however has to reside inside its own build directory. yocto provides a script to setup and/or use specific build directory.

$ cd ~/yocto/poky
$ . .oe-init-build-env rpibuild

.oe-init-build-env is the environment setup script that will setup local path and other variables for you build directory. rpibuild is the name of the build directory (yocto name: TOPDIR, BUILDDIR). rpibuild stands for Raspberry Pi build, as we will be building a distro for the Raspberry Pi in the next chapter of this tutorial. If you dont’t provide a build directory name it will default to build. Please note the extra point “.” in . .oe-init-build-env. The first point is a shortcut for the source command, the second point makes .oe-init-build-env a hidden file.

The first call to .oe-init-build-env with a new directory name will create the directory and its contents, all subsequient calls will only set the environment variables accordingly. You have to call .oe-init-build-env once per terminal session, otherwise building and many other tools will not work (as in file not found errors). The source command runs the contents of the script as if typed onto the current shell. This includes directory changes, thus running the .oe-init-build-env script will leave you inside the build directory.

Since we are planning to build distros for multiple targets, we will make some changes to the <code<local.conf</code> file.

$ nano conf/local.conf

Search for the line #DL_DIR ?= "${TOPDIR}/downloads" and change it into DL_DIR ?= "/home/username/yocto/downloads" where username should be replaced by your user name.

Now run mkdir ~/yocto/downloads to create the corresponding directory. All tarball downloads, git checkouts, etc. will now be stored in a central place. Repeat the config change for every build directory and you will save space and downlaod time in the future.

Setting up build history

Building yocto images can be pretty confusing at times. While yocto generally does a good job in automatically handling dependecies and ensuring building of all packages, sometomes things go awry and you end up with a failed package and no idea why you even tried to build it. Build history will create a directory buildhistory inside your build directory. therein it will aintain information about the build, such as:

  • Source revisions
  • Files in image
  • Installed packages ordered by size or name
  • Dependency graph

The directoy will be versioned by git, so you can compare different releases easily. There is small size and time penalty for using the feature, but it is well worth it. You can activate and deactivate the buildhistory in the config file:

$ nano conf/local.conf

At the end of the file append the following lines

INHERIT += "buildhistory"
BUILDHISTORY_COMMIT = "1"

Read more about these features in the yocto reference manual buildhistory section.