This version of the project is now considered obsolete, please select and use a more recent version.

The Yocto Project Quick Start

Copyright © 2010-2012 Linux Foundation

Welcome!

Welcome to the Yocto Project! The Yocto Project is an open-source collaboration project focused on embedded Linux developers. Amongst other things, the Yocto Project uses the Poky build system to construct complete Linux images.

If you don't have a system that runs Linux and you want to give the Yocto Project a test run, you might consider using the Yocto Project Build Appliance. The Build Appliance allows you to build and boot a custom embedded Linux image with the Yocto Project using a non-Linux development system. See the Yocto Project Build Appliance for more information.

On the other hand, if you know all about open-source development, Linux development environments, Git source repositories and the like and you just want some quick information that lets you try out the Yocto Project on your Linux system, skip right to the "Super User" section at the end of this quick start.

For the rest of you, this short document will give you some basic information about the environment and let you experience it in its simplest form. After reading this document, you will have a basic understanding of what the Yocto Project is and how to use some of its core components. This document steps you through a simple example showing you how to build a small image and run it using the QEMU emulator.

For more detailed information on the Yocto Project, you should check out these resources:

Note

Due to production processes, there could be differences between the Yocto Project documentation bundled in the release tarball and the Yocto Project Quick Start on the Yocto Project website. For the latest version of this manual, see the manual on the website.

Introducing the Yocto Project Development Environment

The Yocto Project through the Poky build system provides an open source development environment targeting the ARM, MIPS, PowerPC and x86 architectures for a variety of platforms including x86-64 and emulated ones. You can use components from the Yocto Project to design, develop, build, debug, simulate, and test the complete software stack using Linux, the X Window System, GNOME Mobile-based application frameworks, and Qt frameworks.

The Yocto Project Development Environment

Here are some highlights for the Yocto Project:

  • Provides a recent Linux kernel along with a set of system commands and libraries suitable for the embedded environment.

  • Makes available system components such as X11, Matchbox, GTK+, Pimlico, Clutter, GuPNP and Qt (among others) so you can create a richer user interface experience on devices that use displays or have a GUI. For devices that don't have a GUI or display, you simply would not employ these components.

  • Creates a focused and stable core compatible with the OpenEmbedded project with which you can easily and reliably build and develop.

  • Fully supports a wide range of hardware and device emulation through the QEMU Emulator.

The Yocto Project can generate images for many kinds of devices. However, the standard example machines target QEMU full-system emulation for x86, x86-64, ARM, MIPS, and PPC-based architectures as well as specific hardware such as the Intel® Desktop Board DH55TC. Because an image developed with the Yocto Project can boot inside a QEMU emulator, the development environment works nicely as a test platform for developing embedded software.

Another important Yocto Project feature is the Sato reference User Interface. This optional GNOME mobile-based UI, which is intended for devices with restricted screen sizes, sits neatly on top of a device using the GNOME Mobile Stack and provides a well-defined user experience. Implemented in its own layer, it makes it clear to developers how they can implement their own user interface on top of Yocto Linux.

What You Need and How You Get It

You need these things to develop in the Yocto Project environment:

  • A host system running a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, and Ubuntu). If the host system supports multiple cores and threads, you can configure the Yocto Project build system to decrease the time needed to build images significantly.

  • The right packages.

  • A release of Yocto Project.

The Linux Distribution

The Yocto Project team is continually verifying more and more Linux distributions with each release. In general, if you have the current release minus one of the following distributions you should have no problems.

  • Ubuntu

  • Fedora

  • openSUSE

  • CentOS

For a list of the distributions under validation and their status, see the Distribution Support wiki page.

Note

For notes about using the Yocto Project on a RHEL 4-based host, see the BuildingOnRHEL4 wiki page.

The build system should be able to run on any modern distribution with Python 2.6 or 2.7. Earlier releases of Python are known to not work and the system does not support Python 3 at this time. This document assumes you are running one of the previously noted distributions on your Linux-based host systems.

Note

