linux: introduce BR2_KERNEL_DTB_KEEP_DIRNAME
authorMichael Walle <michael@walle.cc>
Thu, 4 Jun 2020 22:11:21 +0000 (00:11 +0200)
committerYann E. MORIN <yann.morin.1998@free.fr>
Fri, 5 Jun 2020 22:07:25 +0000 (00:07 +0200)
In linux, newer architectures like ARM64 and RISC-V keep their device
tree sources organized by subdirectories. When these device trees are
installed by the kernel they will keep the directory names. But
buildroot strips the prefixes when installing them into /boot or the
images directory.
Sometimes the bootloader references the device tree by name (e.g.
u-boot has the environment variable 'fdtfile') which also includes
the prefix directory.
Make it possible to keep this prefix during installation, so we can
be compatible with other distributions and make it easier for the
user, because he doesn't have to change that environment variable.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
linux/Config.in
linux/linux.mk

index f85d72068c896d5e091675041b787029aa9c7804..61e84f00b4e0bf596438669cbc0012b684e7bd29 100644 (file)
@@ -407,6 +407,13 @@ config BR2_LINUX_KERNEL_CUSTOM_DTS_PATH
          You can provide a list of dts paths to copy and
          build, separated by spaces.
 
+config BR2_KERNEL_DTB_KEEP_DIRNAME
+       bool "Keep the directory name of the Device Tree"
+       help
+         If enabled, the device tree blobs keep their
+         directory prefixes when they get copied to the
+         output image directory or the target directory.
+
 config BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT
        bool "Build Device Tree with overlay support"
        help
index ea7490d613c51239dbe40840130802e6e153f6a1..c3859a59d57eeca891107f8c71e8ddff6fe55654 100644 (file)
@@ -378,10 +378,11 @@ endef
 ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB),)
 define LINUX_INSTALL_DTB
        # dtbs moved from arch/<ARCH>/boot to arch/<ARCH>/boot/dts since 3.8-rc1
-       cp $(addprefix \
-               $(LINUX_ARCH_PATH)/boot/$(if $(wildcard \
-               $(addprefix $(LINUX_ARCH_PATH)/boot/dts/,$(LINUX_DTBS))),dts/),$(LINUX_DTBS)) \
-               $(1)
+       $(foreach dtb,$(LINUX_DTBS), \
+               install -D \
+                       $(or $(wildcard $(LINUX_ARCH_PATH)/boot/dts/$(dtb)),$(LINUX_ARCH_PATH)/boot/$(dtb)) \
+                       $(1)/$(if $(BR2_KERNEL_DTB_KEEP_DIRNAME),$(dtb),$(notdir $(dtb)))
+       )
 endef
 endif # BR2_LINUX_KERNEL_APPENDED_DTB
 endif # BR2_LINUX_KERNEL_DTB_IS_SELF_BUILT