Topic: Adding and Managing Custom Layers
Date: 02/06/2026
Source: Personal build workflow notes
Key Points
- Custom layers keep project changes isolated from vendor layers
- Never modify poky or meta-petalinux directly
- Use bitbake tools to create and register layers
- Packages can be added via IMAGE_INSTALL or rootfs config
Step-by-Step Process
Step 1: Source the Build Environment
Inside your Petalinux project you are allowed to run the following command below to
create a build enviorment that would allow you to use the bitbake commands.
source <proj-root>/components/yocto/layers/poky/oe-init-build-env
This enables:
- bitbake
- bitbake-layers
- environment variables for the build system
Without this step, layer commands will fail.
Step 2: Create a New Layer
bitbake-layers create-layer <path-to-layer>
Example:
bitbake-layers create-layer ../project-spec/meta-template
This generates:
- conf/layer.conf
- recipes-example
- basic layer structure
Step 3: Add the Layer to the Project
Once you have created a layer you will need to add that layer to the bblayer.conf
that is located in build/conf/bblayers.conf. The BBLAYERS variable will be updated
with a new path to the newest created layer.
bitbake-layers add-layer <path-to-layer>
Example:
bitbake-layers add-layer ../project-spec/meta-template
Step 4: Verify the Layer
bitbake-layers show-layers
Confirm your layer appears in the list.
Step 5: Add Packages to the Image (Option A - Always Installed)
If you want to ensure that the package is installed in the rootfs
no matter what you will need to add the following below to your
conf/layer.conf or image recipe that would append the packages.
To do this follow the update below:
IMAGE_INSTALL:append = " testapp2 testapp3"
or
IMAGE_INSTALL += " testapp2 testapp3"
Use this when packages should always be included in the image.
Optional Step: Enable via RootFS Config
If you want to make the packages to be optional you may want to add the package
config to your rootfs-config so that the user defines if they want this is their
project or not.
To do this add configurable packages using rootfs config located:
Edit:
<proj-root>/project-spec/meta-user/conf/user-rootfsconfig
Add:
CONFIG_testapp2
CONFIG_testapp3
This allows enabling/disabling from:
petalinux-config -c rootfs
Use this when you want optional packages instead of always-on installs.
Questions & Clarifications
- Should this package always ship or be optional?
- Does it belong in meta-user or a separate project layer?
- Are dependencies declared correctly in the recipe?
Action Items / Next Steps
- Create recipes for custom apps under recipes-apps/
- Keep vendor layers untouched
- Commit the layer to version control
- Rebuild and test image after each change
Summary
Whether you need to make sure that your project is clean and reproducable without much leg work may require creating a dedicated meta-layer keeps your PetaLinux project clean, portable, and maintainable.
To do this we have to source the environment, create the layer, add it with bitbake, and then manage packages using IMAGE_INSTALL or rootfs config depending on whether they should be mandatory or optional.
Examples of this are in step 5 in which I used named packages like testapp2 and testapp3 keeps the configuration explicit and easy to maintain as the project grows.
Solus Christus
