From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: fpg@pengutronix.de, chalianis1@gmail.com,
Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH RFT 2/4] kbuild: dtc: introduce empty fallback device tree
Date: Wed, 26 Aug 2026 14:15:30 +0200 [thread overview]
Message-ID: <20260826121640.2936023-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20260826121640.2936023-1-a.fatoum@pengutronix.de>
CONFIG_EXTERNAL_DTS_FRAGMENTS can't be used with the EFI payload, because
it has no internal DT at build-time and until recently not even a DT at
runtime.
Instead of synthesizing a DT root node at runtime, just compile in an
empty DT that the user can extend with builtin state nodes via
CONFIG_EXTERNAL_DTS_FRAGMENTS.
x86 has had no device trees of its own so far, but gets a dts directory
here as well, so the fallback device tree is built the same way on every
architecture and efi/payload/Makefile needs no special case for the
architectures without one.
That makes it the first dtb in the tree that is built without
CONFIG_PBL_IMAGE, so define suffix_y for that case as well:
scripts/gen-dtb-s reads the size of the compressed dtb unconditionally,
but scripts/Makefile.pbl, which defines suffix_y, is only included for PBL
builds. Without it, the .dtb.z is never generated, the build prints an ls
error for the missing file and the dtb objects are regenerated on every
make.
Assisted-by: Claude:fable-5
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/dts/Makefile | 2 ++
arch/riscv/dts/Makefile | 2 ++
arch/x86/Kbuild | 2 ++
arch/x86/dts/Makefile | 5 +++++
common/fallback.dts | 10 ++++++++++
efi/payload/boarddata.c | 11 -----------
efi/payload/fdt.c | 25 +++++++++++++++++++++++++
scripts/Makefile.dtbs | 10 ++++++++++
8 files changed, 56 insertions(+), 11 deletions(-)
create mode 100644 arch/x86/dts/Makefile
create mode 100644 common/fallback.dts
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 64f46064b735..b537aa757a93 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1,5 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-only
+obj-pbl-$(CONFIG_OFDEVICE) += fallback.dtb.o
+
lwl-$(CONFIG_MACH_ADVANTECH_ROM_742X) += imx6dl-advantech-rom-7421.dtb.o
lwl-$(CONFIG_MACH_AFI_GF) += am335x-afi-gf.dtb.o
lwl-$(CONFIG_MACH_AM625_SK) += k3-am625-sk.dtb.o k3-am625-r5-sk.dtb.o k3-am625sip-r5-sk.dtb.o
diff --git a/arch/riscv/dts/Makefile b/arch/riscv/dts/Makefile
index 521c8407c5ae..a89f246bb633 100644
--- a/arch/riscv/dts/Makefile
+++ b/arch/riscv/dts/Makefile
@@ -1,5 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
+obj-pbl-$(CONFIG_OFDEVICE) += fallback.dtb.o
+
lwl-$(CONFIG_BOARD_ERIZO_GENERIC) += erizo-generic.dtb.o
lwl-$(CONFIG_BOARD_HIFIVE) += hifive-unmatched-a00.dtb.o \
hifive-unleashed-a00.dtb.o
diff --git a/arch/x86/Kbuild b/arch/x86/Kbuild
index f5fa602122a5..28744c7dc511 100644
--- a/arch/x86/Kbuild
+++ b/arch/x86/Kbuild
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-y += lib/
+
+obj-$(CONFIG_OFTREE) += dts/
diff --git a/arch/x86/dts/Makefile b/arch/x86/dts/Makefile
new file mode 100644
index 000000000000..25b653bc9b03
--- /dev/null
+++ b/arch/x86/dts/Makefile
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+obj-pbl-$(CONFIG_OFDEVICE) += fallback.dtb.o
+
+clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts *.dtb.z
diff --git a/common/fallback.dts b/common/fallback.dts
new file mode 100644
index 000000000000..7c88eba462b6
--- /dev/null
+++ b/common/fallback.dts
@@ -0,0 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/dts-v1/;
+
+/*
+ * Fallback device tree for images not tied to a board, like the EFI payload.
+ * Empty, but can be populated via CONFIG_EXTERNAL_DTS_FRAGMENTS.
+ */
+
+/ {
+};
diff --git a/efi/payload/boarddata.c b/efi/payload/boarddata.c
index ec6ee7bbd98f..a2f4b8d21b4a 100644
--- a/efi/payload/boarddata.c
+++ b/efi/payload/boarddata.c
@@ -14,7 +14,6 @@
#include <linux/printk.h>
#include <debug_ll.h>
#include <init.h>
-#include <of.h>
#include <pbl/handoff-data.h>
static int handle_efi_boarddata(void)
@@ -47,13 +46,3 @@ static int handle_efi_boarddata(void)
return 0;
}
pure_initcall(handle_efi_boarddata);
-
-static __maybe_unused int efi_register_of(void)
-{
- if (!BS)
- return 0;
- return barebox_register_of(of_new_node(NULL, NULL));
-}
-#ifdef CONFIG_OFDEVICE
-core_initcall(efi_register_of);
-#endif
diff --git a/efi/payload/fdt.c b/efi/payload/fdt.c
index 9cdb32370f22..f98fd86bfbd6 100644
--- a/efi/payload/fdt.c
+++ b/efi/payload/fdt.c
@@ -5,10 +5,35 @@
#include <common.h>
#include <init.h>
#include <libfile.h>
+#include <of.h>
#include <efi/payload.h>
#include <efi/payload/init.h>
#include <efi/guid.h>
+extern char __dtb_fallback_start[];
+
+/*
+ * EFI systems have no device tree, but barebox may still need one for its
+ * own purposes, e.g. to describe a state partition. Register a tree that's
+ * empty unless populated via CONFIG_EXTERNAL_DTS_FRAGMENTS.
+ */
+static __maybe_unused int efi_of_init(void)
+{
+ int ret;
+
+ ret = barebox_register_fdt(__dtb_fallback_start);
+ if (ret == -EBUSY) {
+ /* architecture code registered a device tree already */
+ pr_debug("keeping already registered device tree\n");
+ return 0;
+ }
+
+ return ret;
+}
+#ifdef CONFIG_OFDEVICE
+core_efi_initcall(efi_of_init);
+#endif
+
static int efi_fdt_probe(void)
{
struct efi_config_table *ect;
diff --git a/scripts/Makefile.dtbs b/scripts/Makefile.dtbs
index 2228d04eea98..3c32747a30e5 100644
--- a/scripts/Makefile.dtbs
+++ b/scripts/Makefile.dtbs
@@ -72,6 +72,11 @@ cmd_dt_S_dtbo = $(srctree)/scripts/gen-dtbo-s $(subst -,_,$(*F)) $< > $@
$(obj)/%.dtbo.S: $(obj)/%.dtbo $(srctree)/scripts/gen-dtbo-s FORCE
$(call if_changed,dt_S_dtbo)
+# scripts/Makefile.pbl defines suffix_y, but is only included for PBL builds.
+# The compressed dtb is unused without a PBL, but still needs to exist, as
+# scripts/gen-dtb-s reads its size unconditionally.
+suffix_y ?= comp_copy
+
$(obj)/%.dtb.z: $(obj)/%.dtb FORCE
$(call if_changed,$(suffix_y))
@@ -89,6 +94,11 @@ cmd_dtc = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) \
$(obj)/%.dtb: $(src)/%.dts FORCE
$(call if_changed_dep,dtc,$(dts-frags))
+# The fallback device tree is board-agnostic, so its source is shared by all
+# architectures instead of living in a dts directory
+$(obj)/fallback.dtb: $(obj)/%.dtb: $(srctree)/common/fallback.dts FORCE
+ $(call if_changed_dep,dtc,$(dts-frags))
+
$(obj)/%.dtbo: $(src)/%.dtso $(DTC) FORCE
$(call if_changed_dep,dtc)
--
2.47.3
next prev parent reply other threads:[~2026-08-26 12:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 12:15 [PATCH RFT 0/4] efi: payload: allow extension via fragments Ahmad Fatoum
2026-08-26 12:15 ` [PATCH RFT 1/4] efi: payload: ignore ESP state.dtb if device tree is populated Ahmad Fatoum
2026-08-26 12:15 ` Ahmad Fatoum [this message]
2026-08-26 12:15 ` [PATCH RFT 3/4] efi: payload: export device tree in barebox-dtb EFI variable Ahmad Fatoum
2026-08-26 12:15 ` [PATCH RFT 4/4] Documentation: efi: describe device tree handling Ahmad Fatoum
2026-08-26 22:56 ` [PATCH RFT 0/4] efi: payload: allow extension via fragments chalianis1
2026-08-27 7:31 ` Ahmad Fatoum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260826121640.2936023-3-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=chalianis1@gmail.com \
--cc=fpg@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox