* [PATCH] ARM: lib32: bootm: always pass a device tree to barebox images
@ 2026-09-28 9:59 Ahmad Fatoum
0 siblings, 0 replies; only message in thread
From: Ahmad Fatoum @ 2026-09-28 9:59 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum, Steffen Trumtrar
Since commit 828ffad14177 ("bootm: make fallback to barebox internal
tree optional"), disabling CONFIG_BOOTM_OFTREE_FALLBACK doesn't only
affect kernels, but also barebox images started with bootm. Without -o,
these now get ATAGs instead of a device tree, which leaves images like
barebox-dt-2nd.img or the STM32MP generic BL33 without any description
of the hardware and thus without an interactive console.
The option is meant to make users notice a missing kernel device tree,
but barebox images don't ship one that should be preferred over ours.
So let's have the barebox image handler preset barebox' own device tree
for bootm_get_devicetree() to use if none was supplied.
Tested on an STM32MP157C-DK2 with CONFIG_BOOTM_OFTREE_FALLBACK=n: a
zImage still gets no device tree, -o is still honoured and a chainloaded
generic BL33 image comes up with a console.
Assisted-by: Claude:opus-5.5
Fixes: 828ffad14177 ("bootm: make fallback to barebox internal tree optional")
Reported-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/lib32/bootm.c | 17 ++++++++++++++++-
common/bootm.c | 4 +++-
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/arch/arm/lib32/bootm.c b/arch/arm/lib32/bootm.c
index e2a80ada788b..cfd30d1e0aff 100644
--- a/arch/arm/lib32/bootm.c
+++ b/arch/arm/lib32/bootm.c
@@ -457,9 +457,24 @@ static struct image_handler zimage_handler = {
.filetype = filetype_arm_zimage,
};
+static int do_bootm_barebox(struct image_data *data)
+{
+ /*
+ * Unlike a kernel, barebox doesn't ship a device tree that should be
+ * preferred over ours: Images like barebox-dt-2nd.img and the
+ * STM32MP generic BL33 image learn about the hardware solely from
+ * the device tree they are passed. So pass along ours if none was
+ * supplied, regardless of CONFIG_BOOTM_OFTREE_FALLBACK.
+ */
+ if (!data->oftree)
+ data->of_root_node = of_dup(of_get_root_node());
+
+ return do_bootm_linux(data);
+}
+
static struct image_handler barebox_handler = {
.name = "ARM barebox",
- .bootm = do_bootm_linux,
+ .bootm = do_bootm_barebox,
.check_image = bootm_efi_check_image,
.filetype = filetype_arm_barebox,
};
diff --git a/common/bootm.c b/common/bootm.c
index 27da1a590bf1..7ba31379a217 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -330,7 +330,9 @@ void *bootm_get_devicetree(struct image_data *data)
printf("using %s as devicetree\n", data->oftree->name);
} else {
- data->of_root_node = of_dup_root_node_for_boot();
+ /* image handlers may preset barebox' own device tree */
+ if (!data->of_root_node)
+ data->of_root_node = of_dup_root_node_for_boot();
if (!data->of_root_node) {
if (bootm_verbose(data))
printf("using no devicetree\n");
--
2.47.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-28 10:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-28 9:59 [PATCH] ARM: lib32: bootm: always pass a device tree to barebox images Ahmad Fatoum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox