[Buildroot] [PATCH] boot/uboot: support custom DTS with CONFIG_OF_UPSTREAM
Alexander Sverdlin
alexander.sverdlin at gmail.com
Tue Sep 1 14:52:24 UTC 2026
Since U-Boot 2024.07, boards with CONFIG_OF_UPSTREAM build their device
trees from dts/upstream/src/<arch>/<vendor>/ instead of arch/<arch>/dts/,
so the files copied by BR2_TARGET_UBOOT_CUSTOM_DTS_PATH were ignored and
the build failed with "No rule to make target".
Derive the destination from the U-Boot configuration, including the vendor
sub-directory taken from CONFIG_DEFAULT_DEVICE_TREE. That tree keeps the
Linux architecture naming, so aarch64 has to be mapped back from
UBOOT_ARCH ("arm") to "arm64".
Signed-off-by: Alexander Sverdlin <alexander.sverdlin at gmail.com>
---
boot/uboot/uboot.mk | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/boot/uboot/uboot.mk b/boot/uboot/uboot.mk
index 5b3f46ac74..06417da06f 100644
--- a/boot/uboot/uboot.mk
+++ b/boot/uboot/uboot.mk
@@ -426,10 +426,26 @@ endif # BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY
UBOOT_CUSTOM_DTS_PATH = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_DTS_PATH))
+# With CONFIG_OF_UPSTREAM the device trees are built from dts/upstream/src/
+# instead of arch/<arch>/dts/, in the vendor sub-directory encoded in the
+# device tree name. That tree keeps the Linux architecture naming, so aarch64
+# has to be mapped back from UBOOT_ARCH ("arm") to "arm64".
+define UBOOT_INSTALL_CUSTOM_DTS
+ dts_dir="arch/$(UBOOT_ARCH)/dts"; \
+ if grep -q "^CONFIG_OF_UPSTREAM=y" $(@D)/.config; then \
+ if grep -q "^CONFIG_ARM64=y" $(@D)/.config; then \
+ dts_dir="dts/upstream/src/arm64"; \
+ else \
+ dts_dir="dts/upstream/src/$(UBOOT_ARCH)"; \
+ fi; \
+ dt=$$(sed -n 's/^CONFIG_DEFAULT_DEVICE_TREE="\(.*\)"$$/\1/p' $(@D)/.config); \
+ case "$$dt" in */*) dts_dir="$$dts_dir/$${dt%/*}";; esac; \
+ fi; \
+ cp -f $(UBOOT_CUSTOM_DTS_PATH) $(@D)/$$dts_dir/
+endef
+
define UBOOT_BUILD_CMDS
- $(if $(UBOOT_CUSTOM_DTS_PATH),
- cp -f $(UBOOT_CUSTOM_DTS_PATH) $(@D)/arch/$(UBOOT_ARCH)/dts/
- )
+ $(if $(UBOOT_CUSTOM_DTS_PATH),$(UBOOT_INSTALL_CUSTOM_DTS))
$(TARGET_CONFIGURE_OPTS) \
PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
PKG_CONFIG_SYSROOT_DIR="/" \
--
2.55.0
More information about the buildroot
mailing list