If you attempt to use a distribution not in the above list, you may or may not have success - you are venturing into untested territory. Refer to OE and Your Distro and Required Software for information for other distributions used with the OpenEmbedded project, which might be a starting point for exploration. If you go down this path, you should expect problems. When you do, please go to Yocto Project Bugzilla and submit a bug. We are interested in hearing about your experience.

The Packages

Packages and package installation vary depending on your development system. In general, you need to have root access and then install the required packages. The next few sections show you how to get set up with the right packages for Ubuntu, Fedora, openSUSE, and CentOS.

Ubuntu

The packages you need for a supported Ubuntu distribution are shown in the following command:

     $ sudo apt-get install sed wget cvs subversion git-core coreutils \
     unzip texi2html texinfo libsdl1.2-dev docbook-utils fop gawk \
     python-pysqlite2 diffstat help2man make gcc build-essential xsltproc \
     g++ desktop-file-utils chrpath libgl1-mesa-dev libglu1-mesa-dev \
     mercurial autoconf automake groff libtool xterm libxml-parser-perl
                

Fedora

The packages you need for a supported Fedora distribution are shown in the following commands:

     $ sudo yum groupinstall "development tools"
     $ sudo yum install python m4 make wget curl ftp hg tar bzip2 gzip \
     unzip python-psyco perl texinfo texi2html diffstat openjade \
     docbook-style-dsssl sed docbook-style-xsl docbook-dtds fop xsltproc \
     docbook-utils sed bc eglibc-devel ccache pcre pcre-devel quilt \
     groff linuxdoc-tools patch linuxdoc-tools cmake help2man \
     perl-ExtUtils-MakeMaker tcl-devel gettext chrpath ncurses apr \
     SDL-devel mesa-libGL-devel mesa-libGLU-devel gnome-doc-utils \
     autoconf automake libtool xterm
                

Note

If you are using a Fedora version prior to version 15, you will need to take some extra steps to enable sudo, or you will need to run the commands as root user. See the Configuring Sudo wiki page for details. For information on other dependencies you will need to install, see the Fedora section on the Poky/GettingStarted/Dependencies wiki page.

openSUSE

The packages you need for a supported openSUSE distribution are shown in the following command:

     $ sudo zypper install python gcc gcc-c++ libtool fop \
     subversion git chrpath automake make wget help2man xsltproc \
     diffstat texinfo mercurial freeglut-devel libSDL-devel
                

CentOS

The packages you need for a supported CentOS distribution are shown in the following commands:

     $ sudo yum -y groupinstall "development tools"
     $ sudo yum -y install tetex gawk sqlite-devel vim-common redhat-lsb xz \
       m4 make wget curl ftp tar bzip2 gzip python-devel \
       unzip perl texinfo texi2html diffstat openjade zlib-devel \
       docbook-style-dsssl sed docbook-style-xsl docbook-dtds \
       docbook-utils bc glibc-devel pcre pcre-devel \
       groff linuxdoc-tools patch linuxdoc-tools cmake \
       tcl-devel gettext ncurses apr \
       SDL-devel mesa-libGL-devel mesa-libGLU-devel gnome-doc-utils \
       autoconf automake libtool xterm
                

Note

Depending on the CentOS version you are using, other requirements and dependencies might exist. For details, you should look at the CentOS sections on the Poky/GettingStarted/Dependencies wiki page.

Yocto Project Release

You can download the latest Yocto Project release by going to the Yocto Project Download page. Just go to the page and click the "Yocto Downloads" link found in the "Download" navigation pane to the right to view all available Yocto Project releases. Then, click the "Yocto Release" link for the release you want from the list to begin the download. Nightly and developmental builds are also maintained at http://autobuilder.yoctoproject.org/nightly/. However, for this document a released version of Yocto Project is used.

You can also get the Yocto Project files by setting up a Git repository on your host development system. Doing so allows you to contribute back to the project. For information on how to get set up using this method, see the "Yocto Project Release" item in The Yocto Project Development Manual.

A Quick Test Run

