Bitbake recipe to modify u-boot-default-env or boot.scr

We want to modify the u-boot-initial-env-sd file or possibly the boot.scr file that is built and included into the TEZI image as part of the yocto build. Our initial requirement is to provide a “maintenance mode” boot function that can be controlled by writing a u-boot environment variable from linux command-line then rebooting. Eventually we’ll want to include firmware for the M-4 cores in the boot sequence as well.

We have our own custom meta-layer that already does a number of other customizations for our image, including adding packages and enabling extra kernel modules.

Is there an obvious or supported way to write a .bb or .bbappend file to also edit/replace the u-boot-initial-env-sd or boot.scr file?

Greetings @gregb,

For quick tests and debugging you can simply just edit these files in the Yocto layers directly. However it is of course best practice to have such changes in your own meta-layer via a bbappend. So for example to use your own boot.scr you would need to do the following:

“boot.scr” is included into the image via way of the recipe u-boot-distro-boot. The base bb recipe file for this is in the meta-toradex-bsp-common layer here: u-boot « recipes-bsp - meta-toradex-bsp-common.git - Toradex BSP layer, recipes common to all modules

However we also bbappend onto this file in meta-toradex-torizon here: meta-toradex-torizon/recipes-bsp/u-boot at master · toradex/meta-toradex-torizon · GitHub

Taking a quick look at the recipe file you can see it takes a source file called “boot.cmd.in” this eventually gets compiled into “boot.scr”. So for your layer you’ll need to do something similar to what was done in the Torizon bbappend file. In this layer a new “boot.cmd.in” was supplied. This will override the “boot.cmd.in” given in meta-toradex-bsp-common since the meta-toradex-torizon has a higher layer priority.

So for your own meta-layer you’ll basically need to do the same thing. The only think to keep in mind is to make sure your meta-layer is of an even higher priority so that it overwrites the “boot.cmd.in” give in meta-toradex-torizon.

Best Regards,
Jeremias

Thanks Jeremias, that was most helpful.

I’ve managed to get this working with a patch rather than replace the entire script, which is for our purposes more robust. Getting all the paths right was a pain, but this is what’s working for me now (for future reference):

In my recipe file recipes-bsp/u-boot/u-boot-distro-boot.bbappend:

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI_append = " file://001-boot.cmd.in.patch;patchdir=${WORKDIR}"

and the head of the patch file:

diff -Nurp boot.cmd.in boot.cmd.in
--- a/boot.cmd.in	2020-10-16 09:51:59.549727449 +1100
+++ b/boot.cmd.in	2020-10-16 09:56:40.006000000 +1100
@@ -82,4 +82,10 @@ fi

I.e. only 1 directory, which is stripped by the -p1 arg to patch.

1 Like

Glad you were able to get a solution that works best for you!