* [PATCH v3 1/2] u-boot: make initial environment binary image
@ 2025-11-21 8:49 pierre-loup.gosse
2025-11-21 8:49 ` [PATCH v3 2/2] oe-selftest: uboot: add test for building U-Boot initial env binary pierre-loup.gosse
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: pierre-loup.gosse @ 2025-11-21 8:49 UTC (permalink / raw)
To: openembedded-core; +Cc: Pierre-Loup GOSSE
From: Pierre-Loup GOSSE <pierre-loup.gosse@smile.fr>
Build the U-Boot initial environment binary image if
UBOOT_INITIAL_ENV_BINARY is set to "1". The environment partition size
(in bytes, hexadecimal or decimal) must be defined using
UBOOT_INITIAL_ENV_BINARY_SIZE.
If U-Boot environment redundancy is enabled,
UBOOT_INITIAL_ENV_BINARY_REDUND must be set to "1".
The resulting binary can be flashed using WIC at the environment offset,
overriding any existing environment if present, for example:
part --source rawcopy --sourceparams="file=u-boot-initial-env-sd.bin" --ondisk sda --no-table --offset 4096
Signed-off-by: Pierre-Loup GOSSE <pierre-loup.gosse@smile.fr>
---
Note: Once merged, a patch with the new variables will be submitted to the
documentation mailing list.
changes in v2:
- fix uboot_deploy_config (builddir was missing)
no changes in v3
---
meta/classes-recipe/uboot-config.bbclass | 11 +++++++++
meta/recipes-bsp/u-boot/u-boot.inc | 30 ++++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/meta/classes-recipe/uboot-config.bbclass b/meta/classes-recipe/uboot-config.bbclass
index fd6c045142..81057b5cad 100644
--- a/meta/classes-recipe/uboot-config.bbclass
+++ b/meta/classes-recipe/uboot-config.bbclass
@@ -71,6 +71,14 @@ UBOOT_ENV_BINARY ?= "${UBOOT_ENV}.${UBOOT_ENV_SUFFIX}"
UBOOT_ENV_IMAGE ?= "${UBOOT_ENV}-${MACHINE}-${UBOOT_VERSION}.${UBOOT_ENV_SUFFIX}"
UBOOT_ENV_SYMLINK ?= "${UBOOT_ENV}-${MACHINE}.${UBOOT_ENV_SUFFIX}"
+# Enable the build of the U-Boot initial env binary image. The binary size is
+# required (i.e. the U-Boot partition environment size). Since the environment
+# layout with multiple copies is different, set UBOOT_INITIAL_ENV_BINARY_REDUND
+# to "1" if the U-Boot environment redundancy is enabled.
+UBOOT_INITIAL_ENV_BINARY ?= "0"
+UBOOT_INITIAL_ENV_BINARY_SIZE ?= ""
+UBOOT_INITIAL_ENV_BINARY_REDUND ?= "0"
+
# U-Boot EXTLINUX variables. U-Boot searches for /boot/extlinux/extlinux.conf
# to find EXTLINUX conf file.
UBOOT_EXTLINUX_INSTALL_DIR ?= "/boot/extlinux"
@@ -100,6 +108,9 @@ UBOOT_DTB_BINARY ??= ""
UBOOT_FIT_CHECK_SIGN ?= "uboot-fit_check_sign"
python () {
+ if bb.utils.to_boolean(d.getVar('UBOOT_INITIAL_ENV_BINARY')) and d.getVar('UBOOT_INITIAL_ENV_BINARY_SIZE') == "":
+ bb.fatal("UBOOT_INITIAL_ENV_BINARY requires setting the U-Boot partition environment size with the UBOOT_INITIAL_ENV_BINARY_SIZE variable")
+
ubootmachine = d.getVar("UBOOT_MACHINE")
ubootconfigflags = d.getVarFlags('UBOOT_CONFIG')
ubootbinary = d.getVar('UBOOT_BINARY')
diff --git a/meta/recipes-bsp/u-boot/u-boot.inc b/meta/recipes-bsp/u-boot/u-boot.inc
index 16c9836508..ffa9ef2d59 100644
--- a/meta/recipes-bsp/u-boot/u-boot.inc
+++ b/meta/recipes-bsp/u-boot/u-boot.inc
@@ -4,6 +4,7 @@ PROVIDES = "virtual/bootloader"
PACKAGE_ARCH = "${MACHINE_ARCH}"
DEPENDS += "${@bb.utils.contains('UBOOT_ENV_SUFFIX', 'scr', 'u-boot-mkimage-native', '', d)}"
+DEPENDS += "${@ 'u-boot-mkenvimage-native' if bb.utils.to_boolean(d.getVar('UBOOT_INITIAL_ENV_BINARY')) else ''}"
inherit uboot-config uboot-extlinux-config uboot-sign deploy python3native kernel-arch
@@ -104,6 +105,10 @@ uboot_compile_config () {
if [ -n "${UBOOT_INITIAL_ENV}" ]; then
oe_runmake -C ${S} O=${B}/${builddir} u-boot-initial-env
cp ${B}/${builddir}/u-boot-initial-env ${B}/${builddir}/u-boot-initial-env-${type}
+ if [ "${UBOOT_INITIAL_ENV_BINARY}" = "1" ] ; then
+ uboot_compile_initial_env_binary
+ cp ${B}/${builddir}/u-boot-initial-env.bin ${B}/${builddir}/u-boot-initial-env-${type}.bin
+ fi
fi
}
@@ -123,7 +128,18 @@ uboot_compile () {
# Generate the uboot-initial-env
if [ -n "${UBOOT_INITIAL_ENV}" ]; then
oe_runmake -C ${S} O=${B} u-boot-initial-env
+ if [ "${UBOOT_INITIAL_ENV_BINARY}" = "1" ] ; then
+ uboot_compile_initial_env_binary
+ fi
+ fi
+}
+
+uboot_compile_initial_env_binary() {
+ redund=""
+ if [ "${UBOOT_INITIAL_ENV_BINARY_REDUND}" = "1" ] ; then
+ redund="-r"
fi
+ uboot-mkenvimage -s ${UBOOT_INITIAL_ENV_BINARY_SIZE} ${redund} -o ${B}/${builddir}/u-boot-initial-env.bin ${B}/${builddir}/u-boot-initial-env
}
do_install () {
@@ -388,9 +404,16 @@ uboot_deploy_config () {
# Deploy the uboot-initial-env
if [ -n "${UBOOT_INITIAL_ENV}" ]; then
install -D -m 644 ${B}/${builddir}/u-boot-initial-env-${type} ${DEPLOYDIR}/${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${UBOOT_VERSION}
+ if [ "${UBOOT_INITIAL_ENV_BINARY}" = "1" ]; then
+ install -D -m 644 ${B}/${builddir}/u-boot-initial-env-${type}.bin ${DEPLOYDIR}/${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${UBOOT_VERSION}.bin
+ fi
cd ${DEPLOYDIR}
ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${UBOOT_VERSION} ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}
ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${UBOOT_VERSION} ${UBOOT_INITIAL_ENV}-${type}
+ if [ "${UBOOT_INITIAL_ENV_BINARY}" = "1" ]; then
+ ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${UBOOT_VERSION}.bin ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}.bin
+ ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${UBOOT_VERSION}.bin ${UBOOT_INITIAL_ENV}-${type}.bin
+ fi
fi
}
@@ -405,9 +428,16 @@ uboot_deploy () {
# Deploy the uboot-initial-env
if [ -n "${UBOOT_INITIAL_ENV}" ]; then
install -D -m 644 ${B}/u-boot-initial-env ${DEPLOYDIR}/${UBOOT_INITIAL_ENV}-${MACHINE}-${UBOOT_VERSION}
+ if [ "${UBOOT_INITIAL_ENV_BINARY}" = "1" ]; then
+ install -D -m 644 ${B}/u-boot-initial-env.bin ${DEPLOYDIR}/${UBOOT_INITIAL_ENV}-${MACHINE}-${UBOOT_VERSION}.bin
+ fi
cd ${DEPLOYDIR}
ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${UBOOT_VERSION} ${UBOOT_INITIAL_ENV}-${MACHINE}
ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${UBOOT_VERSION} ${UBOOT_INITIAL_ENV}
+ if [ "${UBOOT_INITIAL_ENV_BINARY}" = "1" ]; then
+ ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${UBOOT_VERSION}.bin ${UBOOT_INITIAL_ENV}-${MACHINE}.bin
+ ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${UBOOT_VERSION}.bin ${UBOOT_INITIAL_ENV}.bin
+ fi
fi
}
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 2/2] oe-selftest: uboot: add test for building U-Boot initial env binary
2025-11-21 8:49 [PATCH v3 1/2] u-boot: make initial environment binary image pierre-loup.gosse
@ 2025-11-21 8:49 ` pierre-loup.gosse
2025-12-01 17:59 ` [OE-core] [PATCH v3 1/2] u-boot: make initial environment binary image adrian.freihofer
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: pierre-loup.gosse @ 2025-11-21 8:49 UTC (permalink / raw)
To: openembedded-core; +Cc: Pierre-Loup GOSSE
From: Pierre-Loup GOSSE <pierre-loup.gosse@smile.fr>
This adds two new selftest cases `test_uboot_initial_env_binary` and
`test_uboot_config_initial_env_binary` to verify the build of the U-Boot
initial env binary with the mkimage tool.
Signed-off-by: Pierre-Loup GOSSE <pierre-loup.gosse@smile.fr>
---
changes in v2:
- add tests
changes in v3:
- fix UBOOT_CONFIG[test] with the correct UBOOT_MACHINE
---
meta/lib/oeqa/selftest/cases/uboot.py | 54 +++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/meta/lib/oeqa/selftest/cases/uboot.py b/meta/lib/oeqa/selftest/cases/uboot.py
index 980ea327f0..28169514f5 100644
--- a/meta/lib/oeqa/selftest/cases/uboot.py
+++ b/meta/lib/oeqa/selftest/cases/uboot.py
@@ -5,6 +5,9 @@
# SPDX-License-Identifier: MIT
#
+import os
+import textwrap
+
from oeqa.selftest.case import OESelftestTestCase
from oeqa.utils.commands import bitbake, runqemu, get_bb_var, get_bb_vars, runCmd
from oeqa.core.decorator.data import skipIfNotArch, skipIfNotBuildArch
@@ -96,3 +99,54 @@ QB_DRIVE_TYPE = "/dev/vd"
self.assertTrue("Machine model: linux,dummy-virt" in output, msg=output)
# with KVM enabled
self.assertTrue("KVM: hypervisor services detected" in output, msg=output)
+
+ def test_uboot_initial_env_binary(self):
+ """
+ Tests building the initial U-Boot environment in binary format with
+ the U-Boot mkimage tool.
+ We assume that the uboot-mkenvimage tool generates a correct binary.
+ """
+
+ self.write_config(textwrap.dedent("""
+ UBOOT_INITIAL_ENV_BINARY = "1"
+ UBOOT_INITIAL_ENV_BINARY_SIZE = "0x4000"
+ UBOOT_INITIAL_ENV_BINARY_REDUND = "1"
+ """))
+
+ bitbake("u-boot")
+
+ bb_vars = get_bb_vars(["DEPLOYDIR", "UBOOT_INITIAL_ENV"], "u-boot")
+
+ uboot_initial_env_binary_path = os.path.realpath(os.path.join(
+ bb_vars["DEPLOYDIR"], "%s.bin" % bb_vars["UBOOT_INITIAL_ENV"]
+ ))
+
+ self.assertExists(uboot_initial_env_binary_path)
+
+ def test_uboot_config_initial_env_binary(self):
+ """
+ Tests building the initial U-Boot environment in binary format with
+ the U-Boot mkimage tool for a U-Boot config.
+ We assume that the uboot-mkenvimage tool generates a correct binary.
+ """
+
+ uboot_machine = get_bb_var("UBOOT_MACHINE", "u-boot")
+
+ self.write_config(textwrap.dedent(f"""
+ UBOOT_CONFIG = "test"
+ UBOOT_CONFIG[test] := "{uboot_machine}"
+ UBOOT_MACHINE = ""
+ UBOOT_INITIAL_ENV_BINARY = "1"
+ UBOOT_INITIAL_ENV_BINARY_SIZE = "0x4000"
+ UBOOT_INITIAL_ENV_BINARY_REDUND = "1"
+ """))
+
+ bitbake("u-boot")
+
+ bb_vars = get_bb_vars(["DEPLOYDIR", "UBOOT_INITIAL_ENV"], "u-boot")
+
+ uboot_initial_env_binary_path = os.path.realpath(os.path.join(
+ bb_vars["DEPLOYDIR"], "%s-test.bin" % bb_vars["UBOOT_INITIAL_ENV"]
+ ))
+
+ self.assertExists(uboot_initial_env_binary_path)
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [OE-core] [PATCH v3 1/2] u-boot: make initial environment binary image
2025-11-21 8:49 [PATCH v3 1/2] u-boot: make initial environment binary image pierre-loup.gosse
2025-11-21 8:49 ` [PATCH v3 2/2] oe-selftest: uboot: add test for building U-Boot initial env binary pierre-loup.gosse
@ 2025-12-01 17:59 ` adrian.freihofer
2025-12-11 15:36 ` Pierre-loup GOSSE
2025-12-12 9:39 ` Martin Schwan
2025-12-16 15:20 ` Mathieu Dubois-Briand
3 siblings, 1 reply; 8+ messages in thread
From: adrian.freihofer @ 2025-12-01 17:59 UTC (permalink / raw)
To: pierre-loup.gosse, openembedded-core
Hi
Just a few thoughts on the matter. There are several ways to transfer
the default environment to a target device:
* Compile the environment in u-boot and run env default -a on the
target device, as documented at
https://docs.u-boot.org/en/latest/usage/environment.html#text-based-environment
.
* Install the file in /etc/u-boot-initial-env, which is used by
libubootenv as the initial environment on the target device.
* Install it as suggested in this patch, e.g., via wic or another flash
approach during device manufacturing.
It is important to enforce some consistency between all these different
approaches. Ideally, all approaches should use the same environment
source, which should be the file referenced by CONFIG_ENV_SOURCE_FILE.
If this is not the case, when the user executes, for example, env
default -a, they will get a different environment than the one
initialized by wic for fw_setenv.
Will this be mentioned in the documentation, or will it not be taken
into account in these patches?
Thank you for the patches.
Regards,
Adrian
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#226653):
> https://lists.openembedded.org/g/openembedded-core/message/226653
> Mute This Topic: https://lists.openembedded.org/mt/116405112/4454582
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe:
> https://lists.openembedded.org/g/openembedded-core/unsub [
> adrian.freihofer@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [OE-core] [PATCH v3 1/2] u-boot: make initial environment binary image
2025-12-01 17:59 ` [OE-core] [PATCH v3 1/2] u-boot: make initial environment binary image adrian.freihofer
@ 2025-12-11 15:36 ` Pierre-loup GOSSE
2025-12-11 23:04 ` adrian.freihofer
0 siblings, 1 reply; 8+ messages in thread
From: Pierre-loup GOSSE @ 2025-12-11 15:36 UTC (permalink / raw)
To: adrian.freihofer; +Cc: openembedded-core
[-- Attachment #1: Type: text/plain, Size: 2339 bytes --]
Hi,
Thanks for your remark.
I did not plan to mention this in the documentation patch, as I think it is
outside the scope of these patches, which only create the binary format of
the existing u-boot-initial-env file.
Besides, from my comprehension, all these approaches use the same
environment source from the default_environment structure declared in the
env_default.h file, which enforces consistency.
However, this is not prevent users from installing a different default
environment from the one compiled in U-Boot. If wanted, I can explicitly
mention this matter in my documentation patch.
Regards,
Pierre-Loup
On Mon, Dec 1, 2025 at 6:59 PM <adrian.freihofer@gmail.com> wrote:
> Hi
>
> Just a few thoughts on the matter. There are several ways to transfer
> the default environment to a target device:
>
> * Compile the environment in u-boot and run env default -a on the
> target device, as documented at
>
> https://docs.u-boot.org/en/latest/usage/environment.html#text-based-environment
> .
> * Install the file in /etc/u-boot-initial-env, which is used by
> libubootenv as the initial environment on the target device.
> * Install it as suggested in this patch, e.g., via wic or another flash
> approach during device manufacturing.
>
> It is important to enforce some consistency between all these different
> approaches. Ideally, all approaches should use the same environment
> source, which should be the file referenced by CONFIG_ENV_SOURCE_FILE.
> If this is not the case, when the user executes, for example, env
> default -a, they will get a different environment than the one
> initialized by wic for fw_setenv.
>
> Will this be mentioned in the documentation, or will it not be taken
> into account in these patches?
>
> Thank you for the patches.
> Regards,
> Adrian
>
>
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#226653):
> > https://lists.openembedded.org/g/openembedded-core/message/226653
> > Mute This Topic: https://lists.openembedded.org/mt/116405112/4454582
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe:
> > https://lists.openembedded.org/g/openembedded-core/unsub [
> > adrian.freihofer@gmail.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
>
[-- Attachment #2: Type: text/html, Size: 3523 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [OE-core] [PATCH v3 1/2] u-boot: make initial environment binary image
2025-12-11 15:36 ` Pierre-loup GOSSE
@ 2025-12-11 23:04 ` adrian.freihofer
0 siblings, 0 replies; 8+ messages in thread
From: adrian.freihofer @ 2025-12-11 23:04 UTC (permalink / raw)
To: Pierre-loup GOSSE; +Cc: openembedded-core
[-- Attachment #1: Type: text/plain, Size: 2742 bytes --]
Hi Pierre-Loup
Thank you for the explanation. I took a closer look at the tests and
now think I understand how it works and why it is consistent by
default.
Regards,
Adrian
On Thu, 2025-12-11 at 16:36 +0100, Pierre-loup GOSSE wrote:
> Hi,
>
> Thanks for your remark.
>
> I did not plan to mention this in the documentation patch, as I think
> it is outside the scope of these patches, which only create the
> binary format of the existing u-boot-initial-env file.
>
> Besides, from my comprehension, all these approaches use the same
> environment source from the default_environment structure declared in
> the env_default.h file, which enforces consistency.
>
> However, this is not prevent users from installing a different
> default environment from the one compiled in U-Boot. If wanted, I can
> explicitly mention this matter in my documentation patch.
>
> Regards,
> Pierre-Loup
>
>
>
> On Mon, Dec 1, 2025 at 6:59 PM <adrian.freihofer@gmail.com> wrote:
> > Hi
> >
> > Just a few thoughts on the matter. There are several ways to
> > transfer
> > the default environment to a target device:
> >
> > * Compile the environment in u-boot and run env default -a on the
> > target device, as documented at
> > https://docs.u-boot.org/en/latest/usage/environment.html#text-based-environment
> > .
> > * Install the file in /etc/u-boot-initial-env, which is used by
> > libubootenv as the initial environment on the target device.
> > * Install it as suggested in this patch, e.g., via wic or another
> > flash
> > approach during device manufacturing.
> >
> > It is important to enforce some consistency between all these
> > different
> > approaches. Ideally, all approaches should use the same environment
> > source, which should be the file referenced by
> > CONFIG_ENV_SOURCE_FILE.
> > If this is not the case, when the user executes, for example, env
> > default -a, they will get a different environment than the one
> > initialized by wic for fw_setenv.
> >
> > Will this be mentioned in the documentation, or will it not be
> > taken
> > into account in these patches?
> >
> > Thank you for the patches.
> > Regards,
> > Adrian
> >
> >
> > >
> > > -=-=-=-=-=-=-=-=-=-=-=-
> > > Links: You receive all messages sent to this group.
> > > View/Reply Online (#226653):
> > > https://lists.openembedded.org/g/openembedded-core/message/226653
> > > Mute This Topic:
> > https://lists.openembedded.org/mt/116405112/4454582
> > > Group Owner: openembedded-core+owner@lists.openembedded.org
> > > Unsubscribe:
> > > https://lists.openembedded.org/g/openembedded-core/unsub [
> > > adrian.freihofer@gmail.com]
> > > -=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 4306 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [OE-core] [PATCH v3 1/2] u-boot: make initial environment binary image
2025-11-21 8:49 [PATCH v3 1/2] u-boot: make initial environment binary image pierre-loup.gosse
2025-11-21 8:49 ` [PATCH v3 2/2] oe-selftest: uboot: add test for building U-Boot initial env binary pierre-loup.gosse
2025-12-01 17:59 ` [OE-core] [PATCH v3 1/2] u-boot: make initial environment binary image adrian.freihofer
@ 2025-12-12 9:39 ` Martin Schwan
2025-12-16 15:20 ` Mathieu Dubois-Briand
3 siblings, 0 replies; 8+ messages in thread
From: Martin Schwan @ 2025-12-12 9:39 UTC (permalink / raw)
To: pierre-loup.gosse@smile.fr,
openembedded-core@lists.openembedded.org
Thanks Pierre-loup for the patch. This is going to be very useful.
Reviewed-by: Martin Schwan <m.schwan@phytec.de>
Regards,
Martin
On Fri, 2025-11-21 at 09:49 +0100, Pierre-loup GOSSE via
lists.openembedded.org wrote:
> From: Pierre-Loup GOSSE <pierre-loup.gosse@smile.fr>
>
> Build the U-Boot initial environment binary image if
> UBOOT_INITIAL_ENV_BINARY is set to "1". The environment partition
> size
> (in bytes, hexadecimal or decimal) must be defined using
> UBOOT_INITIAL_ENV_BINARY_SIZE.
>
> If U-Boot environment redundancy is enabled,
> UBOOT_INITIAL_ENV_BINARY_REDUND must be set to "1".
>
> The resulting binary can be flashed using WIC at the environment
> offset,
> overriding any existing environment if present, for example:
>
> part --source rawcopy --sourceparams="file=u-boot-initial-env-
> sd.bin" --ondisk sda --no-table --offset 4096
>
> Signed-off-by: Pierre-Loup GOSSE <pierre-loup.gosse@smile.fr>
> ---
> Note: Once merged, a patch with the new variables will be submitted
> to the
> documentation mailing list.
>
> changes in v2:
> - fix uboot_deploy_config (builddir was missing)
>
> no changes in v3
> ---
> meta/classes-recipe/uboot-config.bbclass | 11 +++++++++
> meta/recipes-bsp/u-boot/u-boot.inc | 30
> ++++++++++++++++++++++++
> 2 files changed, 41 insertions(+)
>
> diff --git a/meta/classes-recipe/uboot-config.bbclass b/meta/classes-
> recipe/uboot-config.bbclass
> index fd6c045142..81057b5cad 100644
> --- a/meta/classes-recipe/uboot-config.bbclass
> +++ b/meta/classes-recipe/uboot-config.bbclass
> @@ -71,6 +71,14 @@ UBOOT_ENV_BINARY ?=
> "${UBOOT_ENV}.${UBOOT_ENV_SUFFIX}"
> UBOOT_ENV_IMAGE ?= "${UBOOT_ENV}-${MACHINE}-
> ${UBOOT_VERSION}.${UBOOT_ENV_SUFFIX}"
> UBOOT_ENV_SYMLINK ?= "${UBOOT_ENV}-${MACHINE}.${UBOOT_ENV_SUFFIX}"
>
> +# Enable the build of the U-Boot initial env binary image. The
> binary size is
> +# required (i.e. the U-Boot partition environment size). Since the
> environment
> +# layout with multiple copies is different, set
> UBOOT_INITIAL_ENV_BINARY_REDUND
> +# to "1" if the U-Boot environment redundancy is enabled.
> +UBOOT_INITIAL_ENV_BINARY ?= "0"
> +UBOOT_INITIAL_ENV_BINARY_SIZE ?= ""
> +UBOOT_INITIAL_ENV_BINARY_REDUND ?= "0"
> +
> # U-Boot EXTLINUX variables. U-Boot searches for
> /boot/extlinux/extlinux.conf
> # to find EXTLINUX conf file.
> UBOOT_EXTLINUX_INSTALL_DIR ?= "/boot/extlinux"
> @@ -100,6 +108,9 @@ UBOOT_DTB_BINARY ??= ""
> UBOOT_FIT_CHECK_SIGN ?= "uboot-fit_check_sign"
>
> python () {
> + if bb.utils.to_boolean(d.getVar('UBOOT_INITIAL_ENV_BINARY')) and
> d.getVar('UBOOT_INITIAL_ENV_BINARY_SIZE') == "":
> + bb.fatal("UBOOT_INITIAL_ENV_BINARY requires setting the U-
> Boot partition environment size with the
> UBOOT_INITIAL_ENV_BINARY_SIZE variable")
> +
> ubootmachine = d.getVar("UBOOT_MACHINE")
> ubootconfigflags = d.getVarFlags('UBOOT_CONFIG')
> ubootbinary = d.getVar('UBOOT_BINARY')
> diff --git a/meta/recipes-bsp/u-boot/u-boot.inc b/meta/recipes-bsp/u-
> boot/u-boot.inc
> index 16c9836508..ffa9ef2d59 100644
> --- a/meta/recipes-bsp/u-boot/u-boot.inc
> +++ b/meta/recipes-bsp/u-boot/u-boot.inc
> @@ -4,6 +4,7 @@ PROVIDES = "virtual/bootloader"
> PACKAGE_ARCH = "${MACHINE_ARCH}"
>
> DEPENDS += "${@bb.utils.contains('UBOOT_ENV_SUFFIX', 'scr', 'u-boot-
> mkimage-native', '', d)}"
> +DEPENDS += "${@ 'u-boot-mkenvimage-native' if
> bb.utils.to_boolean(d.getVar('UBOOT_INITIAL_ENV_BINARY')) else ''}"
>
> inherit uboot-config uboot-extlinux-config uboot-sign deploy
> python3native kernel-arch
>
> @@ -104,6 +105,10 @@ uboot_compile_config () {
> if [ -n "${UBOOT_INITIAL_ENV}" ]; then
> oe_runmake -C ${S} O=${B}/${builddir} u-boot-initial-env
> cp ${B}/${builddir}/u-boot-initial-env ${B}/${builddir}/u-
> boot-initial-env-${type}
> + if [ "${UBOOT_INITIAL_ENV_BINARY}" = "1" ] ; then
> + uboot_compile_initial_env_binary
> + cp ${B}/${builddir}/u-boot-initial-env.bin
> ${B}/${builddir}/u-boot-initial-env-${type}.bin
> + fi
> fi
> }
>
> @@ -123,7 +128,18 @@ uboot_compile () {
> # Generate the uboot-initial-env
> if [ -n "${UBOOT_INITIAL_ENV}" ]; then
> oe_runmake -C ${S} O=${B} u-boot-initial-env
> + if [ "${UBOOT_INITIAL_ENV_BINARY}" = "1" ] ; then
> + uboot_compile_initial_env_binary
> + fi
> + fi
> +}
> +
> +uboot_compile_initial_env_binary() {
> + redund=""
> + if [ "${UBOOT_INITIAL_ENV_BINARY_REDUND}" = "1" ] ; then
> + redund="-r"
> fi
> + uboot-mkenvimage -s ${UBOOT_INITIAL_ENV_BINARY_SIZE} ${redund} -
> o ${B}/${builddir}/u-boot-initial-env.bin ${B}/${builddir}/u-boot-
> initial-env
> }
>
> do_install () {
> @@ -388,9 +404,16 @@ uboot_deploy_config () {
> # Deploy the uboot-initial-env
> if [ -n "${UBOOT_INITIAL_ENV}" ]; then
> install -D -m 644 ${B}/${builddir}/u-boot-initial-env-
> ${type} ${DEPLOYDIR}/${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-
> ${UBOOT_VERSION}
> + if [ "${UBOOT_INITIAL_ENV_BINARY}" = "1" ]; then
> + install -D -m 644 ${B}/${builddir}/u-boot-initial-env-
> ${type}.bin ${DEPLOYDIR}/${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-
> ${UBOOT_VERSION}.bin
> + fi
> cd ${DEPLOYDIR}
> ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-
> ${UBOOT_VERSION} ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}
> ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-
> ${UBOOT_VERSION} ${UBOOT_INITIAL_ENV}-${type}
> + if [ "${UBOOT_INITIAL_ENV_BINARY}" = "1" ]; then
> + ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-
> ${UBOOT_VERSION}.bin ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}.bin
> + ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-
> ${UBOOT_VERSION}.bin ${UBOOT_INITIAL_ENV}-${type}.bin
> + fi
> fi
> }
>
> @@ -405,9 +428,16 @@ uboot_deploy () {
> # Deploy the uboot-initial-env
> if [ -n "${UBOOT_INITIAL_ENV}" ]; then
> install -D -m 644 ${B}/u-boot-initial-env
> ${DEPLOYDIR}/${UBOOT_INITIAL_ENV}-${MACHINE}-${UBOOT_VERSION}
> + if [ "${UBOOT_INITIAL_ENV_BINARY}" = "1" ]; then
> + install -D -m 644 ${B}/u-boot-initial-env.bin
> ${DEPLOYDIR}/${UBOOT_INITIAL_ENV}-${MACHINE}-${UBOOT_VERSION}.bin
> + fi
> cd ${DEPLOYDIR}
> ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${UBOOT_VERSION}
> ${UBOOT_INITIAL_ENV}-${MACHINE}
> ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${UBOOT_VERSION}
> ${UBOOT_INITIAL_ENV}
> + if [ "${UBOOT_INITIAL_ENV_BINARY}" = "1" ]; then
> + ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-
> ${UBOOT_VERSION}.bin ${UBOOT_INITIAL_ENV}-${MACHINE}.bin
> + ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-
> ${UBOOT_VERSION}.bin ${UBOOT_INITIAL_ENV}.bin
> + fi
> fi
> }
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#226653):
> https://lists.openembedded.org/g/openembedded-core/message/226653
> Mute This Topic: https://lists.openembedded.org/mt/116405112/9947111
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe:
> https://lists.openembedded.org/g/openembedded-core/unsub [
> m.schwan@phytec.de]
> -=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [OE-core] [PATCH v3 1/2] u-boot: make initial environment binary image
2025-11-21 8:49 [PATCH v3 1/2] u-boot: make initial environment binary image pierre-loup.gosse
` (2 preceding siblings ...)
2025-12-12 9:39 ` Martin Schwan
@ 2025-12-16 15:20 ` Mathieu Dubois-Briand
2025-12-16 15:28 ` Mathieu Dubois-Briand
3 siblings, 1 reply; 8+ messages in thread
From: Mathieu Dubois-Briand @ 2025-12-16 15:20 UTC (permalink / raw)
To: pierre-loup.gosse, openembedded-core
On Fri Nov 21, 2025 at 9:49 AM CET, Pierre-loup GOSSE via lists.openembedded.org wrote:
> From: Pierre-Loup GOSSE <pierre-loup.gosse@smile.fr>
>
> Build the U-Boot initial environment binary image if
> UBOOT_INITIAL_ENV_BINARY is set to "1". The environment partition size
> (in bytes, hexadecimal or decimal) must be defined using
> UBOOT_INITIAL_ENV_BINARY_SIZE.
>
> If U-Boot environment redundancy is enabled,
> UBOOT_INITIAL_ENV_BINARY_REDUND must be set to "1".
>
> The resulting binary can be flashed using WIC at the environment offset,
> overriding any existing environment if present, for example:
>
> part --source rawcopy --sourceparams="file=u-boot-initial-env-sd.bin" --ondisk sda --no-table --offset 4096
>
> Signed-off-by: Pierre-Loup GOSSE <pierre-loup.gosse@smile.fr>
> ---
> Note: Once merged, a patch with the new variables will be submitted to the
> documentation mailing list.
>
> changes in v2:
> - fix uboot_deploy_config (builddir was missing)
>
> no changes in v3
> ---
Hi Pierre-loup,
After the last comments I took your series for testing, but got the
following error during selftest:
2025-12-16 11:06:28,209 - oe-selftest - INFO - uboot.UBootTest.test_uboot_initial_env_binary (subunit.RemotedTestCase)
2025-12-16 11:06:28,210 - oe-selftest - INFO - ... FAIL
...
2025-12-16 11:06:05,623 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/uboot.py", line 152, in test_uboot_config_initial_env_binary
self.assertExists(uboot_initial_env_binary_path)
File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/case.py", line 251, in assertExists
raise self.failureException(msg)
AssertionError: '/srv/pokybuild/yocto-worker/oe-selftest-debian/build/build-st-1145752/tmp/work/qemux86_64-poky-linux/u-boot/2025.10/deploy-u-boot/u-boot-initial-env-test.bin' does not exist
https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/2838
https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/2732
Can you have a look at this issue?
Thanks,
Mathieu
--
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [OE-core] [PATCH v3 1/2] u-boot: make initial environment binary image
2025-12-16 15:20 ` Mathieu Dubois-Briand
@ 2025-12-16 15:28 ` Mathieu Dubois-Briand
0 siblings, 0 replies; 8+ messages in thread
From: Mathieu Dubois-Briand @ 2025-12-16 15:28 UTC (permalink / raw)
To: pierre-loup.gosse, openembedded-core
On Tue Dec 16, 2025 at 4:20 PM CET, Mathieu Dubois-Briand wrote:
> On Fri Nov 21, 2025 at 9:49 AM CET, Pierre-loup GOSSE via lists.openembedded.org wrote:
>> From: Pierre-Loup GOSSE <pierre-loup.gosse@smile.fr>
>>
>> Build the U-Boot initial environment binary image if
>> UBOOT_INITIAL_ENV_BINARY is set to "1". The environment partition size
>> (in bytes, hexadecimal or decimal) must be defined using
>> UBOOT_INITIAL_ENV_BINARY_SIZE.
>>
>> If U-Boot environment redundancy is enabled,
>> UBOOT_INITIAL_ENV_BINARY_REDUND must be set to "1".
>>
>> The resulting binary can be flashed using WIC at the environment offset,
>> overriding any existing environment if present, for example:
>>
>> part --source rawcopy --sourceparams="file=u-boot-initial-env-sd.bin" --ondisk sda --no-table --offset 4096
>>
>> Signed-off-by: Pierre-Loup GOSSE <pierre-loup.gosse@smile.fr>
>> ---
>> Note: Once merged, a patch with the new variables will be submitted to the
>> documentation mailing list.
>>
>> changes in v2:
>> - fix uboot_deploy_config (builddir was missing)
>>
>> no changes in v3
>> ---
>
> Hi Pierre-loup,
>
> After the last comments I took your series for testing, but got the
> following error during selftest:
>
> 2025-12-16 11:06:28,209 - oe-selftest - INFO - uboot.UBootTest.test_uboot_initial_env_binary (subunit.RemotedTestCase)
> 2025-12-16 11:06:28,210 - oe-selftest - INFO - ... FAIL
> ...
> 2025-12-16 11:06:05,623 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
> File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/uboot.py", line 152, in test_uboot_config_initial_env_binary
> self.assertExists(uboot_initial_env_binary_path)
> File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/case.py", line 251, in assertExists
> raise self.failureException(msg)
> AssertionError: '/srv/pokybuild/yocto-worker/oe-selftest-debian/build/build-st-1145752/tmp/work/qemux86_64-poky-linux/u-boot/2025.10/deploy-u-boot/u-boot-initial-env-test.bin' does not exist
>
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/2838
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/2732
>
> Can you have a look at this issue?
>
> Thanks,
> Mathieu
OK, it looks like the issue is somewhere between my keyboard and my
chair. Forget this issue for now...
--
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-12-16 15:28 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-21 8:49 [PATCH v3 1/2] u-boot: make initial environment binary image pierre-loup.gosse
2025-11-21 8:49 ` [PATCH v3 2/2] oe-selftest: uboot: add test for building U-Boot initial env binary pierre-loup.gosse
2025-12-01 17:59 ` [OE-core] [PATCH v3 1/2] u-boot: make initial environment binary image adrian.freihofer
2025-12-11 15:36 ` Pierre-loup GOSSE
2025-12-11 23:04 ` adrian.freihofer
2025-12-12 9:39 ` Martin Schwan
2025-12-16 15:20 ` Mathieu Dubois-Briand
2025-12-16 15:28 ` Mathieu Dubois-Briand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox