Yocto Project

Overview

The Yocto Project, or more commonly just called Yocto, is a build system used to create custom Linux distributions for embedded systems. It is important to note that it is not a Linux distribution itself, but a collection of tools to generate a custom Linux distribution for your specific embedded hardware.

The logo for the Yocto project.

Child Pages

How To Add A Custom App To A Yocto Build
ContentsOverviewMaking A Basic Hello, World App (Binary)Make A Layer To Hold The AppOverview Making A Basic Hello, World App (Binary) Firstly, we need a basic application that we can then add to a Yocto build. Let’s create a simple application that prints “Hello, World” to stdout and then exits. We need to create the following … Continue reading How To Add A Custom App To A Yocto Build
Recipes
ContentsOverviewGetting Code From Online Git RepositoriesOverview Getting Code From Online Git Repositories Yocto supports the ability to pull code from online git repositories as part of the build process. What about private repositories? Private repositories have the added complexity of requiring authentication before you can download (a.k.a clone) them. Luckily, Yocto supports the ssh protocol. … Continue reading Recipes

Quick Start

This is a Yocto “Quick Start”, aimed to get you familiar with the basics of the Yocto and building a embedded Linux image in no time!

This quick start has been tested with Ubuntu 16.04 64-bit, running in VMWare on a Windows host (the free VirtualBox VM should also work fine).

NOTE: Give your VM a ton of hard drive space, memory and processors. You will be building Linux from source code, and this is very resource intensive! I gave the VM 120GB hard drive space (grows as needed), 8GB memory and 8 processors.

Yocto has it’s own quick start guide at http://www.yoctoproject.org/docs/2.2.1/yocto-project-qs/yocto-project-qs.html. However, I have has problems with this, including errors such as:

Install Prerequisites

Run the following bash command:

Clone Yocto’s poky Repository

poky is a Yocto project release. As of April 2017, this is the most recent release. Run the following command, which should clone poky into ~/poky/.

Checkout The Correct Branch Of poky

Now change into the poky directory:

Switch to the morty branch:

(with new versions of git, this will automatically set it up to track origin/morty).

Initialise Build Environment

Before you can start a Linux build, you need to initialise the Yocto build environment. This can be done with the following command:

After running this command, you should of automatically been moved into the poky/build/ directory.

This command needs to be re-run everytime your environment variables get reset (e.g. everytime you login).

Build Linux

We’re almost at Linux building time! We won’t touch any of the config files for now, and just build Linux using Yocto’s default settings. Run the following command (from the poky/build/ directory):

Now go grab a coffee. Or better yet, take your family out to a restaurant for a nice meal. This is going to TAKE A WHILE

An embedded Linux build in progress (using Yocto), note the CPU usage!

Make sure your computer is not set to go to sleep/shutdown after 1-2 hours of activity, otherwise you might find the build won’t complete!

Yocto will calculate all dependencies, download them, and compile! (make sure you have an o.k. internet connection).

You can safely ignore (usually)   most of the orange “Failed to fetch URL…” warnings that pop-up as the build progresses, as Yocto can attempt to download them from other sources.

After the build was complete, Yocto had used about 35GB of hard drive memory. The output build images should be in poky/build/tmp/deploy/images/. You can now test out the Linux image you just built by running it in QEMU:

This should load up a separate window, and display a GUI of the Linux image you just built.

Running the finished Yocto build in QEMU (an emulator).

The Project Configuration File

The main configuration for a Yocto project is located at poky/build/conf/local.conf.

Moving The Entire Yocto Project Directory Somewhere Else

Moving the entire Yocto project directory isn’t as straightforward as you might think (e.g. moving or renaming the poky folder). Because Yocto stores a small but non-zero amount of information in the project using absolute paths (gasp!), moving/renaming this folder will break a build (assuming a build has already been completed at least once, if not, you’re o.k.!).

You will probably receive an error message along the lines of:

 

Oh no! I have to rebuild? But that took hours! Luckily, you can fix this without having to do a complete rebuild. Upon receiving this error, open up the poky/build/tmp/saved_tmpdir file in a text editor, and update the path to the new location (the path should be the only thing in this file).

You should now be able to run bitbake ... without any errors, and without having to restart the build from scratch.