boot/uboot: support custom DTS with CONFIG_OF_UPSTREAM
PATCH v2 1/1 boot/uboot: support custom DTS with CONFIG_OF_UPSTREAM
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".
---
Changelog:
v2:
- handle *u-boot.dtsi separately
- document the new behaviour with OF_UPSTREAM-enabled U-Boot builds v1:
https://lore.kernel.org/all/[email protected]/
boot/uboot/Config.in | 13 +++++++++++-- boot/uboot/uboot.mk | 30 +++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 5 deletions(-)
boot/uboot/Config.in +11 -2
@@ -803,8 +803,17 @@ config BR2_TARGET_UBOOT_CUSTOM_DTS_PATH string "Device Tree Source file paths" help Space-separated list of paths to device tree source files - that will be copied to arch/ARCH/dts/ before starting the - build. + that will be copied before starting the build. + + They are copied to arch/ARCH/dts/, except that a configuration + with CONFIG_OF_UPSTREAM (U-Boot 2024.07 and later) builds its + device trees from the vendor directory below dts/upstream/src/ + that CONFIG_DEFAULT_DEVICE_TREE names, so they are copied + there instead. + + The *u-boot.dtsi fragments U-Boot includes on its own are + copied to arch/ARCH/dts/ in either case, as that is the only + place it looks for them. To use this device tree source file, the U-Boot configuration file must refer to it.
boot/uboot/uboot.mk +27 -3
@@ -426,10 +426,34 @@ 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". The fragments +# U-Boot includes on its own are searched for in arch/<arch>/dts/ only, so +# they stay there whatever the device trees do. +define UBOOT_INSTALL_CUSTOM_DTS + arch_dir="arch/$(UBOOT_ARCH)/dts"; \ + dts_dir="$$arch_dir"; \ + 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; \ + for dts in $(UBOOT_CUSTOM_DTS_PATH); do \ + case "$$dts" in \ + *u-boot.dtsi) cp -f "$$dts" $(@D)/$$arch_dir/;; \ + *) cp -f "$$dts" $(@D)/$$dts_dir/;; \ + esac; \ + done +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="/" \
Signature · 6 lines
2.55.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hi Alexander,
I am interested by your updates. See below
Quoted 10 lines · Alexander Sverdlin
Since U-Boot 2024.07, boards with
CONFIG_OF_UPSTREAMbuild their device trees from dts/upstream/src/<arch>/<vendor>/ instead of arch/<arch>/dts/, so the files copied byBR2_TARGET_UBOOT_CUSTOM_DTS_PATHwere 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 fromUBOOT_ARCH("arm") to "arm64".
...
Quoted 14 lines
boot/uboot/Config.in +11
-2Space-separated list of paths to device tree source files - that will be copied to arch/ARCH/dts/ before starting the - build. + that will be copied before starting the build. + + They are copied to arch/ARCH/dts/, except that a configuration + with CONFIG_OF_UPSTREAM (U-Boot 2024.07 and later) builds its + device trees from the vendor directory below dts/upstream/src/ + that CONFIG_DEFAULT_DEVICE_TREE names, so they are copied + there instead. + + The *u-boot.dtsi fragments U-Boot includes on its own are + copied to arch/ARCH/dts/ in either case, as that is the only + place it looks for them.
...
boot/uboot/uboot.mk endif # BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY · line 434
Quoted 6 lines
boot/uboot/uboot.mk +6
-0+# 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". The fragments +# U-Boot includes on its own are searched for in arch/<arch>/dts/ only, so +# they stay there whatever the device trees do.
Those comments are similar 3 times: into config.in, into uboot.mk and into the commit log.
I would prefer to avoid reading them 3 times and having them only into the commit log.
Why is it specific to arm64 ? Why isn't this feature generic ?
best regards,
Vincent
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Hi Vincent!
Quoted 40 lines · Vincent Jardin
Quoted 10 lines
Since U-Boot 2024.07, boards with
CONFIG_OF_UPSTREAMbuild their device trees from dts/upstream/src/<arch>/<vendor>/ instead of arch/<arch>/dts/, so the files copied byBR2_TARGET_UBOOT_CUSTOM_DTS_PATHwere 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 fromUBOOT_ARCH("arm") to "arm64"....
Quoted 14 lines
Space-separated list of paths to device tree source files
boot/uboot/Config.in +11
-2- that will be copied to arch/ARCH/dts/ before starting the - build. + that will be copied before starting the build. + + They are copied to arch/ARCH/dts/, except that a configuration + with CONFIG_OF_UPSTREAM (U-Boot 2024.07 and later) builds its + device trees from the vendor directory below dts/upstream/src/ + that CONFIG_DEFAULT_DEVICE_TREE names, so they are copied + there instead. + + The *u-boot.dtsi fragments U-Boot includes on its own are + copied to arch/ARCH/dts/ in either case, as that is the only + place it looks for them....
boot/uboot/uboot.mk endif # BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY · line 434
Quoted 6 lines
boot/uboot/uboot.mk +6
-0+# 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". The fragments +# U-Boot includes on its own are searched for in arch/<arch>/dts/ only, so +# they stay there whatever the device trees do.Those comments are similar 3 times: into config.in, into uboot.mk and into the commit log.
Quoted 2 lines
I would prefer to avoid reading them 3 times and having them only into the commit log.
Thanks for the quick feedback! No problem, I'll prune the texts next time.
Quoted 1 line
Why is it specific to arm64 ? Why isn't this feature generic ?
arm64 is special because it maps to "arm" ARCH in U-Boot, together with arm, which maps to "arm" as well. Other ARCHs should be 1:1 mapping.
Signature · 5 lines
Alexander Sverdlin. _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot