* [Buildroot] [PATCH] linux: Add support for vendor directory in BR2_LINUX_KERNEL_CUSTOM_DTS_PATH
@ 2024-07-10 15:29 Kory Maincent via buildroot
2024-07-15 14:07 ` Arnout Vandecappelle via buildroot
0 siblings, 1 reply; 5+ messages in thread
From: Kory Maincent via buildroot @ 2024-07-10 15:29 UTC (permalink / raw)
To: buildroot; +Cc: Kory Maincent, thomas.petazzoni
Linux organizes devicetree files under vendor subdirectories for arm and
arm64 architectures, such as arch/<arch>/boot/dts/<vendor>/. The
BR2_LINUX_KERNEL_CUSTOM_DTS_PATH was only copying devicetree files to
arch/<arch>/boot/dts/, which is incompatible with the vendor
subdirectory structure.
This patch adds support for using a directory in
BR2_LINUX_KERNEL_CUSTOM_DTS_PATH that matches the vendor subdirectory name.
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---
linux/Config.in | 4 +++-
linux/linux.mk | 14 +++++++++++---
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/linux/Config.in b/linux/Config.in
index 34057a4893..6ca615cae3 100644
--- a/linux/Config.in
+++ b/linux/Config.in
@@ -423,7 +423,9 @@ config BR2_LINUX_KERNEL_CUSTOM_DTS_PATH
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
- be compiled from there.
+ be compiled from there. You can also use a directory which
+ name match the vendor name as in
+ arch/<arch>/boot/dts/<vendor>/
config BR2_LINUX_KERNEL_DTB_KEEP_DIRNAME
bool "Keep the directory name of the Device Tree"
diff --git a/linux/linux.mk b/linux/linux.mk
index 16d9f19470..07d4ddf7f3 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -198,7 +198,15 @@ LINUX_DTS_NAME += $(call qstrip,$(BR2_LINUX_KERNEL_INTREE_DTS_NAME))
# and .dtsi files in BR2_LINUX_KERNEL_CUSTOM_DTS_PATH. Both will be
# copied to arch/<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)))))
+# In case we are copying a vendor dts subdirectory as in
+# arch/<arch>/boot/dts/<vendor>/ we have to append the wildcard to the
+# folder to list the devicetree.
+LINUX_KERNEL_CUSTOM_DTS_PATH = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH))
+ifneq ($(wildcard $(LINUX_KERNEL_CUSTOM_DTS_PATH)/.*),)
+LINUX_DTS_NAME += $(addprefix $(notdir $(LINUX_KERNEL_CUSTOM_DTS_PATH))/,$(basename $(filter %.dts,$(notdir $(wildcard $(LINUX_KERNEL_CUSTOM_DTS_PATH)/*)))))
+else
+LINUX_DTS_NAME += $(basename $(filter %.dts,$(notdir $(wildcard $(LINUX_KERNEL_CUSTOM_DTS_PATH)))))
+endif
LINUX_DTBS = $(addsuffix .dtb,$(LINUX_DTS_NAME))
@@ -505,8 +513,8 @@ endif
# http://lists.busybox.net/pipermail/buildroot/2020-May/282727.html
define LINUX_BUILD_CMDS
$(call KCONFIG_DISABLE_OPT,CONFIG_GCC_PLUGINS)
- $(foreach dts,$(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH)), \
- cp -f $(dts) $(LINUX_ARCH_PATH)/boot/dts/
+ $(foreach dts,$(LINUX_KERNEL_CUSTOM_DTS_PATH), \
+ cp -rf $(dts) $(LINUX_ARCH_PATH)/boot/dts/
)
$(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) all
$(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_TARGET_NAME)
--
2.25.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Buildroot] [PATCH] linux: Add support for vendor directory in BR2_LINUX_KERNEL_CUSTOM_DTS_PATH
2024-07-10 15:29 [Buildroot] [PATCH] linux: Add support for vendor directory in BR2_LINUX_KERNEL_CUSTOM_DTS_PATH Kory Maincent via buildroot
@ 2024-07-15 14:07 ` Arnout Vandecappelle via buildroot
2024-07-15 15:22 ` Brandon Maier via buildroot
0 siblings, 1 reply; 5+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2024-07-15 14:07 UTC (permalink / raw)
To: Kory Maincent, buildroot; +Cc: thomas.petazzoni
On 10/07/2024 17:29, Kory Maincent via buildroot wrote:
> Linux organizes devicetree files under vendor subdirectories for arm and
> arm64 architectures, such as arch/<arch>/boot/dts/<vendor>/. The
> BR2_LINUX_KERNEL_CUSTOM_DTS_PATH was only copying devicetree files to
> arch/<arch>/boot/dts/, which is incompatible with the vendor
> subdirectory structure.
I don't see what the problem is though? If a DT is put in
arch/<arch>/boot/dts, it can still be built with the current Buildroot.
The only thing you need to do is to make sure to do
#include "vendor/cpu.dtsi"
instead of
#include "cpu.dtsi"
The in-tree DTSes don't have the vendor/ part in the include, of course, but
for custom DTSes you can do what you want, right?
I'm going to mark it as Rejected for now, but feel free to resubmit if there
is a good reason to have this feature.
> This patch adds support for using a directory in
> BR2_LINUX_KERNEL_CUSTOM_DTS_PATH that matches the vendor subdirectory name.
>
> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
> ---
> linux/Config.in | 4 +++-
> linux/linux.mk | 14 +++++++++++---
> 2 files changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/linux/Config.in b/linux/Config.in
> index 34057a4893..6ca615cae3 100644
> --- a/linux/Config.in
> +++ b/linux/Config.in
> @@ -423,7 +423,9 @@ config BR2_LINUX_KERNEL_CUSTOM_DTS_PATH
> 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
> - be compiled from there.
> + be compiled from there. You can also use a directory which
> + name match the vendor name as in
> + arch/<arch>/boot/dts/<vendor>/
I think the explanation could be better:
Starting from Linux 6.5, the device trees are put in a <vendor>
subdirectory. To emulate this, you can put custom device trees
in a directory with that same <vendor> name, and specify the
path to that directory here instead of to individual dts files.
I feel this is pretty complicated for a user to understand though...
>
> config BR2_LINUX_KERNEL_DTB_KEEP_DIRNAME
> bool "Keep the directory name of the Device Tree"
> diff --git a/linux/linux.mk b/linux/linux.mk
> index 16d9f19470..07d4ddf7f3 100644
> --- a/linux/linux.mk
> +++ b/linux/linux.mk
> @@ -198,7 +198,15 @@ LINUX_DTS_NAME += $(call qstrip,$(BR2_LINUX_KERNEL_INTREE_DTS_NAME))
> # and .dtsi files in BR2_LINUX_KERNEL_CUSTOM_DTS_PATH. Both will be
> # copied to arch/<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)))))
> +# In case we are copying a vendor dts subdirectory as in
> +# arch/<arch>/boot/dts/<vendor>/ we have to append the wildcard to the
> +# folder to list the devicetree.
> +LINUX_KERNEL_CUSTOM_DTS_PATH = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH))
> +ifneq ($(wildcard $(LINUX_KERNEL_CUSTOM_DTS_PATH)/.*),)
You don't actually need the * here.
Also, better use positive logic (ifeq instead of ifneq, and swap the branches).
> +LINUX_DTS_NAME += $(addprefix $(notdir $(LINUX_KERNEL_CUSTOM_DTS_PATH))/,$(basename $(filter %.dts,$(notdir $(wildcard $(LINUX_KERNEL_CUSTOM_DTS_PATH)/*)))))
> +else
> +LINUX_DTS_NAME += $(basename $(filter %.dts,$(notdir $(wildcard $(LINUX_KERNEL_CUSTOM_DTS_PATH)))))
This is also getting pretty complicated, could it be refactored so there are a
bit more common parts? Something like:
ifeq ($(wildcard $(LINUX_KERNEL_CUSTOM_DTS_PATH)/.),)
LINUX_CUSTOM_DTS_FILES = $(wildcard $(LINUX_KERNEL_CUSTOM_DTS_PATH)/*))
LINUX_CUSTOM_DTS_PREFIX = $(notdir $(LINUX_KERNEL_CUSTOM_DTS_PATH))/
else
LINUX_CUSTOM_DTS_FILES = $(LINUX_KERNEL_CUSTOM_DTS_PATH)
endif
LINUX_DTS_NAME += $(addprefix $(LINUX_CUSTOM_DTS_PREFIX),$(basename $(filter
%.dts,$(LINUX_CUSTOM_DTS_FILES))))
(parenthesis added in an email editor so probably unbalanced :-)
Regards,
Arnout
> +endif
>
> LINUX_DTBS = $(addsuffix .dtb,$(LINUX_DTS_NAME))
>
> @@ -505,8 +513,8 @@ endif
> # http://lists.busybox.net/pipermail/buildroot/2020-May/282727.html
> define LINUX_BUILD_CMDS
> $(call KCONFIG_DISABLE_OPT,CONFIG_GCC_PLUGINS)
> - $(foreach dts,$(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH)), \
> - cp -f $(dts) $(LINUX_ARCH_PATH)/boot/dts/
> + $(foreach dts,$(LINUX_KERNEL_CUSTOM_DTS_PATH), \
> + cp -rf $(dts) $(LINUX_ARCH_PATH)/boot/dts/
> )
> $(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) all
> $(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_TARGET_NAME)
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Buildroot] [PATCH] linux: Add support for vendor directory in BR2_LINUX_KERNEL_CUSTOM_DTS_PATH
2024-07-15 14:07 ` Arnout Vandecappelle via buildroot
@ 2024-07-15 15:22 ` Brandon Maier via buildroot
2025-02-20 13:53 ` Matthew Weber
0 siblings, 1 reply; 5+ messages in thread
From: Brandon Maier via buildroot @ 2024-07-15 15:22 UTC (permalink / raw)
To: Arnout Vandecappelle, Kory Maincent, buildroot; +Cc: thomas.petazzoni
Hi Arnout, Kory,
On Mon Jul 15, 2024 at 2:07 PM UTC, Arnout Vandecappelle via buildroot wrote:
>
>
> On 10/07/2024 17:29, Kory Maincent via buildroot wrote:
> > Linux organizes devicetree files under vendor subdirectories for arm and
> > arm64 architectures, such as arch/<arch>/boot/dts/<vendor>/. The
> > BR2_LINUX_KERNEL_CUSTOM_DTS_PATH was only copying devicetree files to
> > arch/<arch>/boot/dts/, which is incompatible with the vendor
> > subdirectory structure.
>
> I don't see what the problem is though? If a DT is put in
> arch/<arch>/boot/dts, it can still be built with the current Buildroot.
>
> The only thing you need to do is to make sure to do
>
> #include "vendor/cpu.dtsi"
>
> instead of
>
> #include "cpu.dtsi"
>
> The in-tree DTSes don't have the vendor/ part in the include, of course, but
> for custom DTSes you can do what you want, right?
This does work, I do this for Xilinx devicetrees which go into a
'xilinx' vendor directory.
>
> I'm going to mark it as Rejected for now, but feel free to resubmit if there
> is a good reason to have this feature.
This does solve one problem for me. I compile the same devicetree into
Linux and U-Boot. But Linux migrated the Xilinx devicetrees into a
'xilinx/' vendor directory. But U-Boot has not made the same migration
as their Makefiles don't support dts sub-directories. So the #include
path is the only thing different between the Linux and U-Boot
devicetrees.
I work around it for now by patching a symlink into U-Boot
'arch/arm/dts/xilinx -> ./'.
Though ideally U-Boot would be updated to use the same devicetree layout
as Linux.
Thanks,
Brandon
>
>
> > This patch adds support for using a directory in
> > BR2_LINUX_KERNEL_CUSTOM_DTS_PATH that matches the vendor subdirectory name.
> >
> > Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
> > ---
> > linux/Config.in | 4 +++-
> > linux/linux.mk | 14 +++++++++++---
> > 2 files changed, 14 insertions(+), 4 deletions(-)
> >
> > diff --git a/linux/Config.in b/linux/Config.in
> > index 34057a4893..6ca615cae3 100644
> > --- a/linux/Config.in
> > +++ b/linux/Config.in
> > @@ -423,7 +423,9 @@ config BR2_LINUX_KERNEL_CUSTOM_DTS_PATH
> > 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
> > - be compiled from there.
> > + be compiled from there. You can also use a directory which
> > + name match the vendor name as in
> > + arch/<arch>/boot/dts/<vendor>/
>
> I think the explanation could be better:
>
> Starting from Linux 6.5, the device trees are put in a <vendor>
> subdirectory. To emulate this, you can put custom device trees
> in a directory with that same <vendor> name, and specify the
> path to that directory here instead of to individual dts files.
>
> I feel this is pretty complicated for a user to understand though...
>
> >
> > config BR2_LINUX_KERNEL_DTB_KEEP_DIRNAME
> > bool "Keep the directory name of the Device Tree"
> > diff --git a/linux/linux.mk b/linux/linux.mk
> > index 16d9f19470..07d4ddf7f3 100644
> > --- a/linux/linux.mk
> > +++ b/linux/linux.mk
> > @@ -198,7 +198,15 @@ LINUX_DTS_NAME += $(call qstrip,$(BR2_LINUX_KERNEL_INTREE_DTS_NAME))
> > # and .dtsi files in BR2_LINUX_KERNEL_CUSTOM_DTS_PATH. Both will be
> > # copied to arch/<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)))))
> > +# In case we are copying a vendor dts subdirectory as in
> > +# arch/<arch>/boot/dts/<vendor>/ we have to append the wildcard to the
> > +# folder to list the devicetree.
> > +LINUX_KERNEL_CUSTOM_DTS_PATH = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH))
> > +ifneq ($(wildcard $(LINUX_KERNEL_CUSTOM_DTS_PATH)/.*),)
>
> You don't actually need the * here.
>
> Also, better use positive logic (ifeq instead of ifneq, and swap the branches).
>
> > +LINUX_DTS_NAME += $(addprefix $(notdir $(LINUX_KERNEL_CUSTOM_DTS_PATH))/,$(basename $(filter %.dts,$(notdir $(wildcard $(LINUX_KERNEL_CUSTOM_DTS_PATH)/*)))))
> > +else
> > +LINUX_DTS_NAME += $(basename $(filter %.dts,$(notdir $(wildcard $(LINUX_KERNEL_CUSTOM_DTS_PATH)))))
>
> This is also getting pretty complicated, could it be refactored so there are a
> bit more common parts? Something like:
>
> ifeq ($(wildcard $(LINUX_KERNEL_CUSTOM_DTS_PATH)/.),)
> LINUX_CUSTOM_DTS_FILES = $(wildcard $(LINUX_KERNEL_CUSTOM_DTS_PATH)/*))
> LINUX_CUSTOM_DTS_PREFIX = $(notdir $(LINUX_KERNEL_CUSTOM_DTS_PATH))/
> else
> LINUX_CUSTOM_DTS_FILES = $(LINUX_KERNEL_CUSTOM_DTS_PATH)
> endif
> LINUX_DTS_NAME += $(addprefix $(LINUX_CUSTOM_DTS_PREFIX),$(basename $(filter
> %.dts,$(LINUX_CUSTOM_DTS_FILES))))
>
> (parenthesis added in an email editor so probably unbalanced :-)
>
> Regards,
> Arnout
>
> > +endif
> >
> > LINUX_DTBS = $(addsuffix .dtb,$(LINUX_DTS_NAME))
> >
> > @@ -505,8 +513,8 @@ endif
> > # http://lists.busybox.net/pipermail/buildroot/2020-May/282727.html
> > define LINUX_BUILD_CMDS
> > $(call KCONFIG_DISABLE_OPT,CONFIG_GCC_PLUGINS)
> > - $(foreach dts,$(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH)), \
> > - cp -f $(dts) $(LINUX_ARCH_PATH)/boot/dts/
> > + $(foreach dts,$(LINUX_KERNEL_CUSTOM_DTS_PATH), \
> > + cp -rf $(dts) $(LINUX_ARCH_PATH)/boot/dts/
> > )
> > $(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) all
> > $(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_TARGET_NAME)
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Buildroot] [PATCH] linux: Add support for vendor directory in BR2_LINUX_KERNEL_CUSTOM_DTS_PATH
2024-07-15 15:22 ` Brandon Maier via buildroot
@ 2025-02-20 13:53 ` Matthew Weber
2025-02-20 14:10 ` Niklas Cassel via buildroot
0 siblings, 1 reply; 5+ messages in thread
From: Matthew Weber @ 2025-02-20 13:53 UTC (permalink / raw)
To: Brandon Maier; +Cc: Kory Maincent, thomas.petazzoni, buildroot
Hi Kory,
On Mon, Jul 15, 2024 at 10:23 AM Brandon Maier via buildroot
<buildroot@buildroot.org> wrote:
>
> Hi Arnout, Kory,
>
> On Mon Jul 15, 2024 at 2:07 PM UTC, Arnout Vandecappelle via buildroot wrote:
> >
> >
> > On 10/07/2024 17:29, Kory Maincent via buildroot wrote:
> > > Linux organizes devicetree files under vendor subdirectories for arm and
> > > arm64 architectures, such as arch/<arch>/boot/dts/<vendor>/. The
> > > BR2_LINUX_KERNEL_CUSTOM_DTS_PATH was only copying devicetree files to
> > > arch/<arch>/boot/dts/, which is incompatible with the vendor
> > > subdirectory structure.
> >
[snip]
Which kernel version were you using? I noticed in 6.12 when I use the
BR2_LINUX_KERNEL_CUSTOM_DTS_PATH, I get a "no make target for" error
trying to build that dtb once placed in the root of
arch/<arch>/boot/dts/. The file is there and if I move it into the
vendor folder and update Buildroot to build it as a in-tree dts, it
works OK.
Wanted to check if this is a known issue before sharing a basic
example to reproduce.
Regards,
Matt
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Buildroot] [PATCH] linux: Add support for vendor directory in BR2_LINUX_KERNEL_CUSTOM_DTS_PATH
2025-02-20 13:53 ` Matthew Weber
@ 2025-02-20 14:10 ` Niklas Cassel via buildroot
0 siblings, 0 replies; 5+ messages in thread
From: Niklas Cassel via buildroot @ 2025-02-20 14:10 UTC (permalink / raw)
To: Matthew Weber
Cc: Brandon Maier, Kory Maincent, thomas.petazzoni@bootlin.com,
buildroot@buildroot.org, Romain Naour
Hello Matthew,
On Thu, Feb 20, 2025 at 07:53:25AM -0600, Matthew Weber wrote:
> Hi Kory,
>
>
> On Mon, Jul 15, 2024 at 10:23 AM Brandon Maier via buildroot
> <buildroot@buildroot.org> wrote:
> >
> > Hi Arnout, Kory,
> >
> > On Mon Jul 15, 2024 at 2:07 PM UTC, Arnout Vandecappelle via buildroot wrote:
> > >
> > >
> > > On 10/07/2024 17:29, Kory Maincent via buildroot wrote:
> > > > Linux organizes devicetree files under vendor subdirectories for arm and
> > > > arm64 architectures, such as arch/<arch>/boot/dts/<vendor>/. The
> > > > BR2_LINUX_KERNEL_CUSTOM_DTS_PATH was only copying devicetree files to
> > > > arch/<arch>/boot/dts/, which is incompatible with the vendor
> > > > subdirectory structure.
> > >
> [snip]
>
> Which kernel version were you using? I noticed in 6.12 when I use the
> BR2_LINUX_KERNEL_CUSTOM_DTS_PATH, I get a "no make target for" error
> trying to build that dtb once placed in the root of
> arch/<arch>/boot/dts/. The file is there and if I move it into the
> vendor folder and update Buildroot to build it as a in-tree dts, it
> works OK.
>
> Wanted to check if this is a known issue before sharing a basic
> example to reproduce.
Please have a look at:
https://lore.kernel.org/buildroot/20250204163622.192932-1-romain.naour@smile.fr/T/#me44dcc9853e35589a0a64ab20fc75f038641a49a
Kind regards,
Niklas
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-02-20 14:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-10 15:29 [Buildroot] [PATCH] linux: Add support for vendor directory in BR2_LINUX_KERNEL_CUSTOM_DTS_PATH Kory Maincent via buildroot
2024-07-15 14:07 ` Arnout Vandecappelle via buildroot
2024-07-15 15:22 ` Brandon Maier via buildroot
2025-02-20 13:53 ` Matthew Weber
2025-02-20 14:10 ` Niklas Cassel via buildroot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox