All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: devicetree@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
	Simon Glass <sjg@chromium.org>,
	Masahiro Yamada <masahiroy@kernel.org>,
	Jonathan Corbet <corbet@lwn.net>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Nicolas Schier <nicolas@fjasle.eu>,
	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	[thread overview]
Message-ID: <20240109120738.346061-5-masahiroy@kernel.org> (raw)
In-Reply-To: <20240109120738.346061-1-masahiroy@kernel.org>

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 := foo_base.dtb foo_overlay1.dtbo
    foo2-dtbs := foo_base.dtb foo_overlay2.dtbo
    dtb-y := 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=1, '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 <masahiroy@kernel.org>
---

 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 tree blobs for
 relocations required by build roots.  This is not defined in the
 makefile but the argument can be passed to make if needed.
 
+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 instance,
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 = INSTALL $@
 $(dst)/%: $(obj)/%
 	$(call cmd,dtb_install)
 
-dtbs := $(patsubst $(obj)/%,%,$(call read-file, $(obj)/dtbs-list))
+dtbs := $(call read-file, $(obj)/dtbs-list)
+
+ifdef INSTALL_DTBS_PRIMITIVE
+dtbs := $(foreach f, $(dtbs), $(if $(filter %.dtb,$(f)),$(call read-file, $(patsubst %.dtb,%.dtlst,$(f))),$(f)))
+endif
+
+dtbs := $(patsubst $(obj)/%,%,$(dtbs))
 
 ifdef CONFIG_ARCH_WANT_FLAT_DTB_INSTALL
 
-- 
2.40.1


  parent reply	other threads:[~2024-01-09 12:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-09 12:07 [PATCH 0/4] kbuild: create a list of DTBs and allow to install base dtb and overlays Masahiro Yamada
2024-01-09 12:07 ` [PATCH 1/4] kbuild: create a list of all built DTB files Masahiro Yamada
2024-01-09 14:22   ` Masahiro Yamada
2024-01-09 12:07 ` [PATCH 2/4] kbuild: simplify dtbs_install by reading the list of compiled DTBs Masahiro Yamada
2024-01-17 14:52   ` Rob Herring
2024-01-19  5:30     ` Masahiro Yamada
2024-01-09 12:07 ` [PATCH 3/4] kbuild: create a list of base and overlays for each DTB Masahiro Yamada
2024-01-09 12:07 ` Masahiro Yamada [this message]
2024-01-17 15:37   ` [PATCH 4/4] kbuild: allow 'make dtbs_install' to install primitive DTBs Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240109120738.346061-5-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nicolas@fjasle.eu \
    --cc=robh+dt@kernel.org \
    --cc=sjg@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.