How to deploy files to /boot partition with Yocto
Asked Answered
P

3

7

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.

Primarily answered 6/7, 2019 at 12:57 Comment(0)
M
1

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!

Markhor answered 17/4, 2023 at 11:0 Comment(0)
H
4

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.

Hedge answered 6/7, 2019 at 17:29 Comment(11)
Thank you for your answer! Unfortunately I did some mistake or have to go a different approach. When using RPI_KERNEL_DEVICETREE_OVERLAYS it tries to compile the dtbo's like they would be dts files. Using IMAGE_BOOT_FILES the image builds but without the files. I'l update my question with more details.Primarily
Maybe try to change install by cp ? If you use bitbake -v rpi3-overlays, do you see files to be copied ?Hedge
Another way could be to patch kernel with new dts file to get it compiled by Yocto?Hedge
I have no local build (only on build server), but I can try that. But I don't think cp will do anything different than install. The files are deployed, but in the /boot directory on the root fs instead of the /boot fs. In theory I could convert the dtbos back to dts, but as I get them in binary form it would be an additional step and this would only apply to dtbos. When I have to deploy other file types then that solution wouldn't work.Primarily
Which Yocto version do you use?Hedge
can you try to add your recipe in do_image_wic[depends] of rpi-base.incHedge
I'm using the warrior branch. To add the recipe it's do_image_wic[depends]_append = " rpi3-overlays:do_deploy" right?Primarily
not sure, try do_image_wic[depends] += "rpi3-overlays:do_deploy"Hedge
I added that line to my recipe, but the result didn't change :(Primarily
In which recipe did you add that line? Try to add it directly to rpi-base.inc file just to be sure? I think IMAGE_BOOT_FILES_append should contain rpi3-overlays/3dlab-nano-player.dtbo instead of overlays/3dlab-nano-player.dtbo. Can you use bitbake -v -D <your_image> to verify your files are taken into account during wic process?Hedge
Thank you very much for your help! Will try that, but that will take until tomorrow as I'll have to make a manual build in order to do the change and run bitbake with different options.Primarily
P
1

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
Primarily answered 19/10, 2019 at 11:39 Comment(0)
M
1

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!

Markhor answered 17/4, 2023 at 11:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.