Now that you have your system requirements in order, you can give Yocto Project a try. This section presents some steps that let you do the following:

  • Build an image and run it in the QEMU emulator

  • Use a pre-built image and run it in the QEMU emulator

Building an Image

In the development environment you will need to build an image whenever you change hardware support, add or change system libraries, or add or change services that have dependencies.

Building an Image

Use the following commands to build your image. The build process creates an entire Linux distribution, including the toolchain, from source.

Note

The build process using Sato currently consumes about 50GB of disk space. To allow for variations in the build process and for future package expansion, we recommend having at least 100GB of free disk space.

Note

By default, the Yocto Project searches for source code using a pre-determined order through a set of locations. If you encounter problems with the Yocto Project finding and downloading source code, see the FAQ entry "How does the Yocto Project build system obtain source code and will it work behind my firewall or proxy server?" in The Yocto Project Reference Manual.

     $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.2/poky-denzil-7.0.tar.bz2
     $ tar xjf poky-denzil-7.0.tar.bz2
     $ source poky-denzil-7.0/oe-init-build-env poky-denzil-7.0-build
             

Tip

To help conserve disk space during builds, you can add the following statement to your project's configuration file, which for this example is poky-denzil-7.0-build/conf/local.conf. Adding this statement deletes the work directory used for building a package once the package is built.

     INHERIT += rm_work
             

  • In the previous example, the first command retrieves the Yocto Project release tarball from the source repositories using the wget command. Alternatively, you can go to the Yocto Project website Downloads page to retrieve the tarball.

  • The second command extracts the files from the tarball and places them into a directory named poky-denzil-7.0 in the current directory.

  • The third command runs the Yocto Project environment setup script. Running this script defines Yocto Project build environment settings needed to complete the build. The script also creates the Yocto Project build directory, which is poky-denzil-7.0-build in this case. After the script runs, your current working directory is set to the build directory. Later, when the build completes, the build directory contains all the files created during the build.

Take some time to examine your local.conf file in your project's configuration directory. The defaults in that file should work fine. However, there are some variables of interest at which you might look.

By default, the target architecture for the build is qemux86, which produces an image that can be used in the QEMU emulator and is targeted at an Intel® 32-bit based architecture. To change this default, edit the value of the MACHINE variable in the configuration file before launching the build.

Another couple of variables of interest are the BB_NUMBER_THREADS and the PARALLEL_MAKE variables. By default, these variables are commented out. However, if you have a multi-core CPU you might want to uncomment the lines and set both variables equal to twice the number of your host's processor cores. Setting these variables can significantly shorten your build time.

Another consideration before you build is the package manager used when creating the image. By default, the Yocto Project build system uses the RPM package manager. You can control this configuration by using the PACKAGE_CLASSES variable. For additional package manager selection information, see "Packaging - package*.bbclass" in The Yocto Project Reference Manual.

Continue with the following command to build an OS image for the target, which is core-image-sato in this example. For information on the -k option use the bitbake --help command or see the "BitBake" section in The Yocto Project Reference Manual.

     $ bitbake -k core-image-sato
             

Note

BitBake requires Python 2.6 or 2.7. For more information on this requirement, see the FAQ in The Yocto Project Reference Manual.

The final command runs the image:

     $ runqemu qemux86
             

Note

Depending on the number of processors and cores, the amount or RAM, the speed of your Internet connection and other factors, the build process could take several hours the first time you run it. Subsequent builds run much faster since parts of the build are cached.

Using Pre-Built Binaries and QEMU

If hardware, libraries and services are stable, you can get started by using a pre-built binary of the filesystem image, kernel, and toolchain and run it using the QEMU emulator. This scenario is useful for developing application software.

Using a Pre-Built Image

For this scenario, you need to do several things:

  • Install the appropriate stand-alone Yocto toolchain tarball.

  • Download the pre-built image that will boot with QEMU. You need to be sure to get the QEMU image that matches your target machine’s architecture (e.g. x86, ARM, etc.).

  • Download the filesystem image for your target machine's architecture.

  • Set up the environment to emulate the hardware and then start the QEMU emulator.

