# Using the Yocto Project

This chapter describes common usage for the Yocto Project. The information is introductory in nature as other manuals in the Yocto Project documentation set provide more details on how to use the Yocto Project.

## Running a Build

This section provides a summary of the build process and provides information for less obvious aspects of the build process. For general information on how to build an image using the OpenEmbedded build system, see the "Building Images" section of the Yocto Project Quick Start.

### Build Overview

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

The first thing you need to do is set up the OpenEmbedded build environment by sourcing an environment setup script (i.e. `&OE_INIT_FILE;` or `oe-init-build-env-memres`). Here is an example:

         $ source &OE_INIT_FILE; [build_dir]

The build_dir argument is optional and specifies the directory the OpenEmbedded build system uses for the build - the Build Directory. If you do not specify a Build Directory, it defaults to a directory named `build` in your current working directory. 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.

Once the build environment is set up, you can build a target using:

         $ bitbake target

If you experience a build error due to resources temporarily being unavailable and it appears you should not be having this issue, it might be due to the combination of a 4.3+ Linux kernel and `systemd` version 228+ (i.e. see this link for information).

To work around this issue, you can try either of the following:

- Try the build again.

- Modify the "DefaultTasksMax" `systemd` parameter by uncommenting it and setting it to "infinity". You can find this parameter in the `system.conf` file located in `/etc/systemd` on most systems.

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`, etc. 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.

Building an image without GNU General Public License Version 3 (GPLv3), or similarly licensed, components is supported for only minimal and base images. See the "Images" chapter for more information.

### Building an Image Using GPL Components

When building an image using GPL components, you need to maintain your original settings and not switch back and forth applying different versions of the GNU General Public License. If you rebuild using different versions of GPL, dependency errors might occur due to some components not being rebuilt.

## Installing and Using the Result

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 Software Development Kit (SDK) Developer's Guide. For information about how to install these images, see the documentation for your particular board or machine.

## Debugging Tools and Techniques

The exact method for debugging build failures depends on the nature of the problem and on the system's area from which the bug originates. Standard debugging practices such as comparison against the last known working version with examination of the changes and the re-application of steps to identify the one causing the problem are valid for the Yocto Project just as they are for any other system. Even though it is impossible to detail every possible potential failure, this section provides some general tips to aid in debugging.

A useful feature for debugging is the error reporting tool. Configuring the Yocto Project to use this tool causes the OpenEmbedded build system to produce error reporting commands as part of the console output. You can enter the commands after the build completes to log error information into a common database, that can help you figure out what might be going wrong. For information on how to enable and use this feature, see the "Using the Error Reporting Tool" section in the Yocto Project Development Manual.

For discussions on debugging, see the "Debugging With the GNU Project Debugger (GDB) Remotely" section in the Yocto Project Developer's Manual and the "Working within Eclipse" section in the Yocto Project Software Development Kit (SDK) Developer's Guide.

The remainder of this section presents many examples of the `bitbake` command. You can learn about BitBake by reading the BitBake User Manual.

### Viewing Logs from Failed Tasks

You can find the log for a task in the file `${``WORKDIR``}/temp/log.do_`taskname. For example, the log for the `do_compile` task of the QEMU minimal image for the x86 machine (`qemux86`) might be in `tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/temp/log.do_compile`. To see the commands BitBake ran to generate a log, look at the corresponding `run.do_`taskname file in the same directory.

`log.do_`taskname and `run.do_`taskname are actually symbolic links to `log.do_`taskname`.`pid and `log.run_`taskname`.`pid, where pid is the PID the task had when it ran. The symlinks always point to the files corresponding to the most recent run.

### Viewing Variable Values

BitBake's `-e` option is used to display variable values after parsing. The following command displays the variable values after the configuration files (i.e. `local.conf`, `bblayers.conf`, `bitbake.conf` and so forth) have been parsed:

         $ bitbake -e

The following command displays variable values after a specific recipe has been parsed. The variables include those from the configuration as well:

         $ bitbake -e recipename

Each recipe has its own private set of variables (datastore). Internally, after parsing the configuration, a copy of the resulting datastore is made prior to parsing each recipe. This copying implies that variables set in one recipe will not be visible to other recipes.

Likewise, each task within a recipe gets a private datastore based on the recipe datastore, which means that variables set within one task will not be visible to other tasks.

In the output of `bitbake -e`, each variable is preceded by a description of how the variable got its value, including temporary values that were later overriden. This description also includes variable flags (varflags) set on the variable. The output can be very helpful during debugging.

Variables that are exported to the environment are preceded by `export` in the output of `bitbake -e`. See the following example:

         export CC="i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/ulf/poky/build/tmp/sysroots/qemux86"

In addition to variable values, the output of the `bitbake -e` and `bitbake -e` recipe commands includes the following information:

- The output starts with a tree listing all configuration files and classes included globally, recursively listing the files they include or inherit in turn. Much of the behavior of the OpenEmbedded build system (including the behavior of the normal recipe build tasks) is implemented in the `base` class and the classes it inherits, rather than being built into BitBake itself.

- After the variable values, all functions appear in the output. For shell functions, variables referenced within the function body are expanded. If a function has been modified using overrides or using override-style operators like `_append` and `_prepend`, then the final assembled function body appears in the output.

### Viewing Package Information with `oe-pkgdata-util`

You can use the `oe-pkgdata-util` command-line utility to query `PKGDATA_DIR` and display various package-related information. When you use the utility, you must use it to view information on packages that have already been built.

Following are a few of the available `oe-pkgdata-util` subcommands.

You can use the standard * and ? globbing wildcards as part of package names and paths.

- `oe-pkgdata-util list-pkgs [`pattern`]`: Lists all packages that have been built, optionally limiting the match to packages that match pattern.

- `oe-pkgdata-util list-pkg-files` package`...`: Lists the files and directories contained in the given packages.

  A different way to view the contents of a package is to look at the `${``WORKDIR``}/packages-split` directory of the recipe that generates the package. This directory is created by the `do_package` task and has one subdirectory for each package the recipe generates, which contains the files stored in that package.

  If you want to inspect the `${WORKDIR}/packages-split` directory, make sure that `rm_work` is not enabled when you build the recipe.

- `oe-pkgdata-util find-path` path`...`: Lists the names of the packages that contain the given paths. For example, the following tells us that `/usr/share/man/man1/make.1` is contained in the `make-doc` package:

           $ oe-pkgdata-util find-path /usr/share/man/man1/make.1
           make-doc: /usr/share/man/man1/make.1

- `oe-pkgdata-util lookup-recipe` package`...`: Lists the name of the recipes that produce the given packages.

For more information on the `oe-pkgdata-util` command, use the help facility:

         $ oe-pkgdata-util &dash;&dash;help
         $ oe-pkgdata-util subcommand --help

### Viewing Dependencies Between Recipes and Tasks

Sometimes it can be hard to see why BitBake wants to build other recipes before the one you have specified. Dependency information can help you understand why a recipe is built.

To generate dependency information for a recipe, run the following command:

         $ bitbake -g recipename

This command writes the following files in the current directory:

- `pn-buildlist`: A list of recipes/targets involved in building recipename. "Involved" here means that at least one task from the recipe needs to run when building recipename from scratch. Targets that are in `ASSUME_PROVIDED` are not listed.

- `task-depends.dot`: A graph showing dependencies between tasks.

The graphs are in DOT format and can be converted to images (e.g. using the `dot` tool from Graphviz).

#### Notes

- DOT files use a plain text format. The graphs generated using the `bitbake -g` command are often so large as to be difficult to read without special pruning (e.g. with Bitbake's `-I` option) and processing. Despite the form and size of the graphs, the corresponding `.dot` files can still be possible to read and provide useful information.

  As an example, the `task-depends.dot` file contains lines such as the following:

           "libxslt.do_configure" -> "libxml2.do_populate_sysroot"

  The above example line reveals that the `do_configure` task in `libxslt` depends on the `do_populate_sysroot` task in `libxml2`, which is a normal `DEPENDS` dependency between the two recipes.

- For an example of how `.dot` files can be processed, see the `scripts/contrib/graph-tool` Python script, which finds and displays paths between graph nodes.

You can use a different method to view dependency information by using the following command:

         $ bitbake -g -u taskexp recipename

This command displays a GUI window from which you can view build-time and runtime dependencies for the recipes involved in building recipename.

### Viewing Task Variable Dependencies

As mentioned in the "Checksums (Signatures)" section of the BitBake User Manual, BitBake tries to automatically determine what variables a task depends on so that it can rerun the task if any values of the variables change. This determination is usually reliable. However, if you do things like construct variable names at runtime, then you might have to manually declare dependencies on those variables using `vardeps` as described in the "Variable Flags" section of the BitBake User Manual.

If you are unsure whether a variable dependency is being picked up automatically for a given task, you can list the variable dependencies BitBake has determined by doing the following:

1. Build the recipe containing the task:

            $ bitbake recipename

2. Inside the `STAMPS_DIR` directory, find the signature data (`sigdata`) file that corresponds to the task. The `sigdata` files contain a pickled Python database of all the metadata that went into creating the input checksum for the task. As an example, for the `do_fetch` task of the `db` recipe, the `sigdata` file might be found in the following location:

            ${BUILDDIR}/tmp/stamps/i586-poky-linux/db/6.0.30-r1.do_fetch.sigdata.7c048c18222b16ff0bcee2000ef648b1

   For tasks that are accelerated through the shared state (sstate) cache, an additional `siginfo` file is written into `SSTATE_DIR` along with the cached task output. The `siginfo` files contain exactly the same information as `sigdata` files.

3. Run `bitbake-dumpsig` on the `sigdata` or `siginfo` file. Here is an example:

            $ bitbake-dumpsig ${BUILDDIR}/tmp/stamps/i586-poky-linux/db/6.0.30-r1.do_fetch.sigdata.7c048c18222b16ff0bcee2000ef648b1

   In the output of the above command, you will find a line like the following, which lists all the (inferred) variable dependencies for the task. This list also includes indirect dependencies from variables depending on other variables, recursively.

            Task dependencies: ['PV', 'SRCREV', 'SRC_URI', 'SRC_URI[md5sum]', 'SRC_URI[sha256sum]', 'base_do_fetch']

   Functions (e.g. `base_do_fetch`) also count as variable dependencies. These functions in turn depend on the variables they reference.

   The output of `bitbake-dumpsig` also includes the value each variable had, a list of dependencies for each variable, and `BB_HASHBASE_WHITELIST` information.

There is also a `bitbake-diffsigs` command for comparing two `siginfo` or `sigdata` files. This command can be helpful when trying to figure out what changed between two versions of a task. If you call `bitbake-diffsigs` with just one file, the command behaves like `bitbake-dumpsig`.

You can also use BitBake to dump out the signature construction information without executing tasks by using either of the following BitBake command-line options:

         &dash;&dash;dump-signatures=SIGNATURE_HANDLER
         -S SIGNATURE_HANDLER

Two common values for SIGNATURE_HANDLER are "none" and "printdiff", which dump only the signature or compare the dumped signature with the cached one, respectively.

Using BitBake with either of these options causes BitBake to dump out `sigdata` files in the `stamps` directory for every task it would have executed instead of building the specified target package.

### Running Specific Tasks

Any given recipe consists of a set of tasks. The standard BitBake behavior in most cases is: `do_fetch`, `do_unpack`, `do_patch`, `do_configure`, `do_compile`, `do_install`, `do_package`, `do_package_write_*`, and `do_build`. The default task is `do_build` and any tasks on which it depends build first. Some tasks, such as `do_devshell`, are not part of the default build chain. If you wish to run a task that is not part of the default build chain, you can use the `-c` option in BitBake. Here is an example:

         $ bitbake matchbox-desktop -c devshell

The `-c` option respects task dependencies, which means that all other tasks (including tasks from other recipes) that the specified task depends on will be run before the task. Even when you manually specify a task to run with `-c`, BitBake will only run the task if it considers it "out of date". See the "Stamp Files and the Rerunning of Tasks" section for how BitBake determines whether a task is "out of date".

If you want to force an up-to-date task to be rerun (e.g. because you made manual modifications to the recipe's `WORKDIR` that you want to try out), then you can use the `-f` option.

The reason `-f` is never required when running the `do_devshell` task is because the `[``nostamp``]` variable flag is already set for the task.

The following example shows one way you can use the `-f` option:

         $ bitbake matchbox-desktop
                   .
                   .
         make some changes to the source code in the work directory
                   .
                   .
         $ bitbake matchbox-desktop -c compile -f
         $ bitbake matchbox-desktop

This sequence first builds and then recompiles `matchbox-desktop`. The last command reruns all tasks (basically the packaging tasks) after the compile. BitBake recognizes that the `do_compile` task was rerun and therefore understands that the other tasks also need to be run again.

Another, shorter way to rerun a task and all normal recipe build tasks that depend on it is to use the `-C` option.

This option is upper-cased and is separate from the `-c` option, which is lower-cased.

Using this option invalidates the given task and then runs the `do_build` task, which is the default task if no task is given, and the tasks on which it depends. You could replace the final two commands in the previous example with the following single command:

         $ bitbake matchbox-desktop -C compile

Internally, the `-f` and `-C` options work by tainting (modifying) the input checksum of the specified task. This tainting indirectly causes the task and its dependent tasks to be rerun through the normal task dependency mechanisms.

BitBake explicitly keeps track of which tasks have been tainted in this fashion, and will print warnings such as the following for builds involving such tasks:

         WARNING: /home/ulf/poky/meta/recipes-sato/matchbox-desktop/matchbox-desktop_2.1.bb.do_compile is tainted from a forced run

The purpose of the warning is to let you know that the work directory and build output might not be in the clean state they would be in for a "normal" build, depending on what actions you took. To get rid of such warnings, you can remove the work directory and rebuild the recipe, as follows:

         $ bitbake matchbox-desktop -c clean
         $ bitbake matchbox-desktop

You can view a list of tasks in a given package by running the `do_listtasks` task as follows:

         $ bitbake matchbox-desktop -c listtasks

The results appear as output to the console and are also in the file `${WORKDIR}/temp/log.do_listtasks`.

### General BitBake Problems

You can see debug output from BitBake by using the `-D` option. The debug output gives more information about what BitBake is doing and the reason behind it. Each `-D` option you use increases the logging level. The most common usage is `-DDD`.

The output from `bitbake -DDD -v` targetname can reveal why BitBake chose a certain version of a package or why BitBake picked a certain provider. This command could also help you in a situation where you think BitBake did something unexpected.

### Development Host System Issues

Sometimes issues on the host development system can cause your build to fail. Following are known, host-specific problems. Be sure to always consult the Release Notes for a look at all release-related issues.

- `glibc-initial` fails to build: If your development host system has the unpatched `GNU Make 3.82`, the `do_install` task fails for `glibc-initial` during the build.

  Typically, every distribution that ships `GNU Make 3.82` as the default already has the patched version. However, some distributions, such as Debian, have `GNU Make 3.82` as an option, which is unpatched. You will see this error on these types of distributions. Switch to `GNU Make 3.81` or patch your `make` to solve the problem.

### Building with No Dependencies

To build a specific recipe (`.bb` file), you can use the following command form:

         $ bitbake -b somepath/somerecipe.bb

This command form does not check for dependencies. Consequently, you should use it only when you know existing dependencies have been met.

You can also specify fragments of the filename. In this case, BitBake checks for a unique match.

### Recipe Logging Mechanisms

The Yocto Project provides several logging functions for producing debugging output and reporting errors and warnings. For Python functions, the following logging functions exist. All of these functions log to `${T}/log.do_`task, and can also log to standard output (stdout) with the right settings:

- `bb.plain(`msg`)`: Writes msg as is to the log while also logging to stdout.

- `bb.note(`msg`)`: Writes "NOTE: msg" to the log. Also logs to stdout if BitBake is called with "-v".

- `bb.debug(`level`,` msg`)`: Writes "DEBUG: msg" to the log. Also logs to stdout if the log level is greater than or equal to level. See the "-D" option in the BitBake User Manual for more information.

- `bb.warn(`msg`)`: Writes "WARNING: msg" to the log while also logging to stdout.

- `bb.error(`msg`)`: Writes "ERROR: msg" to the log while also logging to stdout.

  Calling this function does not cause the task to fail.

- `bb.fatal(`msg`)`: This logging function is similar to `bb.error(`msg`)` but also causes the calling task to fail.

  `bb.fatal()` raises an exception, which means you do not need to put a "return" statement after the function.

The same logging functions are also available in shell functions, under the names `bbplain`, `bbnote`, `bbdebug`, `bbwarn`, `bberror`, and `bbfatal`. The `logging` class implements these functions. See that class in the `meta/classes` folder of the Source Directory for information.

#### Logging With Python

When creating recipes using Python and inserting code that handles build logs, keep in mind the goal is to have informative logs while keeping the console as "silent" as possible. Also, if you want status messages in the log, use the "debug" loglevel.

Following is an example written in Python. The code handles logging for a function that determines the number of tasks needed to be run. See the "`do_listtasks`" section for additional information:

         python do_listtasks() {
             bb.debug(2, "Starting to figure out the task list")
             if noteworthy_condition:
                 bb.note("There are 47 tasks to run")
             bb.debug(2, "Got to point xyz")
             if warning_trigger:
                 bb.warn("Detected warning_trigger, this might be a problem later.")
             if recoverable_error:
                 bb.error("Hit recoverable_error, you really need to fix this!")
             if fatal_error:
                 bb.fatal("fatal_error detected, unable to print the task list")
             bb.plain("The tasks present are abc")
             bb.debug(2, "Finished figuring out the tasklist")
         }

#### Logging With Bash

When creating recipes using Bash and inserting code that handles build logs, you have the same goals - informative with minimal console output. The syntax you use for recipes written in Bash is similar to that of recipes written in Python described in the previous section.

Following is an example written in Bash. The code logs the progress of the `do_my_function` function.

         do_my_function() {
             bbdebug 2 "Running do_my_function"
             if [ exceptional_condition ]; then
                 bbnote "Hit exceptional_condition"
             fi
             bbdebug 2  "Got to point xyz"
             if [ warning_trigger ]; then
                 bbwarn "Detected warning_trigger, this might cause a problem later."
             fi
             if [ recoverable_error ]; then
                 bberror "Hit recoverable_error, correcting"
             fi
             if [ fatal_error ]; then
                 bbfatal "fatal_error detected"
             fi
             bbdebug 2 "Completed do_my_function"
         }

### Other Tips

Here are some other tips that you might find useful:

- When adding new packages, it is worth watching for undesirable items making their way into compiler command lines. For example, you do not want references to local system files like `/usr/lib/` or `/usr/include/`.

- If you want to remove the `psplash` boot splashscreen, add `psplash=false` to the kernel command line. Doing so prevents `psplash` from loading and thus allows you to see the console. It is also possible to switch out of the splashscreen by switching the virtual console (e.g. Fn+Left or Fn+Right on a Zaurus).

- Removing `TMPDIR` (usually `tmp/`, within the Build Directory) can often fix temporary build issues. Removing `TMPDIR` is usually a relatively cheap operation, because task output will be cached in `SSTATE_DIR` (usually `sstate-cache/`, which is also in the Build Directory).

  Removing `TMPDIR` might be a workaround rather than a fix. Consequently, trying to determine the underlying cause of an issue before removing the directory is a good idea.

- Understanding how a feature is used in practice within existing recipes can be very helpful. It is recommended that you configure some method that allows you to quickly search through files.

  Using GNU Grep, you can use the following shell function to recursively search through common recipe-related files, skipping binary files, `.git` directories, and the Build Directory (assuming its name starts with "build"):

           g() {
               grep -Ir \
                    --exclude-dir=.git \
                    --exclude-dir='build*' \
                    --include='*.bb*' \
                    --include='*.inc*' \
                    --include='*.conf*' \
                    --include='*.py*' \
                    "$@"
           }

  Following are some usage examples:

           $ g FOO    # Search recursively for "FOO"
           $ g -i foo # Search recursively for "foo", ignoring case
           $ g -w FOO # Search recursively for "FOO" as a word, ignoring e.g. "FOOBAR"

  If figuring out how some feature works requires a lot of searching, it might indicate that the documentation should be extended or improved. In such cases, consider filing a documentation bug using the Yocto Project implementation of Bugzilla. For general information on how to submit a bug against the Yocto Project, see the "Tracking Bugs" section in the Yocto Project Development Manual.

  The manuals might not be the right place to document variables that are purely internal and have a limited scope (e.g. internal variables used to implement a single `.bbclass` file).

## Maintaining Build Output Quality

Many factors can influence the quality of a build. For example, if you upgrade a recipe to use a new version of an upstream software package or you experiment with some new configuration options, subtle changes can occur that you might not detect until later. Consider the case where your recipe is using a newer version of an upstream package. In this case, a new version of a piece of software might introduce an optional dependency on another library, which is auto-detected. If that library has already been built when the software is building, the software will link to the built library and that library will be pulled into your image along with the new software even if you did not want the library.

The `buildhistory` class exists to help you maintain the quality of your build output. You can use the class to highlight unexpected and possibly unwanted changes in the build output. When you enable build history, it records information about the contents of each package and image and then commits that information to a local Git repository where you can examine the information.

The remainder of this section describes the following:

- How you can enable and disable build history

- How to understand what the build history contains

- How to limit the information used for build history

- How to examine the build history from both a command-line and web interface

### Enabling and Disabling Build History

Build history is disabled by default. To enable it, add the following `INHERIT` statement and set the `BUILDHISTORY_COMMIT` variable to "1" at the end of your `conf/local.conf` file found in the Build Directory:

         INHERIT += "buildhistory"
         BUILDHISTORY_COMMIT = "1"

Enabling build history as previously described causes the build process to collect build output information and commit it to a local Git repository.

Enabling build history increases your build times slightly, particularly for images, and increases the amount of disk space used during the build.

You can disable build history by removing the previous statements from your `conf/local.conf` file.

### Understanding What the Build History Contains

Build history information is kept in `${``TOPDIR``}/buildhistory` in the Build Directory as defined by the `BUILDHISTORY_DIR` variable. The following is an example abbreviated listing:

At the top level, there is a `metadata-revs` file that lists the revisions of the repositories for the layers enabled when the build was produced. The rest of the data splits into separate `packages`, `images` and `sdk` directories, the contents of which are described below.

#### Build History Package Information

The history for each package contains a text file that has name-value pairs with information about the package. For example, `buildhistory/packages/i586-poky-linux/busybox/busybox/latest` contains the following:

         PV = 1.22.1
         PR = r32
         RPROVIDES =
         RDEPENDS = glibc (>= 2.20) update-alternatives-opkg
         RRECOMMENDS = busybox-syslog busybox-udhcpc update-rc.d
         PKGSIZE = 540168
         FILES = /usr/bin/* /usr/sbin/* /usr/lib/busybox/* /usr/lib/lib*.so.* \
            /etc /com /var /bin/* /sbin/* /lib/*.so.* /lib/udev/rules.d \
            /usr/lib/udev/rules.d /usr/share/busybox /usr/lib/busybox/* \
            /usr/share/pixmaps /usr/share/applications /usr/share/idl \
            /usr/share/omf /usr/share/sounds /usr/lib/bonobo/servers
         FILELIST = /bin/busybox /bin/busybox.nosuid /bin/busybox.suid /bin/sh \
            /etc/busybox.links.nosuid /etc/busybox.links.suid

Most of these name-value pairs correspond to variables used to produce the package. The exceptions are `FILELIST`, which is the actual list of files in the package, and `PKGSIZE`, which is the total size of files in the package in bytes.

There is also a file corresponding to the recipe from which the package came (e.g. `buildhistory/packages/i586-poky-linux/busybox/latest`):

         PV = 1.22.1
         PR = r32
         DEPENDS = initscripts kern-tools-native update-rc.d-native \
            virtual/i586-poky-linux-compilerlibs virtual/i586-poky-linux-gcc \
            virtual/libc virtual/update-alternatives
         PACKAGES = busybox-ptest busybox-httpd busybox-udhcpd busybox-udhcpc \
            busybox-syslog busybox-mdev busybox-hwclock busybox-dbg \
            busybox-staticdev busybox-dev busybox-doc busybox-locale busybox

Finally, for those recipes fetched from a version control system (e.g., Git), a file exists that lists source revisions that are specified in the recipe and lists the actual revisions used during the build. Listed and actual revisions might differ when `SRCREV` is set to `${AUTOREV}`. Here is an example assuming `buildhistory/packages/qemux86-poky-linux/linux-yocto/latest_srcrev`):

         # SRCREV_machine = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
         SRCREV_machine = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
         # SRCREV_meta = "a227f20eff056e511d504b2e490f3774ab260d6f"
         SRCREV_meta = "a227f20eff056e511d504b2e490f3774ab260d6f"

You can use the `buildhistory-collect-srcrevs` command with the `-a` option to collect the stored `SRCREV` values from build history and report them in a format suitable for use in global configuration (e.g., `local.conf` or a distro include file) to override floating `AUTOREV` values to a fixed set of revisions. Here is some example output from this command:

         $ buildhistory-collect-srcrevs -a
         # i586-poky-linux
         SRCREV_pn-glibc = "b8079dd0d360648e4e8de48656c5c38972621072"
         SRCREV_pn-glibc-initial = "b8079dd0d360648e4e8de48656c5c38972621072"
         SRCREV_pn-opkg-utils = "53274f087565fd45d8452c5367997ba6a682a37a"
         SRCREV_pn-kmod = "fd56638aed3fe147015bfa10ed4a5f7491303cb4"
         # x86_64-linux
         SRCREV_pn-gtk-doc-stub-native = "1dea266593edb766d6d898c79451ef193eb17cfa"
         SRCREV_pn-dtc-native = "65cc4d2748a2c2e6f27f1cf39e07a5dbabd80ebf"
         SRCREV_pn-update-rc.d-native = "eca680ddf28d024954895f59a241a622dd575c11"
         SRCREV_glibc_pn-cross-localedef-native = "b8079dd0d360648e4e8de48656c5c38972621072"
         SRCREV_localedef_pn-cross-localedef-native = "c833367348d39dad7ba018990bfdaffaec8e9ed3"
         SRCREV_pn-prelink-native = "faa069deec99bf61418d0bab831c83d7c1b797ca"
         SRCREV_pn-opkg-utils-native = "53274f087565fd45d8452c5367997ba6a682a37a"
         SRCREV_pn-kern-tools-native = "23345b8846fe4bd167efdf1bd8a1224b2ba9a5ff"
         SRCREV_pn-kmod-native = "fd56638aed3fe147015bfa10ed4a5f7491303cb4"
         # qemux86-poky-linux
         SRCREV_machine_pn-linux-yocto = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
         SRCREV_meta_pn-linux-yocto = "a227f20eff056e511d504b2e490f3774ab260d6f"
         # all-poky-linux
         SRCREV_pn-update-rc.d = "eca680ddf28d024954895f59a241a622dd575c11"

Here are some notes on using the `buildhistory-collect-srcrevs` command:

- By default, only values where the `SRCREV` was not hardcoded (usually when `AUTOREV` was used) are reported. Use the `-a` option to see all `SRCREV` values.

- The output statements might not have any effect if overrides are applied elsewhere in the build system configuration. Use the `-f` option to add the `forcevariable` override to each output line if you need to work around this restriction.

- The script does apply special handling when building for multiple machines. However, the script does place a comment before each set of values that specifies which triplet to which they belong as shown above (e.g., `i586-poky-linux`).

#### Build History Image Information

The files produced for each image are as follows:

- `image-files:` A directory containing selected files from the root filesystem. The files are defined by `BUILDHISTORY_IMAGE_FILES`.

- `build-id.txt:` Human-readable information about the build configuration and metadata source revisions. This file contains the full build header as printed by BitBake.

- `*.dot:` Dependency graphs for the image that are compatible with `graphviz`.

- `files-in-image.txt:` A list of files in the image with permissions, owner, group, size, and symlink information.

- `image-info.txt:` A text file containing name-value pairs with information about the image. See the following listing example for more information.

- `installed-package-names.txt:` A list of installed packages by name only.

- `installed-package-sizes.txt:` A list of installed packages ordered by size.

- `installed-packages.txt:` A list of installed packages with full package filenames.

Installed package information is able to be gathered and produced even if package management is disabled for the final image.

Here is an example of `image-info.txt`:

         DISTRO = poky
         DISTRO_VERSION = 1.7
         USER_CLASSES = buildstats image-mklibs image-prelink
         IMAGE_CLASSES = image_types
         IMAGE_FEATURES = debug-tweaks
         IMAGE_LINGUAS =
         IMAGE_INSTALL = packagegroup-core-boot run-postinsts
         BAD_RECOMMENDATIONS =
         NO_RECOMMENDATIONS =
         PACKAGE_EXCLUDE =
         ROOTFS_POSTPROCESS_COMMAND = write_package_manifest; license_create_manifest; \
            write_image_manifest ; buildhistory_list_installed_image ; \
            buildhistory_get_image_installed ; ssh_allow_empty_password;  \
            postinst_enable_logging; rootfs_update_timestamp ; ssh_disable_dns_lookup ;
         IMAGE_POSTPROCESS_COMMAND =   buildhistory_get_imageinfo ;
         IMAGESIZE = 6900

Other than `IMAGESIZE`, which is the total size of the files in the image in Kbytes, the name-value pairs are variables that may have influenced the content of the image. This information is often useful when you are trying to determine why a change in the package or file listings has occurred.

#### Using Build History to Gather Image Information Only

As you can see, build history produces image information, including dependency graphs, so you can see why something was pulled into the image. If you are just interested in this information and not interested in collecting specific package or SDK information, you can enable writing only image information without any history by adding the following to your `conf/local.conf` file found in the Build Directory:

         INHERIT += "buildhistory"
         BUILDHISTORY_COMMIT = "0"
         BUILDHISTORY_FEATURES = "image"

Here, you set the `BUILDHISTORY_FEATURES` variable to use the image feature only.

#### Build History SDK Information

Build history collects similar information on the contents of SDKs (e.g. `bitbake -c populate_sdk imagename`) as compared to information it collects for images. Furthermore, this information differs depending on whether an extensible or standard SDK is being produced.

The following list shows the files produced for SDKs:

- `files-in-sdk.txt:` A list of files in the SDK with permissions, owner, group, size, and symlink information. This list includes both the host and target parts of the SDK.

- `sdk-info.txt:` A text file containing name-value pairs with information about the SDK. See the following listing example for more information.

- `sstate-task-sizes.txt:` A text file containing name-value pairs with information about task group sizes (e.g. `do_populate_sysroot` tasks have a total size). The `sstate-task-sizes.txt` file exists only when an extensible SDK is created.

- `sstate-package-sizes.txt:` A text file containing name-value pairs with information for the shared-state packages and sizes in the SDK. The `sstate-package-sizes.txt` file exists only when an extensible SDK is created.

- `sdk-files:` A folder that contains copies of the files mentioned in `BUILDHISTORY_SDK_FILES` if the files are present in the output. Additionally, the default value of `BUILDHISTORY_SDK_FILES` is specific to the extensible SDK although you can set it differently if you would like to pull in specific files from the standard SDK.

  The default files are `conf/local.conf`, `conf/bblayers.conf`, `conf/auto.conf`, `conf/locked-sigs.inc`, and `conf/devtool.conf`. Thus, for an extensible SDK, these files get copied into the `sdk-files` directory.

- The following information appears under each of the `host` and `target` directories for the portions of the SDK that run on the host and on the target, respectively:

  The following files for the most part are empty when producing an extensible SDK because this type of SDK is not constructed from packages as is the standard SDK.

  - `depends.dot:` Dependency graph for the SDK that is compatible with `graphviz`.

  - `installed-package-names.txt:` A list of installed packages by name only.

  - `installed-package-sizes.txt:` A list of installed packages ordered by size.

  - `installed-packages.txt:` A list of installed packages with full package filenames.

Here is an example of `sdk-info.txt`:

         DISTRO = poky
         DISTRO_VERSION = 1.3+snapshot-20130327
         SDK_NAME = poky-glibc-i686-arm
         SDK_VERSION = 1.3+snapshot
         SDKMACHINE =
         SDKIMAGE_FEATURES = dev-pkgs dbg-pkgs
         BAD_RECOMMENDATIONS =
         SDKSIZE = 352712

Other than `SDKSIZE`, which is the total size of the files in the SDK in Kbytes, the name-value pairs are variables that might have influenced the content of the SDK. This information is often useful when you are trying to determine why a change in the package or file listings has occurred.

#### Examining Build History Information

You can examine build history output from the command line or from a web interface.

To see any changes that have occurred (assuming you have `BUILDHISTORY_COMMIT = "1"`), you can simply use any Git command that allows you to view the history of a repository. Here is one method:

          $ git log -p

You need to realize, however, that this method does show changes that are not significant (e.g. a package's size changing by a few bytes).

A command-line tool called `buildhistory-diff` does exist, though, that queries the Git repository and prints just the differences that might be significant in human-readable form. Here is an example:

         $ ~/poky/poky/scripts/buildhistory-diff . HEAD^
         Changes to images/qemux86_64/glibc/core-image-minimal (files-in-image.txt):
            /etc/anotherpkg.conf was added
            /sbin/anotherpkg was added
            * (installed-package-names.txt):
            *   anotherpkg was added
         Changes to images/qemux86_64/glibc/core-image-minimal (installed-package-names.txt):
            anotherpkg was added
         packages/qemux86_64-poky-linux/v86d: PACKAGES: added "v86d-extras"
            * PR changed from "r0" to "r1"
            * PV changed from "0.1.10" to "0.1.12"
         packages/qemux86_64-poky-linux/v86d/v86d: PKGSIZE changed from 110579 to 144381 (+30%)
            * PR changed from "r0" to "r1"
            * PV changed from "0.1.10" to "0.1.12"

The `buildhistory-diff` tool requires the `GitPython` package. Be sure to install it using Pip3 as follows:

       $ pip3 install GitPython --user

Alternatively, you can install `python3-git` using the appropriate distribution package manager (e.g. `apt-get`, `dnf`, or `zipper`).

To see changes to the build history using a web interface, follow the instruction in the `README` file here. .

Here is a sample screenshot of the interface:

## Speeding Up the Build

Build time can be an issue. By default, the build system uses simple controls to try and maximize build efficiency. In general, the default settings for all the following variables result in the most efficient build times when dealing with single socket systems (i.e. a single CPU). If you have multiple CPUs, you might try increasing the default values to gain more speed. See the descriptions in the glossary for each variable for more information:

- `BB_NUMBER_THREADS`: The maximum number of threads BitBake simultaneously executes.

- `BB_NUMBER_PARSE_THREADS`: The number of threads BitBake uses during parsing.

- `PARALLEL_MAKE`: Extra options passed to the `make` command during the `do_compile` task in order to specify parallel compilation on the local build host.

- `PARALLEL_MAKEINST`: Extra options passed to the `make` command during the `do_install` task in order to specify parallel installation on the local build host.

As mentioned, these variables all scale to the number of processor cores available on the build system. For single socket systems, this auto-scaling ensures that the build system fundamentally takes advantage of potential parallel operations during the build based on the build machine's capabilities.

Following are additional factors that can affect build speed:

- File system type: The file system type that the build is being performed on can also influence performance. Using `ext4` is recommended as compared to `ext2` and `ext3` due to `ext4` improved features such as extents.

- Disabling the updating of access time using `noatime`: The `noatime` mount option prevents the build system from updating file and directory access times.

- Setting a longer commit: Using the "commit=" mount option increases the interval in seconds between disk cache writes. Changing this interval from the five second default to something longer increases the risk of data loss but decreases the need to write to the disk, thus increasing the build performance.

- Choosing the packaging backend: Of the available packaging backends, IPK is the fastest. Additionally, selecting a singular packaging backend also helps.

- Using `tmpfs` for `TMPDIR` as a temporary file system: While this can help speed up the build, the benefits are limited due to the compiler using `-pipe`. The build system goes to some lengths to avoid `sync()` calls into the file system on the principle that if there was a significant failure, the Build Directory contents could easily be rebuilt.

- Inheriting the `rm_work` class: Inheriting this class has shown to speed up builds due to significantly lower amounts of data stored in the data cache as well as on disk. Inheriting this class also makes cleanup of `TMPDIR` faster, at the expense of being easily able to dive into the source code. File system maintainers have recommended that the fastest way to clean up large numbers of files is to reformat partitions rather than delete files due to the linear nature of partitions. This, of course, assumes you structure the disk partitions and file systems in a way that this is practical.

Aside from the previous list, you should keep some trade offs in mind that can help you speed up the build:

- Remove items from `DISTRO_FEATURES` that you might not need.

- Exclude debug symbols and other debug information: If you do not need these symbols and other debug information, disabling the `*-dbg` package generation can speed up the build. You can disable this generation by setting the `INHIBIT_PACKAGE_DEBUG_SPLIT` variable to "1".

- Disable static library generation for recipes derived from `autoconf` or `libtool`: Following is an example showing how to disable static libraries and still provide an override to handle exceptions:

           STATICLIBCONF = "--disable-static"
           STATICLIBCONF_sqlite3-native = ""
           EXTRA_OECONF += "${STATICLIBCONF}"

  ### Notes

  - Some recipes need static libraries in order to work correctly (e.g. `pseudo-native` needs `sqlite3-native`). Overrides, as in the previous example, account for these kinds of exceptions.

  - Some packages have packaging code that assumes the presence of the static libraries. If so, you might need to exclude them as well.