From nobody Fri Dec 19 21:47:31 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1CCF381AE; Tue, 9 Jan 2024 12:07:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XwGYdl4H" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1249C43399; Tue, 9 Jan 2024 12:07:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704802069; bh=uYa16IEEJlpGSqmjAAvT3Wz06Y8oSxPf78zrq9xQRVg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XwGYdl4HWKvN8WrzDx3lBhxVXf5qH1spEwHoYUj3ccjxwKAV4WRIaPZKTIEGC2wyy QBsnfn0mZjYKOy+WL31y6zNIxrxOPiGKjsQtnwUudrcEATTDC72xsiHaVlGCv8FXuM biu2JsE7ln2jHOP8ca15tQ2fOUB6ap3eEWgPsMOP1VAME1vDgwZ4QDkaj2QbJFj1PW 8sEkFEsJmelRjvGYA0SETCicU4kAi492LCdA5i2WoH5jkLXdyklKEFXSGkVWU/7JDb 7bGoqfOibgebZ4Y0gfWYGtehPlFBZt0ohiA5URPt6vII3IpyGpSJG71a6Ws47cPEn2 SgT4OAuQ+IxDg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: devicetree@vger.kernel.org, Rob Herring , Simon Glass , Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , linux-kernel@vger.kernel.org Subject: [PATCH 1/4] kbuild: create a list of all built DTB files Date: Tue, 9 Jan 2024 21:07:34 +0900 Message-Id: <20240109120738.346061-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240109120738.346061-1-masahiroy@kernel.org> References: <20240109120738.346061-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It is useful to have a list of all *.dtb and *.dtbo files generated from the current build. With this commit, 'make dtbs' creates arch/*/boot/dts/dtbs-order, which lists the dtb(o) files created in the current build. It maintains the order of the dtb-y additions in Makefiles although the order is not important for DTBs. It is a (good) side effect through the reuse of the modules.order rule. Please note this list only includes the files directly added to dtb-y. For example, consider this case: foo-dtbs :=3D foo_base.dtb foo_overlay.dtbo dtb-y :=3D foo.dtb In this example, the list will include foo.dtb, but not foo_base.dtb or foo_overlay.dtbo. Signed-off-by: Masahiro Yamada --- .gitignore | 1 + Makefile | 4 ++-- scripts/Makefile.build | 20 ++++++++++++-------- scripts/Makefile.lib | 6 ++++++ 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 689a4fa3f547..c59dc60ba62e 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,7 @@ *.xz *.zst Module.symvers +dtbs-list modules.order =20 # diff --git a/Makefile b/Makefile index 6204a3803a90..db7f9e34a24e 100644 --- a/Makefile +++ b/Makefile @@ -1389,7 +1389,7 @@ ifneq ($(dtstree),) =20 PHONY +=3D dtbs dtbs_prepare dtbs_install dtbs_check dtbs: dtbs_prepare - $(Q)$(MAKE) $(build)=3D$(dtstree) + $(Q)$(MAKE) $(build)=3D$(dtstree) need-dtbslist=3D1 =20 # include/config/kernel.release is actually needed when installing DTBs be= cause # INSTALL_DTBS_PATH contains $(KERNELRELEASE). However, we do not want to = make @@ -1927,7 +1927,7 @@ clean: $(clean-dirs) -o -name '*.ko.*' \ -o -name '*.dtb' -o -name '*.dtbo' \ -o -name '*.dtb.S' -o -name '*.dtbo.S' \ - -o -name '*.dt.yaml' \ + -o -name '*.dt.yaml' -o -name 'dtbs-list' \ -o -name '*.dwo' -o -name '*.lst' \ -o -name '*.su' -o -name '*.mod' \ -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 9a3063735e71..d23797dbca0f 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -71,6 +71,7 @@ endif # subdir-builtin and subdir-modorder may contain duplications. Use $(sort = ...) subdir-builtin :=3D $(sort $(filter %/built-in.a, $(real-obj-y))) subdir-modorder :=3D $(sort $(filter %/modules.order, $(obj-m))) +subdir-dtbslist :=3D $(sort $(filter %/dtbs-list, $(dtb-y))) =20 targets-for-builtin :=3D $(extra-y) =20 @@ -387,6 +388,7 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtre= e)/scripts/asn1_compiler # To build objects in subdirs, we need to descend into the directories $(subdir-builtin): $(obj)/%/built-in.a: $(obj)/% ; $(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ; +$(subdir-dtbslist): $(obj)/%/dtbs-list: $(obj)/% ; =20 # # Rule to compile a set of .o files into one .a file (without symbol table) @@ -403,19 +405,21 @@ $(obj)/built-in.a: $(real-obj-y) FORCE $(call if_changed,ar_builtin) =20 # -# Rule to create modules.order file +# Rule to create modules.order and dtbs-list # -# Create commands to either record .ko file or cat modules.order from -# a subdirectory -# Add $(obj-m) as the prerequisite to avoid updating the timestamp of -# modules.order unless contained modules are updated. +# This is a list of build artifacts (module or dtb) from the current Makef= ile +# and its sub-directories. The timestamp should be updated when any of the +# member files. =20 -cmd_modules_order =3D { $(foreach m, $(real-prereqs), \ - $(if $(filter %/modules.order, $m), cat $m, echo $m);) :; } \ +cmd_gen_order =3D { $(foreach m, $(real-prereqs), \ + $(if $(filter %/$(notdir $@), $m), cat $m, echo $m);) :; } \ > $@ =20 $(obj)/modules.order: $(obj-m) FORCE - $(call if_changed,modules_order) + $(call if_changed,gen_order) + +$(obj)/dtbs-list: $(dtb-y) FORCE + $(call if_changed,gen_order) =20 # # Rule to compile a set of .o files into one .a file (with symbol table) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index cd5b181060f1..b35d39022a30 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -45,6 +45,11 @@ else obj-y :=3D $(filter-out %/, $(obj-y)) endif =20 +ifdef need-dtbslist +dtb-y +=3D $(addsuffix /dtbs-list, $(subdir-ym)) +always-y +=3D dtbs-list +endif + # Expand $(foo-objs) $(foo-y) etc. by replacing their individuals suffix-search =3D $(strip $(foreach s, $3, $($(1:%$(strip $2)=3D%$s)))) # List composite targets that are constructed by combining other targets @@ -99,6 +104,7 @@ lib-y :=3D $(addprefix $(obj)/,$(lib-y)) real-obj-y :=3D $(addprefix $(obj)/,$(real-obj-y)) real-obj-m :=3D $(addprefix $(obj)/,$(real-obj-m)) multi-obj-m :=3D $(addprefix $(obj)/, $(multi-obj-m)) +dtb-y :=3D $(addprefix $(obj)/, $(dtb-y)) multi-dtb-y :=3D $(addprefix $(obj)/, $(multi-dtb-y)) real-dtb-y :=3D $(addprefix $(obj)/, $(real-dtb-y)) subdir-ym :=3D $(addprefix $(obj)/,$(subdir-ym)) --=20 2.40.1 From nobody Fri Dec 19 21:47:31 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 559C5381A2; Tue, 9 Jan 2024 12:07:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JZhQQiq1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1A43C43390; Tue, 9 Jan 2024 12:07:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704802071; bh=0i7egdX2nZv01YOBcXbZOK2my3bgeNy9DuIuiyc852c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JZhQQiq16hZd3VAds5HeEend/8zOji+3Gy2B7/Z153/q/SYl++wP8N2JJe3yotR6j HCmmjQoUyKBXQkp0JfNUyJ+GBoH5l3unv7bPQgNYngXx4xzLkFnz4iDgBtIVt2d7wi 3CY/3m9IJ5uRNQe7QN8VaGs6UWL+uXn1F5TL/VB3p13Tnz/RpQmEyPn0bz0qo7KudX cWMaexrdMZNFdjWCRtBRu4SOKukeZ2dMddOSB5z1wdEXOgxdjYR9frnhfHm5rjyBwd LiZKQ35fZ0RDfg2OHvoxUSzZZENM1c0N9yxTdr6Y2ERIPuugu4Yi/zbzcuX0s00b09 e5/pRgqlLb+LA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: devicetree@vger.kernel.org, Rob Herring , Simon Glass , Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , linux-kernel@vger.kernel.org Subject: [PATCH 2/4] kbuild: simplify dtbs_install by reading the list of compiled DTBs Date: Tue, 9 Jan 2024 21:07:35 +0900 Message-Id: <20240109120738.346061-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240109120738.346061-1-masahiroy@kernel.org> References: <20240109120738.346061-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Retrieve the list of *.dtb(o) files from arch/*/boot/dts/dtbs-list instead of traversing the directory tree again. Please note that 'make dtbs_install' installs *.dtb(o) files directly added to dtb-y because scripts/Makefile.dtbinst installs $(dtb-y) without expanding the -dtbs suffix. This commit preserves this behavior. Signed-off-by: Masahiro Yamada --- Makefile | 2 +- scripts/Kbuild.include | 6 ------ scripts/Makefile.dtbinst | 32 ++++++++++++++++++-------------- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index db7f9e34a24e..dae6825b8082 100644 --- a/Makefile +++ b/Makefile @@ -1407,7 +1407,7 @@ endif dtbs_check: dtbs =20 dtbs_install: - $(Q)$(MAKE) $(dtbinst)=3D$(dtstree) dst=3D$(INSTALL_DTBS_PATH) + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.dtbinst obj=3D$(dtstree) =20 ifdef CONFIG_OF_EARLY_FLATTREE all: dtbs diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 7778cc97a4e0..2f331879816b 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -113,12 +113,6 @@ endef # $(Q)$(MAKE) $(build)=3Ddir build :=3D -f $(srctree)/scripts/Makefile.build obj =20 -### -# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.dtbinst obj=3D -# Usage: -# $(Q)$(MAKE) $(dtbinst)=3Ddir -dtbinst :=3D -f $(srctree)/scripts/Makefile.dtbinst obj - ### # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=3D # Usage: diff --git a/scripts/Makefile.dtbinst b/scripts/Makefile.dtbinst index 4405d5b67578..67956f6496a5 100644 --- a/scripts/Makefile.dtbinst +++ b/scripts/Makefile.dtbinst @@ -8,32 +8,36 @@ # $INSTALL_PATH/dtbs/$KERNELRELEASE # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 -src :=3D $(obj) - PHONY :=3D __dtbs_install __dtbs_install: =20 include include/config/auto.conf include $(srctree)/scripts/Kbuild.include -include $(kbuild-file) =20 -dtbs :=3D $(addprefix $(dst)/, $(dtb-y) $(if $(CONFIG_OF_ALL_DTBS),$(dt= b-))) -subdirs :=3D $(addprefix $(obj)/, $(subdir-y) $(subdir-m)) - -__dtbs_install: $(dtbs) $(subdirs) - @: +dst :=3D $(INSTALL_DTBS_PATH) =20 quiet_cmd_dtb_install =3D INSTALL $@ cmd_dtb_install =3D install -D $< $@ =20 -$(dst)/%.dtb: $(obj)/%.dtb +$(dst)/%: $(obj)/% $(call cmd,dtb_install) =20 -$(dst)/%.dtbo: $(obj)/%.dtbo - $(call cmd,dtb_install) +dtbs :=3D $(patsubst $(obj)/%,%,$(call read-file, $(obj)/dtbs-list)) =20 -PHONY +=3D $(subdirs) -$(subdirs): - $(Q)$(MAKE) $(dtbinst)=3D$@ dst=3D$(if $(CONFIG_ARCH_WANT_FLAT_DTB_INSTAL= L),$(dst),$(patsubst $(obj)/%,$(dst)/%,$@)) +ifdef CONFIG_ARCH_WANT_FLAT_DTB_INSTALL + +define gen_install_rules +$(dst)/%: $(obj)/$(1)% + $$(call cmd,dtb_install) +endef + +$(foreach d, $(sort $(dir $(dtbs))), $(eval $(call gen_install_rules,$(d))= )) + +dtbs :=3D $(notdir $(dtbs)) + +endif # CONFIG_ARCH_WANT_FLAT_DTB_INSTALL + +__dtbs_install: $(addprefix $(dst)/, $(dtbs)) + @: =20 .PHONY: $(PHONY) --=20 2.40.1 From nobody Fri Dec 19 21:47:31 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0D9638DFC; Tue, 9 Jan 2024 12:07:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rzw3zg6J" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90B53C433C7; Tue, 9 Jan 2024 12:07:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704802073; bh=yYqdl2V/WrEu6szOfBy/qaZwIUQ0XEnoi+ITcWxYigI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rzw3zg6JH75t7XiuBwPmn0OJf24D9UAvjZC8JDmGcEL8BaHSamz0VfM5IXu3vo+A/ J+E9jdR5QV/nlNq+setc8BpW/3gYxYB8be0V9D1VTdkNa/8l+UQWYeEyAc9THl2CZr SGSo+zAQ/+2vs8mwCJHY+IhVvxUNPuiv9m8pzZA+d/YteiGqQCg8QAfg2x5v1PnRq7 IGquQr/f6QIxxHX/wtgkEl+c/ikLOen0zDaZWVWeffh2ngCF0jPrkb8+s1Sk08qkND 7h6EhuPww6H6f/1n+GvkwUV+vRhp4Wf7vUHdV4jHjjm4zJEg3ZqDjrZl9WVLVBxg4r Xl6Is/9SvBOfw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: devicetree@vger.kernel.org, Rob Herring , Simon Glass , Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , linux-kernel@vger.kernel.org Subject: [PATCH 3/4] kbuild: create a list of base and overlays for each DTB Date: Tue, 9 Jan 2024 21:07:36 +0900 Message-Id: <20240109120738.346061-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240109120738.346061-1-masahiroy@kernel.org> References: <20240109120738.346061-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Some *.dtb files are assembled from a base DTB and overlays, but once they are built, there is no way to propagate such information to succeeding processes. This commit introduces the generation of *.dtlst files, listing the component *.dtb(o) files that construct the corresponding *.dtb. This is analogous to *.mod, which lists component objects for each module. Signed-off-by: Masahiro Yamada --- .gitignore | 1 + Makefile | 2 +- scripts/Makefile.build | 6 ++++++ scripts/Makefile.lib | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c59dc60ba62e..912cb713ad74 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ *.dtbo *.dtb.S *.dtbo.S +*.dtlst *.dwo *.elf *.gcno diff --git a/Makefile b/Makefile index dae6825b8082..3521bdad6db7 100644 --- a/Makefile +++ b/Makefile @@ -1927,7 +1927,7 @@ clean: $(clean-dirs) -o -name '*.ko.*' \ -o -name '*.dtb' -o -name '*.dtbo' \ -o -name '*.dtb.S' -o -name '*.dtbo.S' \ - -o -name '*.dt.yaml' -o -name 'dtbs-list' \ + -o -name '*.dt.yaml' -o -name '*.dtlst' -o -name 'dtbs-list' \ -o -name '*.dwo' -o -name '*.lst' \ -o -name '*.su' -o -name '*.mod' \ -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ diff --git a/scripts/Makefile.build b/scripts/Makefile.build index d23797dbca0f..e9fcf330ff39 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -252,6 +252,12 @@ cmd_mod =3D printf '%s\n' $(call real-search, $*.o, .o= , -objs -y -m) | \ $(obj)/%.mod: FORCE $(call if_changed,mod) =20 +cmd_dt_list =3D printf '%s\n' $(call real-search, $*.dtb, .dtb, -dtbs) | \ + $(AWK) '!x[$$0]++ { print("$(obj)/"$$0) }' > $@ + +$(obj)/%.dtlst: FORCE + $(call if_changed,dt_list) + quiet_cmd_cc_lst_c =3D MKLST $@ cmd_cc_lst_c =3D $(CC) $(c_flags) -g -c -o $*.o $< && \ $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \ diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index b35d39022a30..0a492a4e4fbb 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -93,6 +93,8 @@ base-dtb-y :=3D $(filter %.dtb, $(call real-search, $(mul= ti-dtb-y), .dtb, -dtbs)) =20 always-y +=3D $(dtb-y) =20 +always-y +=3D $(patsubst %.dtb, %.dtlst, $(filter %.dtb, $(dtb-y))) + # Add subdir path =20 ifneq ($(obj),.) --=20 2.40.1 From nobody Fri Dec 19 21:47:31 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B472038FA6; Tue, 9 Jan 2024 12:07:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DbvvzB/W" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F25DC43394; Tue, 9 Jan 2024 12:07:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704802075; bh=MZbzN22IX64OiGkpAjMsQ5NKuAEc1kV5o4lDIUMEQFM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DbvvzB/WipWO1m+9QDyIUGPgsBhQaQ1OsuX1m2GRu7ZM0lKndEJKtlkRqgMAUWXzt TJzYLXMvrCV/MlTEnRvN7LZgbirbseq2QPuZLdVdI8QaxYiZMlL32KYZMT9+RA8dwC y3DBkqM7g21tzJd9wKKt6XYksspHLVzZm7FFPAh8jsLAMwGr6i+MHyT0Il4TI1ILj4 1S3xvWz50/z0zMl40PZYZoneUu81Zld07pTddyhS3fNtMw4y3DNm5m3nzVSkPac0VD xpwpPWUH05jChaK+RHn8VVB6JQiVF2gA44R5RhtsAm560gWml85FxDyhjngRMC//nF mrABK+fq+yCaw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: devicetree@vger.kernel.org, Rob Herring , Simon Glass , Masahiro Yamada , Jonathan Corbet , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] kbuild: allow 'make dtbs_install' to install primitive DTBs Date: Tue, 9 Jan 2024 21:07:37 +0900 Message-Id: <20240109120738.346061-5-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240109120738.346061-1-masahiroy@kernel.org> References: <20240109120738.346061-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Commit 15d16d6dadf6 ("kbuild: Add generic rule to apply fdtoverlay") introduced the -dtbs syntax to apply overlays during the build process. However, scripts/Makefile.dtbinst is not aware of the -dtbs syntax, so 'make dtbs_install' installs the files directly added to dtb-y. (Presumably, it was intentional.) For example, consider this case: foo1-dtbs :=3D foo_base.dtb foo_overlay1.dtbo foo2-dtbs :=3D foo_base.dtb foo_overlay2.dtbo dtb-y :=3D foo1.dtb foo2.dtb 'make dtbs_install' only installs foo1.dtb and foo2.dtb. It is suitable when the boot image supports a single hardware configuration, or when the boot loader in use does not support applying overlays. However, when creating a boot image with multiple board supports, it wastes storage space, as foo1.dtb and foo2.dtb have foo_base.dtb in common. From a space perspective, a more optimal solution is to install foo_base.dtb, foo_overlay1.dtbo, and foo_overlay2.dtbo, then assemble the final dtb (either foo1.dtb or foo2.dtb) on the boot loader. This commit adds a new flag, INSTALL_DTBS_PRIMITIVE. With INSTALL_DTBS_PRIMITIVE=3D1, 'make dtbs_install' will install primitive files (such as foo_base.dtb, foo_overlay1.dtbo, and foo_overlay2.dtbo in this case). Without INSTALL_DTBS_PRIMITIVE, the current behavior is maintained (foo1.dtb and foo2.dtb will be installed in this case). Signed-off-by: Masahiro Yamada --- Documentation/kbuild/kbuild.rst | 6 ++++++ scripts/Makefile.dtbinst | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Documentation/kbuild/kbuild.rst b/Documentation/kbuild/kbuild.= rst index 9c8d1d046ea5..d803ca5afc07 100644 --- a/Documentation/kbuild/kbuild.rst +++ b/Documentation/kbuild/kbuild.rst @@ -249,6 +249,12 @@ INSTALL_DTBS_PATH specifies where to install device tr= ee blobs for relocations required by build roots. This is not defined in the makefile but the argument can be passed to make if needed. =20 +INSTALL_DTBS_PRIMITIVE +---------------------- +INSTALL_DTBS_PRIMITIVE, if defined, will cause the dtbs_install target to +install the base dtb and overlay dtbo files instead of assembled dtb files +constructed by overlay application. + KBUILD_ABS_SRCTREE -------------------------------------------------- Kbuild uses a relative path to point to the tree when possible. For instan= ce, diff --git a/scripts/Makefile.dtbinst b/scripts/Makefile.dtbinst index 67956f6496a5..14111a86987a 100644 --- a/scripts/Makefile.dtbinst +++ b/scripts/Makefile.dtbinst @@ -22,7 +22,13 @@ quiet_cmd_dtb_install =3D INSTALL $@ $(dst)/%: $(obj)/% $(call cmd,dtb_install) =20 -dtbs :=3D $(patsubst $(obj)/%,%,$(call read-file, $(obj)/dtbs-list)) +dtbs :=3D $(call read-file, $(obj)/dtbs-list) + +ifdef INSTALL_DTBS_PRIMITIVE +dtbs :=3D $(foreach f, $(dtbs), $(if $(filter %.dtb,$(f)),$(call read-file= , $(patsubst %.dtb,%.dtlst,$(f))),$(f))) +endif + +dtbs :=3D $(patsubst $(obj)/%,%,$(dtbs)) =20 ifdef CONFIG_ARCH_WANT_FLAT_DTB_INSTALL =20 --=20 2.40.1