Installing the Toolchain

You can download the pre-built toolchain, which includes the runqemu script and support files, from the appropriate directory under http://downloads.yoctoproject.org/releases/yocto/yocto-1.2/toolchain/. Toolchains are available for 32-bit and 64-bit development systems from the i686 and x86-64 directories, respectively. Each type of development system supports five target architectures. The tarball files are named such that a string representing the host system appears first in the filename and then is immediately followed by a string representing the target architecture.

     poky-eglibc-<host_system>-<arch>-toolchain-gmae-<release>.tar.bz2

     Where:
         <host_system> is a string representing your development system: 
                i686 or x86_64.
       
         <arch> is a string representing the target architecture: 
                i586, x86_64, powerpc, mips, or arm.
       
         <release> is the version of Yocto Project.
            

For example, the following toolchain tarball is for a 64-bit development host system and a 32-bit target architecture:

     poky-eglibc-x86_64-i586-toolchain-gmae-1.2.tar.bz2
            

The toolchain tarballs are self-contained and must be installed into /opt/poky. The following commands show how you install the toolchain tarball given a 64-bit development host system and a 32-bit target architecture. The example assumes the toolchain tarball is located in ~/toolchains/:

     $ cd /
     $ sudo tar -xvjf ~/toolchains/poky-eglibc-x86_64-i586-toolchain-gmae-1.2.tar.bz2
                

For more information on how to install tarballs, see the "Using a Cross-Toolchain Tarball" and "Using BitBake and the Yocto Project Build Tree" sections in The Yocto Project Application Development Toolkit (ADT) User's Guide.

Downloading the Pre-Built Linux Kernel

You can download the pre-built Linux kernel suitable for running in the QEMU emulator from http://downloads.yoctoproject.org/releases/yocto/yocto-1.2/machines/qemu. Be sure to use the kernel that matches the architecture you want to simulate. Download areas exist for the five supported machine architectures: qemuarm, qemumips, qemuppc, qemux86, and qemux86-64.

Most kernel files have one of the following forms:

     *zImage-qemu<arch>.bin
     vmlinux-qemu<arch>.bin

     Where:
         <arch> is a string representing the target architecture: 
                x86, x86-64, ppc, mips, or arm.
                

You can learn more about downloading a Yocto Project kernel in the "Linux Yocto Kernel" section of The Yocto Project Development Manual.

Downloading the Filesystem

You can also download the filesystem image suitable for your target architecture from http://downloads.yoctoproject.org/releases/yocto/yocto-1.2/machines/qemu. Again, be sure to use the filesystem that matches the architecture you want to simulate.

The filesystem image has two tarball forms: ext3 and tar. You must use the ext3 form when booting an image using the QEMU emulator. The tar form can be flattened out in your host development system and used for Yocto Project build purposes.

     core-image-<profile>-qemu<arch>.ext3
     core-image-<profile>-qemu<arch>.tar.bz2

     Where:
         <profile> is the filesystem image's profile:
                   lsb, lsb-dev, lsb-sdk, lsb-qt3, minimal, minimal-dev, sato, sato-dev, or sato-sdk.
                   For information on these types of image profiles, see
                   Reference: Images in the Yocto Project Reference Manual.

         <arch> is a string representing the target architecture: 
                x86, x86-64, ppc, mips, or arm.
                

Setting Up the Environment and Starting the QEMU Emulator

Before you start the QEMU emulator, you need to set up the emulation environment. The following command form sets up the emulation environment.

     $ source /opt/poky/1.2/environment-setup-<arch>-poky-linux-<if> 

     Where:
         <arch> is a string representing the target architecture: 
                i586, x86_64, ppc603e, mips, or armv5te.

         <if> is a string representing an embedded application binary interface.
              Not all setup scripts include this string.
                

Finally, this command form invokes the QEMU emulator

     $ runqemu <qemuarch> <kernel-image> <filesystem-image>

     Where:
         <qemuarch> is a string representing the target architecture: qemux86, qemux86-64, 
                    qemuppc, qemumips, or qemuarm.

         <kernel-image> is the architecture-specific kernel image.

         <filesystem-image> is the .ext3 filesystem image.

                

