From patchwork Tue Jan 9 12:07:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 186346 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp61552dyi; Tue, 9 Jan 2024 04:09:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IFag1z7Erw4BHsZLlfIv0MAb3XleXzntlfLhAiaU1Xb8hsqABinrWDBPxgkcEOiWKXRoYcy X-Received: by 2002:a17:906:2210:b0:a26:88f4:3fae with SMTP id s16-20020a170906221000b00a2688f43faemr485643ejs.67.1704802157798; Tue, 09 Jan 2024 04:09:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704802157; cv=none; d=google.com; s=arc-20160816; b=vngm576V9YGjVjOR24k/Q4hEQghsbwtLxYlTj5WmLpHbey7asynnEFieStUuWa0EVM qktt1Xi229GbyJ6QmghIcIfNHeo6PJ5LjOOi2UlTWe81d9ArgcWhld87Vfav+iSByUBh nczOwsn5J4zm57wcEG3kAFDCjt2nefj2qpr14oyrR5rWIcMEtpUORFxwGUgLQ10IGYv9 U3wM5VwoFu1syhNF/AtEHM7V1BBS3UlDvq70PO5N+9iFzcu5aO5Ac6oUmBfd92V9vixr hPJRyZnCDCxgSrKfMjPgFYi6LVXZoC101o10I6rzDq9ehS5+Ot0GVqMhUpdoLJh0n63U v+eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=jrLMKyPdWzAIC82IXhX2YBCqjy1u/aoe1zR03QnkLBY=; fh=aN2kD2oByOQCLFiYXd7TyKLQSQPEZSL4i6gciY+4Zlg=; b=EZiS8mCm/BUgXyKFd5TdK/pceRRtNYN7/f8sXRwSGDp6hKn+LysZemoWJc4bH1YPuA sVjYQpCngCJyTJKYj0rBdlnbtxhjhYww8SMGtlJtHd/KdRHVtjMAHLAwpolxvDS+TOzR u9W5xv2ZV+uC3lsez4MiSQ5p14z39weTrIbF6O0ewXsA8U5JKwnCCoR5DRN4HIZ5hoP+ J+Btu+jg4cLBsKw/Np6mQE70dEw2Z18q5oCPHkvmpd8On+HAZY6AkcyiY6eZWVlzREc3 MpTMGkpEo034Ke7SwyXWqr/kTrDkOQizr3bx8kmInD1AIqZkEL7sJCTb6FOGMXcxFZSp 8Tfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="DbvvzB/W"; spf=pass (google.com: domain of linux-kernel+bounces-20830-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20830-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s21-20020a170906169500b00a27dcb8c6casi753111ejd.878.2024.01.09.04.09.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 04:09:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20830-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="DbvvzB/W"; spf=pass (google.com: domain of linux-kernel+bounces-20830-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20830-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 69F641F2595D for ; Tue, 9 Jan 2024 12:09:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 55D3F39859; Tue, 9 Jan 2024 12:07:58 +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: 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) 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787614627286348181 X-GMAIL-MSGID: 1787614627286348181 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 --- 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