[PATCH] defaultenv: boot/bnet: fallback to booting generic 2nd stage FIT image

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Apr 9 06:19:14 PDT 2025


With CONFIG_BOARD_GENERIC_FIT enabled, barebox generates a FIT image
containing a generic DT-based second-stage barebox images as well as all
enabled DTs.

Add it as fallback if the image with the hostname is missing, example:

  Board-specific image: afa-barebox-lxa-mc1
   Arch-specific image: afa-barebox-arm

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 common/globalvar.c                     | 3 +++
 defaultenv/defaultenv-2-base/boot/bnet | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/common/globalvar.c b/common/globalvar.c
index 5f5b7d44ae62..26202f2b493d 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -680,6 +680,8 @@ static int globalvar_init(void)
 	if (strlen(buildsystem_version_string) > 0)
 		globalvar_add_simple("buildsystem.version", buildsystem_version_string);
 
+	globalvar_add_simple("arch", CONFIG_ARCH_LINUX_NAME);
+
 #ifdef __BIG_ENDIAN
 	endianness = "big";
 #elif defined(__LITTLE_ENDIAN)
@@ -698,6 +700,7 @@ BAREBOX_MAGICVAR(global.version, "The barebox version");
 BAREBOX_MAGICVAR(global.buildsystem.version,
 		 "version of buildsystem barebox was built with");
 BAREBOX_MAGICVAR(global.endianness, "The barebox endianness");
+BAREBOX_MAGICVAR(global.arch, "Name of architecture as used by Linux");
 
 /**
  * nvvar_save - save NV variables to persistent environment
diff --git a/defaultenv/defaultenv-2-base/boot/bnet b/defaultenv/defaultenv-2-base/boot/bnet
index e378acd1e65a..b2eeab93d9b8 100644
--- a/defaultenv/defaultenv-2-base/boot/bnet
+++ b/defaultenv/defaultenv-2-base/boot/bnet
@@ -5,3 +5,6 @@
 path="/mnt/tftp"
 
 global.bootm.image="${path}/${global.user}-barebox-${global.hostname}"
+if [ ! -f "${global.bootm.image}" ]; then
+      global.bootm.image="${path}/${global.user}-barebox-${global.arch}"
+fi
-- 
2.39.5




More information about the barebox mailing list