Automate addition of FDTOVERLAYS to /boot/extlinux/extlinux.conf

Hello,

I’m working on a HummingBoard Pro boad (i.MX8M Plus) with Basel Cameras on the carrier board port.

To declare the necessary DTB, I have to add the following line to /boot/extlinux/extlinux.conf:

   FDTOVERLAYS ../freescale/imx8mp-sr-som-basler.dtbo ../freescale/imx8mp-hummingboard-pulse-basler.dtbo

For the moment, the only way I found is to add it manually after the first boot of my image.

Is there a way to automate the addition of this line in the Yocto build process so that the resulting image includes this line by default?

Thanks by advance for your answer!

The simplest way to do this, is in your own meta-layer specify a custom extlinux.conf that includes these changes. Let me know if you need specific instructions to do this.

Another option is to just do this all in u-boot.

Thank you for your answer.

For several reasons, I prefer not to completely override extlinux.conf.

After some reflection and digging I ended up with implementing a new wic plugin which inherits BootimgPartitionPlugin and append a line passed in parameter to each entry of extlinux.conf.

So I consider my problem is solved like this.

Thank you for your help.

Should it be of any help, here is the pluggin’s code (added to my own layer in scripts/lib/wic/plugins/source/bootimg-partition-with-fdtoverlay.py :


import logging

import importlib  
mod = importlib.import_module("wic.plugins.source.bootimg-partition")

logger = logging.getLogger('wic')

class BootimgPartitionWithFdtoverlayPlugin(mod.BootimgPartitionPlugin):
    """
    Inherit BootimgPartitionPlugin to
        Create an image of boot partition, copying over files
        listed in IMAGE_BOOT_FILES bitbake variable.
    And add 
        and a line with the content of the `extra_line` variable to each entry
    """

    name = 'bootimg-partition-with-fdtoverlay'

    @classmethod
    def do_configure_partition(cls, part, source_params, cr, cr_workdir,
                             oe_builddir, bootimg_dir, kernel_dir,
                             native_sysroot):
        """
        Add the FDTOVERLAY line to extlinux.conf
        """
        super().do_configure_partition(part, source_params, cr, cr_workdir,
                             oe_builddir, bootimg_dir, kernel_dir,
                             native_sysroot)
        
        extra_line = source_params.get('extra_line')
        if not extra_line:
            return
        
        hdddir = "%s/boot.%d" % (cr_workdir, part.lineno)
        cfg = open("%s/extlinux/extlinux.conf" % hdddir, "r")
        original_conf = cfg.read()
        cfg.close()
        
        new_conf = ""
        for line in original_conf.splitlines():
            new_conf += line + '\n'
            if line.startswith("label "):
                new_conf += "   " + extra_line + '\n'

        cfg = open("%s/extlinux/extlinux.conf" % hdddir, "w")
        cfg.write(new_conf)
        cfg.close()