[PATCH] scripts/Makefile.lib: also consider $(CONFIG_SYS_BOARD)-u-boot.dtsi

Rasmus Villemoes rasmus.villemoes at prevas.dk
Fri Mar 17 11:26:39 CET 2023


I have a couple of boards, e.g. foo21, bar33, each with a few
different revisions, so I have

  foo21-revA.dts
  foo21-revB.dts
  bar33-revA.dts
  bar33-revB.dts

Now the necessary U-Boot specific additions for the foo21 boards
doesn't depend on the revision (likely for bar33), so I just want to
have and maintain one

  foo21-u-boot.dtsi

But currently I need to add dummy files foo21-revA-u-boot.dtsi and
foo21-revB-u-boot.dtsi each just containing '#include
foo21-u-boot.dtsi'. And similarly for bar33, and all those files
become quite unwieldy as more revisions need to be supported.

It's quite natural to look for a file named after CONFIG_SYS_BOARD,
with lower precedence of course than a -u-boot.dtsi file with the same
basename as the .dts, but higher than CONFIG_SYS_SOC.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes at prevas.dk>
---

Of course, this can cause unwanted changes for existing boards. But a
bit of ad hoc scripting shows that the risk is low: I first grabbed
all 'default "foo"' stanzas of all 'config SYS_BOARD' instances, as
well as all values of CONFIG_SYS_BOARD set in *_defconfig files. Then
I made a list of all existing *-u-boot.dtsi files, and from these
removed any where there is a corresponding .dts file. That leaves just

imx6ul
imx8mm
mt7620
mt7621
mt7622
mt7623
mt7628
mt8516
socfpga_arria10
sunxi

and inspecting a few of those suggests that they set SYS_SOC to the
same as SYS_BOARD, i.e. they were already picking up the .dtsi file
due to the SYS_SOC rule.

Now, the only way to be really sure is to build the world
with/without this patch and check if any .dtb file changes, but I
don't have the means to do that. But I do notice that 


 doc/develop/devicetree/control.rst | 1 +
 scripts/Makefile.lib               | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/doc/develop/devicetree/control.rst b/doc/develop/devicetree/control.rst
index c71570d64b..831d225fb1 100644
--- a/doc/develop/devicetree/control.rst
+++ b/doc/develop/devicetree/control.rst
@@ -174,6 +174,7 @@ devicetree for your board, searching for them in the same directory as the
 main file, in this order::
 
    <orig_filename>-u-boot.dtsi
+   <CONFIG_SYS_BOARD>-u-boot.dtsi
    <CONFIG_SYS_SOC>-u-boot.dtsi
    <CONFIG_SYS_CPU>-u-boot.dtsi
    <CONFIG_SYS_VENDOR>-u-boot.dtsi
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index ecc15041ee..69f4d560d1 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -160,6 +160,7 @@ ld_flags       = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F))
 
 # Try these files in order to find the U-Boot-specific .dtsi include file
 u_boot_dtsi_options = $(strip $(wildcard $(dir $<)$(basename $(notdir $<))-u-boot.dtsi) \
+	$(wildcard $(dir $<)$(subst $\",,$(CONFIG_SYS_BOARD))-u-boot.dtsi) \
 	$(wildcard $(dir $<)$(subst $\",,$(CONFIG_SYS_SOC))-u-boot.dtsi) \
 	$(wildcard $(dir $<)$(subst $\",,$(CONFIG_SYS_CPU))-u-boot.dtsi) \
 	$(wildcard $(dir $<)$(subst $\",,$(CONFIG_SYS_VENDOR))-u-boot.dtsi) \
@@ -167,6 +168,7 @@ u_boot_dtsi_options = $(strip $(wildcard $(dir $<)$(basename $(notdir $<))-u-boo
 
 u_boot_dtsi_options_raw = $(warning Automatic .dtsi inclusion: options: \
 	$(dir $<)$(basename $(notdir $<))-u-boot.dtsi \
+	$(dir $<)$(subst $\",,$(CONFIG_SYS_BOARD))-u-boot.dtsi \
 	$(dir $<)$(subst $\",,$(CONFIG_SYS_SOC))-u-boot.dtsi \
 	$(dir $<)$(subst $\",,$(CONFIG_SYS_CPU))-u-boot.dtsi \
 	$(dir $<)$(subst $\",,$(CONFIG_SYS_VENDOR))-u-boot.dtsi \
-- 
2.37.2



More information about the U-Boot mailing list