This topic shows how to make permanent changes to a given recipe and build it using Digi Embedded Yocto.

Patch-based workflow

This workflow consists of creating custom patches to apply on top of the source code downloaded by the recipe. This is the typical way to modify source code in any Yocto recipe.

Pros and cons

  • Pros

    • The recipe can remain in sync with the original source code tree and any future patches released by Digi or the community, while still applying your modifications.

    • Changes are permanent and applied to any images built with Digi Embedded Yocto.

  • Cons

    • You have to generate the changes as patch files and create a .bbappend recipe to apply them.

    • If Digi or the community releases changes to the recipe’s source code, you might need to adapt the patches in case they don’t apply correctly.

Instructions

To apply patches to a Yocto recipe you have to change the recipe to instruct it to use your patches. Although you can do this by modifying the original recipe, Digi recommends you create a *.bbappend file (an amendment to the recipe) inside your layer.

Do the following:

  1. Change to your layer directory, for instance:

    $ cd /<yourpath>/<meta-custom>/
  2. Create a path that replicates the path where the original recipe resides in its original layer. For instance, for the kernel recipe linux-dey in meta-digi layer the path is recipes-kernel/linux/:

    $ mkdir -p recipes-kernel/linux/
  3. Create a subfolder with the name of the recipe to hold the patches, for instance for recipe linux-dey:

    $ mkdir -p recipes-kernel/linux/linux-dey/
  4. Generate the patches as explained in Make temporary changes and place them in this subdirectory.

  5. Create a file <recipe-name>_<version>.bbapend. For instance, for the v6.6 kernel:

    $ touch recipes-kernel/linux/linux-dey_6.6.bbappend
    If you want your changes to apply to any recipe version you can name the file <recipe-name>_%.bbappend
  6. Edit the file and add the list of patches and their location:

    # Search for files in subfolder with the name of the recipe
    FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}:"
    
    # List of patches to apply to source code
    SRC_URI:append: = " \
        file://0001-this-is-patch1.patch \
        file://0002-now-patch2.patch \
        file://0003-another-patch.patch \
        file://0004-yet-another-patch.patch \
        file://0005-this-is-the-final-patch.patch \
    "
  7. Go to your Digi Embedded Yocto project and source the environment:

    $ cd <my-project>
    $ source dey-setup-environment
  8. Rebuild the recipe, for instace:

    $ bitbake -c cleanall <recipe-name>
    $ bitbake <recipe-name>

With this method, every time you do a repo sync, you will get the latest source code, and the patches in your layer will be applied on top of it.