* [PATCH RFT 1/4] efi: payload: ignore ESP state.dtb if device tree is populated
2026-08-26 12:15 [PATCH RFT 0/4] efi: payload: allow extension via fragments Ahmad Fatoum
@ 2026-08-26 12:15 ` Ahmad Fatoum
2026-08-26 12:15 ` [PATCH RFT 2/4] kbuild: dtc: introduce empty fallback device tree Ahmad Fatoum
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2026-08-26 12:15 UTC (permalink / raw)
To: barebox; +Cc: fpg, chalianis1, Ahmad Fatoum
In preparation for allowing the state nodes to ship inside the barebox
binary (as we do for non-EFI-payload already), add provisions to skip
the external file if barebox already has a populated DT.
Also for the case that a state had already been set up, skip manual
creation of the state node.
Assisted-by: Claude:opus-5
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
efi/payload/init.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/efi/payload/init.c b/efi/payload/init.c
index 1e5f2eb8cf56..db4bc25682a3 100644
--- a/efi/payload/init.c
+++ b/efi/payload/init.c
@@ -284,6 +284,7 @@ static int efi_late_init(void)
{
const char *state_desc = "/boot/EFI/barebox/state.dtb";
struct device_node *state_root = NULL;
+ struct device_node *root;
size_t size;
void *fdt;
int ret;
@@ -303,6 +304,17 @@ static int efi_late_init(void)
return 0;
}
+ /*
+ * A device tree built into barebox takes precedence: any state it
+ * describes has been instantiated by the state driver already.
+ */
+ root = of_get_root_node();
+ if (root && !list_empty(&root->children)) {
+ pr_warn("device tree is populated, ignoring %s\n", state_desc);
+ free(fdt);
+ return 0;
+ }
+
state_root = of_unflatten_dtb(fdt, size);
free(fdt);
@@ -320,6 +332,10 @@ static int efi_late_init(void)
return 0;
}
+ /* probing the registered tree may have instantiated it already */
+ if (state_by_node(np))
+ return 0;
+
state = state_new_from_node(np, false);
if (IS_ERR(state))
return PTR_ERR(state);
--
2.47.3
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH RFT 2/4] kbuild: dtc: introduce empty fallback device tree
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
2026-08-26 12:15 ` [PATCH RFT 3/4] efi: payload: export device tree in barebox-dtb EFI variable Ahmad Fatoum
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2026-08-26 12:15 UTC (permalink / raw)
To: barebox; +Cc: fpg, chalianis1, Ahmad Fatoum
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
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH RFT 3/4] efi: payload: export device tree in barebox-dtb EFI variable
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 ` [PATCH RFT 2/4] kbuild: dtc: introduce empty fallback device tree Ahmad Fatoum
@ 2026-08-26 12:15 ` 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
4 siblings, 0 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2026-08-26 12:15 UTC (permalink / raw)
To: barebox; +Cc: fpg, chalianis1, Ahmad Fatoum
An operating system booted by barebox on an EFI system doesn't
necessarily have a device tree, so we elected so far to provide a
state.dtb file on the ESP.
This is cumbersome and, in a secure-booting system, has the state DT
parser process untrusted input, which on all other platforms is not
case: The data itself may be untrusted, but the layout description is
verified as part of barebox and passed along.
To allow the same in the EFI payload case, export barebox' device tree
in flattened form in the barebox-dtb EFI variable under the barebox
vendor GUID, next to the bootloader interface variables barebox sets
already.
Under Linux, it can be read out of efivarfs. The variable is volatile
like the others, so it always describes the barebox instance that
booted the system.
The export happens right before control is handed over to the next image,
same as LoaderTimeExecUSec, so the only consumer, which runs after the
handover, sees the final device tree, including a state description read
from the EFI system partition at late init. Exporting before every
StartImage also covers chainloaded EFI bootloaders.
Assisted-by: Claude:opus-5
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
efi/payload/fdt.c | 28 ++++++++++++++++++++++++++++
efi/payload/handover.c | 2 ++
efi/payload/image.c | 2 ++
include/efi/payload.h | 6 ++++++
4 files changed, 38 insertions(+)
diff --git a/efi/payload/fdt.c b/efi/payload/fdt.c
index f98fd86bfbd6..4ab8c197af2b 100644
--- a/efi/payload/fdt.c
+++ b/efi/payload/fdt.c
@@ -9,6 +9,7 @@
#include <efi/payload.h>
#include <efi/payload/init.h>
#include <efi/guid.h>
+#include <efi/variable.h>
extern char __dtb_fallback_start[];
@@ -67,3 +68,30 @@ static int efi_fdt_probe(void)
return 0;
}
late_efi_initcall(efi_fdt_probe);
+
+/*
+ * Export barebox' device tree, so the OS can learn about barebox-specific
+ * configuration like the state partition layout. Called just before handing
+ * over control, so the variable describes the final device tree.
+ */
+void efi_export_dtb(void)
+{
+ struct fdt_header *fdt;
+ int ret;
+
+ if (!of_get_root_node())
+ return;
+
+ fdt = of_get_flattened_tree(NULL, false);
+ if (!fdt)
+ return;
+
+ ret = efi_set_variable("barebox-dtb", &efi_barebox_vendor_guid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS |
+ EFI_VARIABLE_RUNTIME_ACCESS,
+ fdt, fdt32_to_cpu(fdt->totalsize));
+ if (ret)
+ pr_warn("Cannot export device tree: %pe\n", ERR_PTR(ret));
+
+ free(fdt);
+}
diff --git a/efi/payload/handover.c b/efi/payload/handover.c
index 544fdfb3c6ad..669d88c722b6 100644
--- a/efi/payload/handover.c
+++ b/efi/payload/handover.c
@@ -183,6 +183,8 @@ static int do_bootm_efi(struct image_data *data)
goto err_free;
}
+ efi_export_dtb();
+
efi_set_variable_usec("LoaderTimeExecUSec", &efi_systemd_vendor_guid,
ktime_to_us(ktime_get()));
diff --git a/efi/payload/image.c b/efi/payload/image.c
index 378709b6de95..6485bc2f2d68 100644
--- a/efi/payload/image.c
+++ b/efi/payload/image.c
@@ -109,6 +109,8 @@ int efi_execute_image(efi_handle_t handle,
is_driver = (loaded_image->image_code_type == EFI_BOOT_SERVICES_CODE) ||
(loaded_image->image_code_type == EFI_RUNTIME_SERVICES_CODE);
+ efi_export_dtb();
+
if (filetype_is_linux_efi_image(filetype)) {
options = linux_bootargs_get();
printf("Booting kernel via StartImage");
diff --git a/include/efi/payload.h b/include/efi/payload.h
index 381598ba59f2..9e4e8c5ce0ae 100644
--- a/include/efi/payload.h
+++ b/include/efi/payload.h
@@ -27,6 +27,12 @@ extern struct efi_loaded_image *efi_loaded_image;
void *efi_earlymem_alloc(const struct efi_system_table *sys_table,
size_t memsize, enum efi_memory_type mem_type);
+#ifdef CONFIG_OFTREE
+void efi_export_dtb(void);
+#else
+static inline void efi_export_dtb(void) {}
+#endif
+
__attribute__((noreturn)) void efi_main(efi_handle_t, struct efi_system_table *);
#define for_each_efi_config_table(t) \
--
2.47.3
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH RFT 4/4] Documentation: efi: describe device tree handling
2026-08-26 12:15 [PATCH RFT 0/4] efi: payload: allow extension via fragments Ahmad Fatoum
` (2 preceding siblings ...)
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 ` Ahmad Fatoum
2026-08-26 22:56 ` [PATCH RFT 0/4] efi: payload: allow extension via fragments chalianis1
4 siblings, 0 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2026-08-26 12:15 UTC (permalink / raw)
To: barebox; +Cc: fpg, chalianis1, Ahmad Fatoum
Describe how the device tree built into the EFI payload is populated with
external dts fragments, how that interacts with the state.dtb file on the
EFI system partition and where the operating system finds the device tree
barebox exports.
Assisted-by: Claude:opus-5
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Documentation/boards/efi.rst | 75 ++++++++++++++++++++++++++++++++++--
Documentation/user/state.rst | 5 +++
2 files changed, 76 insertions(+), 4 deletions(-)
diff --git a/Documentation/boards/efi.rst b/Documentation/boards/efi.rst
index 869e5e88172f..da50fc8ff6cd 100644
--- a/Documentation/boards/efi.rst
+++ b/Documentation/boards/efi.rst
@@ -44,10 +44,8 @@ architectures. Switching to USB boot in the BIOS should then be enough to
start barebox via USB. Some BIOSes allow to specify a path to a binary to
be executed, others have a "start UEFI shell" entry which executes
EFI/Shellx64.efi on the :term:`ESP`. This can be a barebox binary as well.
-To use the :ref:`state_framework`, the describing devicetree file ``state.dtb``
-has to be put into the ``EFI/barebox/`` directory.
-Supported backends for EFI are raw partitions that can be discovered via a
-partition UUID.
+See `Device tree`_ below on how to describe barebox-specific configuration,
+like a :ref:`state_framework` partition, to barebox.
With this sample script you can create bootable image and transfer it to the
flash driver:
@@ -216,6 +214,75 @@ has a device parameter ``devpath`` which contains its device path:
barebox:/ echo ${handle-00000000d0012198.devpath}
pci_root(0)/Pci(0x1d,0x0)/Usb(0x1,0x0)/Usb(0x2,0x0)
+Device tree
+-----------
+
+EFI systems describe their hardware to barebox via EFI protocols and ACPI, so
+barebox needs no device tree to drive them. Some barebox functionality is
+configured by device tree nevertheless, most prominently the
+:ref:`state_framework`. For that reason, the empty fallback device tree from
+``common/fallback.dts`` is compiled into the EFI payload, which can be
+populated at build time with the ``CONFIG_EXTERNAL_DTS_FRAGMENTS`` option,
+e.g.::
+
+ CONFIG_EXTERNAL_DTS_FRAGMENTS="/path/to/barebox-state.dtsi"
+
+The fragments listed there are appended to every device tree built, so a
+fragment meant for the EFI payload only should be guarded with the
+``fallback_dts`` macro, which is defined while the fallback device tree
+is compiled:
+
+.. code-block:: text
+
+ #ifdef fallback_dts
+ / {
+ aliases {
+ state = &state;
+ };
+
+ state: state {
+ compatible = "barebox,state";
+ magic = <0x27031977>;
+ backend-type = "raw";
+ backend = <&backend_state>;
+ backend-stridesize = <0x40>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ vars {
+ /* ... */
+ };
+ };
+
+ partitions {
+ compatible = "fixed-partitions";
+
+ backend_state: state {
+ partuuid = "9ba1c1c5-6ad7-4e8a-8d69-b1c4b0d1e1e1";
+ };
+ };
+ };
+ #endif
+
+Supported *state* backends for EFI are raw partitions that can be discovered
+via a partition UUID as done above.
+
+Should the device tree be empty, barebox falls back to reading a devicetree
+file ``state.dtb`` out of the ``EFI/barebox/`` directory on the :term:`ESP`.
+If the built-in device tree is populated, an existing ``state.dtb`` is
+ignored with a warning.
+
+When barebox runs as EFI payload, its internal device tree is exported in
+flattened form in the ``barebox-dtb`` EFI variable under the barebox vendor
+GUID just before barebox starts an EFI image or boots a kernel, so the
+operating system can be configured by the same description. Under Linux,
+it's readable at
+``/sys/firmware/efi/efivars/barebox-dtb-5b91f69c-8b88-4a2b-9269-5f1d802b5175``,
+where the blob is prefixed by a four byte EFI variable attribute word.
+
+This is not done when barebox acts as EFI loader for the application.
+
EFI variables
-------------
diff --git a/Documentation/user/state.rst b/Documentation/user/state.rst
index d97ba4e9f157..aa0b255c781b 100644
--- a/Documentation/user/state.rst
+++ b/Documentation/user/state.rst
@@ -35,6 +35,11 @@ the same.
To define a *state* variable set, a devicetree based description is used. Refer to
:ref:`barebox,state` for further details.
+On systems that boot the operating system without a device tree, the
+description can't be shared with it by fixing up the OS device tree. barebox
+running as EFI payload exports its device tree in an EFI variable instead, see
+:ref:`barebox_on_uefi`.
+
There are several software components involved, which are described in this
section.
--
2.47.3
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH RFT 0/4] efi: payload: allow extension via fragments
2026-08-26 12:15 [PATCH RFT 0/4] efi: payload: allow extension via fragments Ahmad Fatoum
` (3 preceding siblings ...)
2026-08-26 12:15 ` [PATCH RFT 4/4] Documentation: efi: describe device tree handling Ahmad Fatoum
@ 2026-08-26 22:56 ` chalianis1
2026-08-27 7:31 ` Ahmad Fatoum
4 siblings, 1 reply; 7+ messages in thread
From: chalianis1 @ 2026-08-26 22:56 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox, fpg, chalianis1
On 2026-08-26 14:15 +0200, Ahmad Fatoum wrote:
> 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.
>
> This series adds the necessary bits to have this work the same on
> non-EFI-payload platforms.
>
> @Fabian, can you give this a test?
>
> Ahmad Fatoum (4):
> efi: payload: ignore ESP state.dtb if device tree is populated
> kbuild: dtc: introduce empty fallback device tree
> efi: payload: export device tree in barebox-dtb EFI variable
> Documentation: efi: describe device tree handling
>
> Documentation/boards/efi.rst | 75 ++++++++++++++++++++++++++++++++++--
> Documentation/user/state.rst | 5 +++
> 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 | 53 +++++++++++++++++++++++++
> efi/payload/handover.c | 2 +
> efi/payload/image.c | 2 +
> efi/payload/init.c | 16 ++++++++
> include/efi/payload.h | 6 +++
> scripts/Makefile.dtbs | 10 +++++
> 14 files changed, 186 insertions(+), 15 deletions(-)
> create mode 100644 arch/x86/dts/Makefile
> create mode 100644 common/fallback.dts
>
> --
> 2.47.3
>
>
>
>
does this work for using state fragment on arm platforms?
I tried quickly to compile with a dtsi for RPi4 and get an error
because the emmc label is not known for RPi3.
For EFI it works on both qemu (x86/arm).
make -j 8 CONFIG_EXTERNAL_DTS_FRAGMENTS=../barebox-arm64-poc/state-rpi.dtsi
UPD include/generated/utsversion.h
ENV arch/arm/boards/raspberry-pi/defaultenv-rpi.bbenv
DTC arch/arm/dts/fallback.dtb
ENV defaultenv/barebox_default_env
CC [P] common/imd-barebox.pbl.o
DTC arch/arm/dts/bcm2837-rpi-3.dtb
DTC arch/arm/dts/bcm2837-rpi-cm3.dtb
./../barebox-arm64-poc/state-rpi.dtsi:11.8-78.4: ERROR (phandle_references): /state: Reference to non-existent node or label "emmc2"
ERROR: Input tree has errors, aborting (use -f to force output)
make[4]: *** [scripts/Makefile.dtbs:100: arch/arm/dts/fallback.dtb] Error 2
make[4]: *** Waiting for unfinished jobs....
ENV defaultenv/defaultenv-2-base.bbenv
./../barebox-arm64-poc/state-rpi.dtsi:11.8-78.4: ERROR (phandle_references): /state: Reference to non-existent node or label "emmc2"
ERROR: Input tree has errors, aborting (use -f to force output)
make[4]: *** [scripts/Makefile.dtbs:95: arch/arm/dts/bcm2837-rpi-cm3.dtb] Error 2
CC common/version.o
./../barebox-arm64-poc/state-rpi.dtsi:11.8-78.4: ERROR (phandle_references): /state: Reference to non-existent node or label "emmc2"
ERROR: Input tree has errors, aborting (use -f to force output)
make[4]: *** [scripts/Makefile.dtbs:95: arch/arm/dts/bcm2837-rpi-3.dtb] Error 2
make[3]: *** [scripts/Makefile.build:468: arch/arm/dts] Error 2
make[2]: *** [scripts/Makefile.build:468: arch/arm] Error 2
make[2]: *** Waiting for unfinished jobs....
AR common/built-in.pbl.a
AR common/built-in.a
make[1]: *** [/home/anicha1/sources/barebox-intern/Makefile:1801: .] Error 2
make: *** [Makefile:200: __sub-make] Error 2
best regards.
Anis
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH RFT 0/4] efi: payload: allow extension via fragments
2026-08-26 22:56 ` [PATCH RFT 0/4] efi: payload: allow extension via fragments chalianis1
@ 2026-08-27 7:31 ` Ahmad Fatoum
0 siblings, 0 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2026-08-27 7:31 UTC (permalink / raw)
To: chalianis1; +Cc: barebox, fpg
Hello Anis,
On 8/27/26 12:56 AM, chalianis1@gmail.com wrote:
> On 2026-08-26 14:15 +0200, Ahmad Fatoum wrote:
> does this work for using state fragment on arm platforms?
> I tried quickly to compile with a dtsi for RPi4 and get an error
> because the emmc label is not known for RPi3.
The fragment is appended to all device trees that are being built. If
you want to customize it per device tree, use the preprocessor
#ifdef bcm2711_rpi_4_dts
backend = <&emmc2>;
#endif
There are similar macros defined for every DT, so you can have one
fragment that covers multiple boards or multiple fragments that each has
an ifdef to cover only a single board.
The alternative would be disabling other boards. I see now though that
this wouldn't fully work because empty.dts is built always, so I should
probably limit its build to only the EFI payload case for now.
Will do so in a later revision until I get more feedback.
Having a compile error when there is a mismatch is one reason why this
might be preferable to overlays. There's work underway for device tree
addons, which looks really interesting. Perhaps when that's widely
available, it would be a better fit for providing the state snippet as
boards could define an API of sorts to make it easy to plug addons into
them.
Thanks for giving this a try!
Ahmad
> ./../barebox-arm64-poc/state-rpi.dtsi:11.8-78.4: ERROR (phandle_references): /state: Reference to non-existent node or label "emmc2"
>
> ERROR: Input tree has errors, aborting (use -f to force output)
> make[4]: *** [scripts/Makefile.dtbs:100: arch/arm/dts/fallback.dtb] Error 2
> make[4]: *** Waiting for unfinished jobs....
> ENV defaultenv/defaultenv-2-base.bbenv
> ./../barebox-arm64-poc/state-rpi.dtsi:11.8-78.4: ERROR (phandle_references): /state: Reference to non-existent node or label "emmc2"
>
> ERROR: Input tree has errors, aborting (use -f to force output)
> make[4]: *** [scripts/Makefile.dtbs:95: arch/arm/dts/bcm2837-rpi-cm3.dtb] Error 2
> CC common/version.o
> ./../barebox-arm64-poc/state-rpi.dtsi:11.8-78.4: ERROR (phandle_references): /state: Reference to non-existent node or label "emmc2"
>
> ERROR: Input tree has errors, aborting (use -f to force output)
> make[4]: *** [scripts/Makefile.dtbs:95: arch/arm/dts/bcm2837-rpi-3.dtb] Error 2
> make[3]: *** [scripts/Makefile.build:468: arch/arm/dts] Error 2
> make[2]: *** [scripts/Makefile.build:468: arch/arm] Error 2
> make[2]: *** Waiting for unfinished jobs....
> AR common/built-in.pbl.a
> AR common/built-in.a
> make[1]: *** [/home/anicha1/sources/barebox-intern/Makefile:1801: .] Error 2
> make: *** [Makefile:200: __sub-make] Error 2
>
> best regards.
> Anis
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 7+ messages in thread