Alexander Nassian
Alexander Nassian

Reputation: 517

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.

Upvotes: 7

Views: 11368

Answers (3)

Antoni
Antoni

Reputation: 366

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!

Upvotes: 1

Alexander Nassian
Alexander Nassian

Reputation: 517

After too many hours of investigation it turned out, that deploying files to other partitions than / is not easily possible. I now went the way of a post-processing script that mounts the final image, deploys the additional files and unmounts it.

# Ensure the first loopback device is free to use
sudo -n losetup -d /dev/loop0 || true

# Create a loopback device for the given image
sudo -n losetup -Pf ../deploy/images/bapi/ba.rootfs.rpi-sdimg

# Mount the loopback device
mkdir -p tmp
sudo -n mount /dev/loop0p1 tmp

# Deploy files
sudo -n cp -n ../../meta-ba-rpi-cm3/recipes-core/rpi3-overlays/files/* tmp/overlays/
sudo -n cp ../../conf/config.txt tmp/config.txt
sudo -n cp ../../conf/cmdline.txt tmp/cmdline.txt

# Unmount the image and free the loopback device
sudo -n umount tmp
sudo -n losetup -d /dev/loop0

Upvotes: 1

Nayfe
Nayfe

Reputation: 2310

RPI images are created with sdimage-raspberrypi.wks WIC wks file. It contains:

part /boot --source bootimg-partition ...

so it uses bootimg-partition.py wic plugin to generate /boot partition. It copies every files defined by IMAGE_BOOT_FILES variable.

It seems you want to add some devicetree overlays, so you need to modify machine configuration and more specifically RPI_KERNEL_DEVICETREE_OVERLAYS variable. IMAGE_BOOT_FILES variable is set in rpi-base.inc.

If you don't have any custom machine or custom distro defined, you can add it in local.conf:

RPI_KERNEL_DEVICETREE_OVERLAYS_append = " <deploy-path>/<dto-path>"

You can see here how to add files in deploy directory.

Upvotes: 4

Related Questions