Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v3 1/1] linux: make out-of-tree DTS work with newest kernels
@ 2025-01-03 14:33 Edgar Bonet
  2025-01-03 22:07 ` Romain Naour via buildroot
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Edgar Bonet @ 2025-01-03 14:33 UTC (permalink / raw)
  To: Buildroot development
  Cc: Michael Walle, Sergey Matyukevich, Romain Naour, Chris Packham,
	Kilian Zinnecker

Since Linux 6.12, the Buildroot option BR2_LINUX_KERNEL_CUSTOM_DTS_PATH
does not work as expected on arm, arm64, mips and ricv.[1] These are the
architectures that store the in-tree DTS files in vendor-specific
subdirectories of arch/$ARCH/boot/dts/.

BR2_LINUX_KERNEL_CUSTOM_DTS_PATH was introduced in Buildroot 2012.08
(commit 69fc497df0ae "Rework support for the device tree"). At the time,
the kernel kept all in-tree DTS files directly in arch/$ARCH/boot/dts/,
and this is where Buildroot drops the user's custom DTS. Vendor-specific
subdirectories appeared in Linux v3.19 for the arm64 architecture, and
this scheme was later adopted by mips, riscv and arm.

For these architectures, Linux 6.12 (commit e7e2941300d2, "kbuild: split
device tree build rules into scripts/Makefile.dtbs") made the DTB build
infrastructure incompatible with the way
BR2_LINUX_KERNEL_CUSTOM_DTS_PATH is implemented. This infrastructure now
expects all DTS files to be in vendor-specific subdirectories on the
architectures that use this scheme. Fulfilling this kernel expectation
would require a new configuration parameter for the name of the
appropriate vendor subdirectory. It would also require changing the
relative paths to included .dtsi files.

Let's add instead a rule to the top dts/Makefile for each DTB we want to
build. This avoids breaking user's out-of-tree configurations.

[1] https://lists.buildroot.org/pipermail/buildroot/2024-October/765463.html

Reported-by: Chris Packham <judge.packham@gmail.com>
Signed-off-by: Edgar Bonet <bonet@grenoble.cnrs.fr>
---
Changes v2 -> v3:
  - note, in the comment and in the log message, that this issue only
    affects some architectures
  - expand the log message with some historical context
These changes were suggested by Romain Naour.

Changes v1 -> v2:
  - define a hook for LINUX_POST_PATCH_HOOKS and LINUX_POST_RSYNC_HOOKS
    instead of modifying LINUX_BUILD_CMDS
  - use $(patsubst %.dts,%.dtb,$(dts)) instead of $(dts:%.dts=%.dtb)
both changes suggested by Arnout Vandecappelle.

This was build-tested with an Acqua defconfig,
in the same manner as v2:

    # Test with an old kernel: v6.6.30
    make acmesystems_acqua_a5_512mb_defconfig
    make linux

    # Test with a new kernel: v6.12.8
    make linux-dirclean
    git am bump_Acqua_kernel_to_v6.12.8.patch
    make acmesystems_acqua_a5_512mb_defconfig
    make linux

    # Test the OVERRIDE_SRCDIR case.
    make linux-dirclean
    git -C $HOME/src/linux checkout v6.12.8
    echo "LINUX_OVERRIDE_SRCDIR = $HOME/src/linux" > local.mk
    make acmesystems_acqua_a5_512mb_defconfig
    make linux
---
 linux/linux.mk | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/linux/linux.mk b/linux/linux.mk
index 12699b8ee4..e6e8a3c3bc 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -327,6 +327,17 @@ define LINUX_TRY_PATCH_TIMECONST
 endef
 LINUX_POST_PATCH_HOOKS += LINUX_TRY_PATCH_TIMECONST
 
+# On some architectures, kernels 6.12+ won't compile the custom DTS
+# files we drop into arch/$ARCH/boot/dts unless we add specific rules to
+# that directory's Makefile.
+define LINUX_ADD_DTB_MAKE_RULES
+	$(foreach dts,$(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH)), \
+		echo "dtb-y += $(patsubst %.dts,%.dtb,$(notdir $(dts)))" >> $(LINUX_ARCH_PATH)/boot/dts/Makefile
+	)
+endef
+LINUX_POST_PATCH_HOOKS += LINUX_ADD_DTB_MAKE_RULES
+LINUX_POST_RSYNC_HOOKS += LINUX_ADD_DTB_MAKE_RULES
+
 LINUX_KERNEL_CUSTOM_LOGO_PATH = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_LOGO_PATH))
 ifneq ($(LINUX_KERNEL_CUSTOM_LOGO_PATH),)
 LINUX_DEPENDENCIES += host-imagemagick
-- 
2.34.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-01-22 19:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-03 14:33 [Buildroot] [PATCH v3 1/1] linux: make out-of-tree DTS work with newest kernels Edgar Bonet
2025-01-03 22:07 ` Romain Naour via buildroot
2025-01-04  7:21 ` Kilian Zinnecker via buildroot
2025-01-05 21:11 ` Michael Walle via buildroot
2025-01-22 10:40   ` Romain Naour via buildroot
2025-01-22 10:52     ` Arnout Vandecappelle via buildroot
2025-01-22 11:06       ` Romain Naour via buildroot
2025-01-22 11:09       ` Michael Walle via buildroot
2025-01-22 19:48     ` Edgar Bonet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox