linuxembeddedyocto

How to deploy files to /boot partition with Yocto


I'm trying to deploy some binary files to /boot in a Yocto image for RPi CM3 but it deploys them to the wrong location.

do_install() {
    install -d ${D}/boot/overlays
    install -m 0664 ${WORKDIR}/*.dtb ${D}/boot/overlays/
    install -m 0664 ${WORKDIR}/*.dtbo ${D}/boot/overlays/
}

The files are deployed to /boot in the / partition of the final image, but not to the /boot partition. So they are not available at boot time.

I already googled and studied the kernel recipes (and classes) of the Poky distribution but I didn't find the mechanism it uses how to ensure that the files are deployed to the boot image (and not to the /boot dir in the root image).

Any help is appreciated :)

Update #1

In my local.conf I did:

IMAGE_BOOT_FILES_append = " \
  overlays/3dlab-nano-player.dtbo \
  overlays/adau1977-adc.dtbo \
  ...
"

And in my rpi3-overlays.bb

do_deploy() {
    install -d ${DEPLOYDIR}/${PN}
    install -m 0664 ${WORKDIR}/*.dtb ${DEPLOYDIR}/${PN}
    install -m 0664 ${WORKDIR}/*.dtbo ${DEPLOYDIR}/${PN}

    touch ${DEPLOYDIR}/${PN}/${PN}-${PV}.stamp
}

Using this the image builds, but the files stillt don't get deployed in the /boot partition. Using RPI_KERNEL_DEVICETREE_OVERLAYS I get a build error because the kernel recipe tries to build the dtbo files like dts files.


Solution

  • I've battled the problem of deploying files to the /boot partition over last few days and came up with a solution. Below instructions are for Yocto Kirkstone 4.0.1.

    1. In case of working with linux-raspberrypi add it as a dependency to your recipe, same with dtc-native for the compilation of Device Tree files.

      DEPENDS:append = " linux-raspberrypi"
      DEPENDS:append = " dtc-native"
      
    2. Prepare the you recipe so that it deploys the file to ${DEPLOYDIR} - directory where files of the final image are stored. Inherit from the deploy class, it's important to add the deploy task with addtask. Below do_deploy function assumes that all the files are compiled and ready for deployment.

      inherit deploy
      
      do_deploy() {
          install -m 0664 ${S}/adau1977-adc.dtbo ${DEPLOYDIR}/adau1977-adc.dtbo
      }
      
      addtask deploy after do_compile
      
    3. To burn the file into the specified directory on the /boot partition, use below syntax of the IMAGE_BOOT_FILES variable:

      IMAGE_BOOT_PARTITION:append = " file_name_in_deploydir;path/on/boot/filename.extension"
      

      For example

      IMAGE_BOOT_PARTITION:append = " adau1977-adc.dtbo;overlays/adau1977-adc.dtbo"
      

      Put this line into your local.conf

    This should work!