3.10.1. Building a Simple Image

In the development environment, you need to build an image whenever you change hardware support, add or change system libraries, or add or change services that have dependencies. Several methods exist that allow you to build an image within the Yocto Project. This section presents the basic steps you need to build a simple image using BitBake from a build host running Linux.

Notes

The build process creates an entire Linux distribution from source and places it in your Build Directory under tmp/deploy/images. For detailed information on the build process using BitBake, see the "Images" section in the Yocto Project Overview and Concepts Manual.

The following figure and list overviews the build process:

  1. Set up Your Host Development System to Support Development Using the Yocto Project: See the "Setting Up to Use the Yocto Project" section for options on how to get a build host ready to use the Yocto Project.

  2. Initialize the Build Environment: Initialize the build environment by sourcing the build environment script (i.e. oe-init-build-env):

         $ source oe-init-build-env [build_dir]
                            

    When you use the initialization script, the OpenEmbedded build system uses build as the default Build Directory in your current work directory. You can use a build_dir argument with the script to specify a different build directory.

    Tip

    A common practice is to use a different Build Directory for different targets. For example, ~/build/x86 for a qemux86 target, and ~/build/arm for a qemuarm target.

  3. Make Sure Your local.conf File is Correct: Ensure the conf/local.conf configuration file, which is found in the Build Directory, is set up how you want it. This file defines many aspects of the build environment including the target machine architecture through the MACHINE variable, the packaging format used during the build (PACKAGE_CLASSES), and a centralized tarball download directory through the DL_DIR variable.

  4. Build the Image: Build the image using the bitbake command:

         $ bitbake target
                            

    Note

    For information on BitBake, see the BitBake User Manual.

    The target is the name of the recipe you want to build. Common targets are the images in meta/recipes-core/images, meta/recipes-sato/images, and so forth all found in the Source Directory. Or, the target can be the name of a recipe for a specific piece of software such as BusyBox. For more details about the images the OpenEmbedded build system supports, see the "Images" chapter in the Yocto Project Reference Manual.

    As an example, the following command builds the core-image-minimal image:

         $ bitbake core-image-minimal
                            

    Once an image has been built, it often needs to be installed. The images and kernels built by the OpenEmbedded build system are placed in the Build Directory in tmp/deploy/images. For information on how to run pre-built images such as qemux86 and qemuarm, see the Yocto Project Application Development and the Extensible Software Development Kit (eSDK) manual. For information about how to install these images, see the documentation for your particular board or machine.