Continuing with the example, the following two commands setup the emulation environment and launch QEMU. This example assumes the root filesystem tarball has been downloaded and expanded, and that the kernel and filesystem are for a 32-bit target architecture.

     $ source /opt/poky/1.2/environment-setup-i686-poky-linux 
     $ runqemu qemux86 bzImage-qemux86-1.2.bin \
     core-image-sato-qemux86.ext3
                

The environment in which QEMU launches varies depending on the filesystem image and on the target architecture. For example, if you source the environment for the ARM target architecture and then boot the minimal QEMU image, the emulator comes up in a new shell in command-line mode. However, if you boot the SDK image, QEMU comes up with a GUI.

Note

Booting the PPC image results in QEMU launching in the same shell in command-line mode.

Super User

This section [1] gives you a very fast description of how to use the Yocto Project to build images for a BeagleBoard xM starting from scratch. The steps were performed on a 64-bit Ubuntu 10.04 system.

Getting the Yocto Project

Get the Yocto Project Files one of two ways:

  • Tarball: Use if you want the latest stable release:

         $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.2/poky-denzil-7.0.tar.bz2
         $ tar xvjf poky-denzil-7.0.tar.bz2
                        
  • Git Repository: Use if you want to work with cutting edge development content:

         $ git clone git://git.yoctoproject.org/poky
                        

The remainder of the section assumes the Git repository method.

Setting Up Your Host

You need some packages for everything to work. Rather than duplicate them here, look at the "The Packages" section earlier in this quick start.

Initializing the Build Environment

From the parent directory of the Yocto Project Files, initialize your environment and provide a meaningful Yocto Project Build Directory name:

     $ source poky/oe-init-build-env mybuilds
            

At this point, the mybuilds directory has been created for you and it is now your current working directory. If you don't provide your own directory name it defaults to build.

Configuring the local.conf File

Initializing the build environment creates a local.conf configuration file in the build directory. You need to manually edit this file to specify the machine you are building and to optimize your build time. Here are the minimal changes to make:

     BB_NUMBER_THREADS = "8"
     PARALLEL_MAKE = "-j 8"
     MACHINE ?= "beagleboard"
            

Briefly, set BB_NUMBER_THREADS and PARALLEL_MAKE to twice your host processor's number of cores.

A good deal that goes into a Yocto Project build is simply downloading all of the source tarballs. Maybe you have been working with another build system (OpenEmbedded, Angstrom, etc) for which you've built up a sizable directory of source tarballs. Or perhaps someone else has such a directory for which you have read access. If so, you can save time by adding the PREMIRRORS statement to your configuration file so that local directories are first checked for existing tarballs before running out to the net:

     PREMIRRORS_prepend = "\
     git://.*/.* file:///home/you/dl/ \n \
     svn://.*/.* file:///home/you/dl/ \n \
     cvs://.*/.* file:///home/you/dl/ \n \
     ftp://.*/.* file:///home/you/dl/ \n \
     http://.*/.* file:///home/you/dl/ \n \
     https://.*/.* file:///home/you/dl/ \n"
            

Building the Image

At this point, you need to select an image to build for the BeagleBoard xM. If this is your first build using the Yocto Project, you should try the smallest and simplest image:

     $ bitbake core-image-minimal
            

Now you just wait for the build to finish.

Here are some variations on the build process that could be helpful:

  • Fetch all the necessary sources without starting the build:

         $ bitbake -c fetchall core-image-minimal
                        

    This variation guarantees that you have all the sources for that BitBake target should you to disconnect from the net and want to do the build later offline.

  • Specify to continue the build even if BitBake encounters an error. By default, BitBake aborts the build when it encounters an error. This command keeps a faulty build going:

         $ bitbake -k core-image-minimal
                        



[1] Kudos and thanks to Robert P. J. Day of CrashCourse for providing the basis for this "expert" section with information from one of his wiki pages.