Skip to main content

Yocto & BitBake Cheatsheet

Quick reference for BitBake, bitbake-layers, devtool, and recipe debugging in the Yocto Project.

Initialize Build Environment​

# Initialize the build directory (defaults to build/)
source oe-init-build-env build

Main config files live in build/conf/:

  • local.conf: Sets MACHINE, DL_DIR, SSTATE_DIR, IMAGE_INSTALL:append, EXTRA_IMAGE_FEATURES.
  • bblayers.conf: Lists active layers in the build.

Common BitBake Commands​

bitbake core-image-minimal # Build an image
bitbake <recipe> # Build a single recipe
bitbake -c listtasks <recipe> # List all tasks for a recipe
bitbake -c menuconfig virtual/kernel # Open Linux kernel menuconfig
bitbake -c compile -f <recipe> # Force rerun the compile task
bitbake -c clean <recipe> # Remove recipe build output
bitbake -c cleansstate <recipe> # Remove output and sstate cache
bitbake -c cleanall <recipe> # Remove output, sstate, and downloaded sources
bitbake -k <image> # Keep building after a recipe fails
bitbake -c populate_sdk <image> # Generate a cross-compile SDK

Layer Management (bitbake-layers)​

bitbake-layers show-layers # List active layers and priorities
bitbake-layers add-layer ../meta-custom
bitbake-layers remove-layer ../meta-custom
bitbake-layers create-layer ../meta-custom
bitbake-layers show-recipes "*nginx*" # Search recipes by name
bitbake-layers show-appends # Show active .bbappend files

Fast Iteration with devtool​

devtool modify <recipe> # Check out source into workspace/sources/<recipe>
devtool build <recipe> # Build the modified recipe
devtool deploy-target <recipe> root@<board-ip> # Push binaries to target board over SSH
devtool update-recipe <recipe> # Export edits as patches into the layer
devtool finish <recipe> <layer-path> # Update recipe and clean workspace
devtool reset <recipe> # Discard workspace changes

Debugging Recipes & Variables​

# Inspect final value and assignment history of a variable
bitbake -e <recipe> | grep "^SRC_URI="
bitbake -e <recipe> | grep "^IMAGE_INSTALL="

# Open an interactive shell with the recipe's build environment
bitbake -c devshell <recipe>

# Generate dependency graph (creates task-depends.dot)
bitbake -g <image>

Build logs and output artifacts live at:

  • tmp/work/<arch>/<recipe>/<version>/temp/log.do_<task>
  • tmp/deploy/images/<machine>/ (kernel, dtb, rootfs, .wic images)

Flashing Images to SD Card (bmaptool)​

bmaptool is much faster than dd because it skips empty blocks and verifies checksums via the .bmap file:

sudo bmaptool copy tmp/deploy/images/raspberrypi4/core-image-minimal.rootfs.wic.zst /dev/sdX

References​