1

I need to add a file to the /boot directory produced by a yocto build. I've created a recipe that is trying to do this:

SRCREV = "48cabcbc64484ca6c201746e526a11b4b43eb359"

FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"

SRC_URI += "file://0001-uEnv.patch file://0002-disable-boot-interrupt.patch file://uEnv.txt"
FILES_${PN} += "/boot/uEnv.txt"

do_install_append() {
    install -m 0744    ${WORKDIR}/uEnv.txt       ${D}/${base_prefex}/boot
}

This recipe does some patching of u-boot too, but for now I'm just interested in the parts that are trying to add uEnv.txt to the boot directory. I know this recipe is being processed. If I rename the uEnv.txt file, for example, it throws an error. So I know it's trying to install it. But when I examine the rootfs created by yocto, the file is missing.

Does anyone know what I'm doing wrong? Maybe the problem is with ${D}/${base_prefex}/boot and I'm just not putting it in the right place? I've tried putting it in other places, though, like ${D}${sysconfdir}/ without success.

Dave
  • 43
  • 4

1 Answers1

2

Here are some idea that you can try:

u-boot already have a variable to work with Env files (Check poky/meta/recipes-bsp/u-boot/u-boot.inc)

It checks for UBOOT_ENV variable if it is present and it copies it to /boot:

do_install() {
...
if [ -n "${UBOOT_ENV}" ]
    then
        install -m 644 ${WORKDIR}/${UBOOT_ENV_BINARY} ${D}/boot/${UBOOT_ENV_IMAGE}
        ln -sf ${UBOOT_ENV_IMAGE} ${D}/boot/${UBOOT_ENV_BINARY}
    fi
...
}

do_deploy() {
...
if [ -n "${UBOOT_ENV}" ]
    then
        install -m 644 ${WORKDIR}/${UBOOT_ENV_BINARY} ${DEPLOYDIR}/${UBOOT_ENV_IMAGE}
        rm -f ${DEPLOYDIR}/${UBOOT_ENV_BINARY} ${DEPLOYDIR}/${UBOOT_ENV_SYMLINK}
        ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_BINARY}
        ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_SYMLINK}
    fi
...
}

I assume that your recipe is a bbappend for uboot because it has a patch.

So you can try the following:

SRCREV = "48cabcbc64484ca6c201746e526a11b4b43eb359"

FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"

SRC_URI += "file://0001-uEnv.patch file://0002-disable-boot-interrupt.patch file://uEnv.txt"

UBOOT_ENV = "uEnv"
UBOOT_ENV_SUFFIX = "txt"

More more note to be considered, if your Uboot is trying to fetch the uEnv.txt file from rootfs/boot then it is okay, but if it trying to get it from the boot partition (if you have one) then you should add it to that partition with (In your machine conf or local conf):

BOOT_FILES_append = " uEnv.txt"
Talel BELHADJSALEM
  • 3,199
  • 1
  • 10
  • 30
  • I tried this, but uEnv.txt wasn't added to the boot directory. (I'm not using a separate partition right now.) I also tried to modify my do_install to make it look as close as possible to the code you showed from u-boot.inc, (```install -D -m 0644 ${WORKDIR}/uEnv.txt ${D}/boot/uEnv.txt```) and that's not doing it either. I never get compile errors, but no matter what I do, nothing shows up in the boot directory. – Dave Jul 08 '22 at 13:36
  • 1
    Go to `WORKDIR` of uboot and check the `image` folder, do you see a `boot` folder there ? – Talel BELHADJSALEM Jul 08 '22 at 13:50
  • Well, that's interesting. Yes, ```$WORKDIR/image/boot``` exists for the u-boot recipe, and my uEnv.txt is sitting there. That's after running my code that is just using do_install (and not using the UBOOT_ENV variables). But it isn't making it to ```$WORKDIR/rootfs/boot" for the core-image-minimal recipe. Is there something I need to do to make that happen? – Dave Jul 08 '22 at 14:20
  • 1
    I think uboot is not added in the `IMAGE_INSTALL`, I don't think I saw this before, but I suggest creating other recipe for example `uboot-env.bb` to install the txt and add it `IMAGE_INSTALL_append = " uboot-env"` – Talel BELHADJSALEM Jul 08 '22 at 15:00
  • Creating another recipe worked, so it sounds like your theory was correct. I have it working just using an install command in a do_install. Eventually I may go back and see if I can make it work with a the UBOOT_ENV approach but from a separate recipe. – Dave Jul 14 '22 at 13:37
  • 1
    You cannot set `UBOOT_ENV` from a separate recipe, the variable is specific to Uboot recipe, it should be a `bbappend` for uboot, you can check other uboot examples that uses `UBOOT_ENV`. – Talel BELHADJSALEM Jul 14 '22 at 13:46