ES: Yocto Scripts and Utility Commands

The Yocto Project includes a scripts directory with utilities that automate common development tasks. Knowing the right commands for listing images, managing layers, finding machines, and working with recipes dramatically improves development efficiency.

The Yocto build environment includes a scripts/ directory containing utilities and tools that extend the BitBake command-line experience. These scripts help you explore the build system, manage layers, and perform routine operations efficiently.


The scripts Directory

The scripts/ directory in the Poky tree contains various tools that automate common tasks:

md
poky/scripts/
├── bitbake-layers      (layer management tool)
├── create-recipe       (recipe scaffolding tool)
├── oe-setup-builddir   (build directory setup)
├── runqemu             (QEMU launcher for Yocto images)
└── ...

All these tools are available in your PATH after sourcing oe-init-build-env.


Working with Images

List All Available Images

Find all image recipes across all meta layers in the current directory:

bash
find . -name "*.bb" | grep image

List only the images that are visible to BitBake from the configured layers:

bash
bitbake -s | grep image

The second command is more accurate — it only shows images that BitBake can actually build with the current layer configuration.


Working with Layers

Add a Layer

bash
bitbake-layers add-layer <layer-path>

Example:

bash
bitbake-layers add-layer /home/user/poky/meta-raspberrypi

This automatically updates build/conf/bblayers.conf.

List Configured Layers

bash
bitbake-layers show-layers

Example output:

md
layer                 path                             priority
================================================================
meta                  /home/amr/poky/meta                   5
meta-poky             /home/amr/poky/meta-poky              5
meta-yocto-bsp        /home/amr/poky/meta-yocto-bsp         5
meta-raspberrypi      /home/amr/poky/meta-raspberrypi       9


Working with Machines

Show the Current Active Machine

bash
bitbake -e | grep "^MACHINE="

This evaluates the full BitBake environment and extracts the MACHINE variable, showing exactly what target is configured.

List Machines from a Specific Layer

bash
find meta-* -name "*.conf" | grep "machine"

Or more broadly:

bash
find . -type f -name "*.conf" | grep "machine"

Each .conf file in a machine/ subdirectory represents a supported machine configuration. The filename (without .conf) is the value you set for MACHINE in local.conf.


Working with Recipes

List Tasks for a Recipe

bash
bitbake -c listtasks core-image-minimal

Execute a Specific Task

Run a task for a recipe by specifying the task name without the do_ prefix:

bash
bitbake -c fetch busybox

Fetch All Dependencies

Download all source archives for an image without building:

bash
bitbake -c fetchall core-image-minimal

Useful for preparing an offline build environment.

Clean a Recipe

Remove all build artifacts and downloaded sources for a recipe:

bash
bitbake -c cleanall busybox

Debug a Recipe Interactively

Open a shell with the full BitBake build environment set up, inside the recipe's source directory:

bash
bitbake -c devshell <recipe-name>

This is the most powerful debugging tool for recipe development — you can run compile commands manually, inspect environment variables, and test fixes interactively.


Quick Reference Table

TaskCommand
List all images`find . -name "*.bb" \grep image`
List buildable images`bitbake -s \grep image`
Add a layerbitbake-layers add-layer <path>
Show layersbitbake-layers show-layers
Current machine`bitbake -e \grep "^MACHINE="`
Find machines in layers`find meta- -name ".conf" \grep machine`
List recipe tasksbitbake -c listtasks <recipe>
Run a taskbitbake -c <task> <recipe>
Fetch all sourcesbitbake -c fetchall <image>
Clean a recipebitbake -c cleanall <recipe>
Debug a recipebitbake -c devshell <recipe>

Running the Image with runqemu

The runqemu script launches Yocto-generated images in QEMU with a single command:

bash
runqemu qemuarm

Run without graphics (serial console only):

bash
runqemu qemuarm nographic

Additional options:

bash
# Specify a build directory
runqemu qemuarm nographic slirp

# Run with KVM acceleration (x86 only)
runqemu qemux86-64 kvm

# Run with specific image
runqemu qemuarm core-image-minimal nographic


Final Thoughts

These utility commands are the daily tools of a Yocto developer. Knowing them by heart reduces the friction of exploring an unfamiliar build configuration, troubleshooting build failures, and iterating on recipe development.

md
Essential Yocto Development Commands:
Start session:   source oe-init-build-env
Build image:     bitbake core-image-minimal
Run in QEMU:     runqemu qemuarm nographic
Check layers:    bitbake-layers show-layers
Debug recipe:    bitbake -c devshell <recipe>
List images:     bitbake -s | grep image
Find machines:   find meta-* -name "*.conf" | grep machine

Bookmark this reference — these commands will be used in every Yocto development session.