Creating an image recipe in Yocto allows developers to define the set of packages and configurations that should be included in the final built image.

This guide provides steps to create an image recipe from scratch or modify an existing one.

Understand image recipes

An image recipe is a BitBake file (with a .bb extension) that specifies which packages should be included in the final image.

Digi Embedded Yocto provides several base image recipes:

  • core-image-minimal: this recipe builds the smallest possible functional Linux image. It includes only essential components required to boot the system. It’s provided by meta layer of Poky

  • core-image-base: builds upon core-image-minimal by including additional utilities and features. The core-image-base image recipe provides a runtime environment with basic system utilities, networking support, SSH access, and commonly used tools. This image is a good starting point for embedded Linux systems that require essential functionality without a full graphical user interface. It’s provided by meta layer of Poky and appended by meta-digi-dey layer to include basic Digi Embedded Yocto features.

  • dey-image-qt: a graphical Qt image available for the Wayland graphical backend

  • dey-image-webkit: a graphical WebKit image available for the Wayland graphical backend

  • dey-image-lvgl: a graphical Light and Versatile Graphics Library (LVGL) image available for the Wayland graphical backend

  • dey-image-recovery-initramfs: a basic ramdisk image with support to install software update packages (SWU)

  • dey-image-trustfence-initramfs: a basic ramdisk image required to encrypt partitions (used by Digi TrustFence for Yocto)

Create a new image recipe

To create a custom image:

  1. Navigate to your layer and create an images directory:

    $ cd /<yourpath>/meta-custom/
    $ mkdir -p recipes-images/myimage
  2. Create a new image recipe file, for example my-image.bb, with the some minimal contents:

    my-image.bb
    SUMMARY = "My Custom Yocto Image"
    LICENSE = "MIT"
    
    inherit core-image
    
    IMAGE_INSTALL += " \
        packagegroup-core-boot \
        bash \
        nano \
        curl \
    "

Modify an existing image recipe

If you want to modify an existing image recipe, the recommended approach is to extend it using a .bbappend file. Digi Embedded Yocto does this, for instance, with the core-image-base recipe. Take a look at https://github.com/digi-embedded/meta-digi/blob/scarthgap/meta-digi-dey/recipes-core/images/core-image-base.bbappend.

You can further customize this recipe by doing another .bbappend in your layer. For instance, see how you can add some packages to the image:

  1. Replicate the directory path where the original recipe is, but inside your layer:

    $ cd /<yourpath>/meta-custom/
    $ mkdir -p recipes-core/images
  2. Create here the file core-image-base.bbappend with the following contents:

    core-image-base.bbappend
    IMAGE_INSTALL += " \
        vim \
        htop \
    "

    This appends additional packages to the existing core-image-base recipe without modifying the original recipe.

Similarly, you may remove packages from the original image using:

core-image-base.bbappend
IMAGE_INSTALL:remove = "<package>"

Build the image

Once the new image recipe (or .bbappend) is created, build the image using:

$ bitbake my-image

or, if you modified an existing image (such as core-image-base):

$ bitbake core-image-base

Deploy and test the image

After the build completes, the final image will be available in the tmp/deploy/images/ directory.

Refer to Deploy to transfer the image to the target.