From 5472d93d1c10dd457322e0a7767346ed69700fd9 Mon Sep 17 00:00:00 2001 From: Michael Walle Date: Fri, 21 Feb 2025 23:55:25 +0100 Subject: [PATCH] linux: add support for device tree overlays The linux kernel can build device tree overlays (.dtbo) itself. Add support to build and copy them along with the actual device trees. These can either be in-tree device tree overlays (BR2_LINUX_KERNEL_INTREE_DTSO_NAMES) or they can be provided outside of the kernel (BR2_LINUX_KERNEL_CUSTOM_DTS_PATH). In the latter case, the overlay source files will be copied into the kernel tree first. Signed-off-by: Michael Walle Reviewed-by: Niklas Cassel Signed-off-by: Romain Naour Signed-off-by: Julien Olivain --- linux/Config.in | 14 +++++++++++--- linux/linux.mk | 7 +++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/linux/Config.in b/linux/Config.in index 30fc9f095f..d6a0ace6c0 100644 --- a/linux/Config.in +++ b/linux/Config.in @@ -426,12 +426,20 @@ config BR2_LINUX_KERNEL_INTREE_DTS_NAME the trailing .dts. You can provide a list of dts files to build, separated by spaces. +config BR2_LINUX_KERNEL_INTREE_DTSO_NAMES + string "In-tree Device Tree Overlay file names" + help + Names of in-tree device tree overlay, without the trailing + .dtso which should be built and installed into the target + system, separated by spaces. + config BR2_LINUX_KERNEL_CUSTOM_DTS_PATH string "Out-of-tree Device Tree Source file paths" help - Paths to out-of-tree Device Tree Source (.dts) and Device Tree - Source Include (.dtsi) files, separated by spaces. These files - will be copied to the kernel sources and the .dts files will + Paths to out-of-tree Device Tree Source (.dts), Device Tree + Source Include (.dtsi) and Device Tree Overlay Source (.dtso) + files, separated by spaces. These files will be copied to the + kernel sources and the .dts files will be compiled from there. config BR2_LINUX_KERNEL_DTB_KEEP_DIRNAME diff --git a/linux/linux.mk b/linux/linux.mk index 12699b8ee4..9c621c18d5 100644 --- a/linux/linux.mk +++ b/linux/linux.mk @@ -203,14 +203,17 @@ endif LINUX_VERSION_PROBED = `MAKEFLAGS='$(filter-out w,$(MAKEFLAGS))' $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) --no-print-directory -s kernelrelease 2>/dev/null` LINUX_DTS_NAME += $(call qstrip,$(BR2_LINUX_KERNEL_INTREE_DTS_NAME)) +LINUX_DTSO_NAMES += $(call qstrip,$(BR2_LINUX_KERNEL_INTREE_DTSO_NAMES)) # We keep only the .dts files, so that the user can specify both .dts # and .dtsi files in BR2_LINUX_KERNEL_CUSTOM_DTS_PATH. Both will be # copied to arch//boot/dts, but only the .dts files will # actually be generated as .dtb. -LINUX_DTS_NAME += $(basename $(filter %.dts,$(notdir $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH))))) +LINUX_CUSTOM_DTS_PATH = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH)) +LINUX_DTS_NAME += $(basename $(filter %.dts,$(notdir $(LINUX_CUSTOM_DTS_PATH)))) +LINUX_DTSO_NAMES += $(basename $(filter %.dtso,$(notdir $(LINUX_CUSTOM_DTS_PATH)))) -LINUX_DTBS = $(addsuffix .dtb,$(LINUX_DTS_NAME)) +LINUX_DTBS = $(addsuffix .dtb,$(LINUX_DTS_NAME)) $(addsuffix .dtbo,$(LINUX_DTSO_NAMES)) ifeq ($(BR2_LINUX_KERNEL_IMAGE_TARGET_CUSTOM),y) LINUX_IMAGE_NAME = $(call qstrip,$(BR2_LINUX_KERNEL_IMAGE_NAME))