Defining Custom Image and Distro for Raspberry Pi Zero 2W

A guide to creating custom image recipes and distribution configurations in your own Yocto layer, eliminating the need for manual local.conf edits
February 3, 2026

Defining Custom Image and Distro for Raspberry Pi Zero 2W

I'll complete the layer for creating my own image by adding an image recipe and distribution configuration to the meta-jooojub-rpi layer created in the previous post.
I will now apply the modifications I previously made to local.conf and bblayers.conf for the Raspberry Pi Zero 2W image directly to the layer.
This eliminates the need for manual edits, allowing you to create images immediately just by adding the layer, which simplifies maintenance and distribution.

1. Add Image recipes

Previously, we used core-image-base when building images with bitbake.
You can create custom image recipes based on this base image.
Create files and directories in the following paths within the meta-jooojub-rpi layer created in the previous post.
I've configured it to be buildable with the name jooojub-rpi0-2w.
recipes-core/images/jooojub-rpi0-2w.bb
bitbake
Since core-image-base is included, you can now build the image using jooojub-rpi0-2w.

2. Create Distro Configuration

To minimize modifications to the existing local.conf, create your own Distro.
conf/distro/rpi0-2w.conf
shell
You can now add the LICENSE and IMAGE_ROOTFS size settings, which were previously modified in local.conf, here instead.

3. Create conf Templates

When running oe-init-build-env to set up the initial build environment, you can specify your own templates.
By default, poky/meta-poky/conf/templates is used.
I'll make this part customizable as well to minimize additional tasks.
Copy the templates from the existing meta-poky.
Copy default template
shell
Now, add the desired parts.
To avoid the hassle of manually adding layers every time, I've configured them to be included automatically during initial setup.
conf/templates/default/bblayers.conf.sample
diff
I've modified the message displayed by oe-init-build-env to include a list of buildable targets.
conf/templates/default/conf-notes.txt
diff
Modify the MACHINE and DISTRO values that need to be added to local.conf to your preferred values.
conf/templates/default/local.conf.sample
diff

4. Build Test

Let's check if the modifications made so far work correctly.
I'll boldly delete the existing build directory and configure the build using my custom conf templates.
Simply specify the path to the previously created templates in the TEMPLATECONF environment variable.
Using an absolute path is recommended.
Create build env with TEMPLATECONF
shell
You can see that the modifications to conf-notes.txt are displayed correctly.
conf/bblayers.conf
bash
The layers are correctly added to conf/bblayers.conf as well.
conf/local.conf
bash
The desired MACHINE and DISTRO values are also present in conf/local.conf.
Since the desired values are included by default, you can run bitbake immediately to generate the image.

5. Next Steps

The basic foundation for customizing Yocto recipes is now in place.
I'll start adding the features I want one by one.
Jooojub
System S/W engineer
Explore Tags
Series
    Recent Post
    © 2026. jooojub. All right reserved.