Search code examples
linuxyoctobitbakedevice-treerecipe

user space and device tree recipe combined in yocto build


I am trying to create a recipe which is composed of a user application which is dependent on certain peripheral interface spi

I have created a recipe for the same but only application becomes the part of the built image.

How can I and what to modify to include the device tree as well?

MKI-33Axx.dts is my platform device tree and my modifications are in this file only for spi and I want this file to be picked up not the original one.

I have read that KERNEL_DEVICETREE_append needs to be provided the modified "dtb" file not the dts file.Do I have to compile the device tree separately then added it to the image after I build the image? But i am still not clear on this. Can some one please tell how to and where to activate this? so that i can append this device tree change as well with my recipe.


Solution

  • KERNEL_DEVICETREE variable is used to specify the device tree files that need to be generated and added to the boot partition, but the bootloader will only charge one of them in the RAM while booting.

    Example, for U-boot, the file specified in DEFAULT_FDT_FILE in the board's defconfig file will be used. But you can change the DTB by pausing U-boot and specifying the DTB file with:

    setenv fdt_file new_file.dtb (make sure of "fdt_file" var with "printenv")
    

    You can use recipetool to automatically add your new device tree file to your linux recipe, check my answer here.

    You don't have to compile the DTS separatly, because adding it to KERNEL_DEVICETREE variable will cause it to be shipped in the boot partition.

    Any modifications on the Linux kernel can be added into :

    meta-custom/recipes-kernel/linux/linux-(PROVIDER)_%.append

    the (PROVIDER) could be found in the machine configuration file, and it is a provider for virtual/kernel recipe.

    You create patches for your Linux, go to:

    tmp/work/.../linux-(PROVIDER)/../git

    do your edits and:

    git add modified_file
    git commit -m "updates"
    git format-patch -1
    

    This will generate a "updates.patch" file, that you can add it to linux-(PROVIDER)_%.append file:

    SRC_URI += "file://updates.patch"
    

    Make sure you copy the patch file to:

    meta-custom/recipes-kernel/linux/files

    Now, the Linux build will triggered and apply the patch.