Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1291546rdb; Fri, 1 Dec 2023 11:56:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IHc5+EUo1xmejC3iA3nt3JlVpelxrFIK/QIp4zrA5Xio96q2VTqw+1/UtFE/o5dDErBMezC X-Received: by 2002:a05:6a20:9191:b0:18f:97c:9271 with SMTP id v17-20020a056a20919100b0018f097c9271mr10139pzd.86.1701460619092; Fri, 01 Dec 2023 11:56:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701460619; cv=none; d=google.com; s=arc-20160816; b=GdU6rhEkcEWtHuwxC5xIqz2yPNc3eGB9A2v2h/qiLH57/d1qcSryWoa28pZteh3Vnt pqkINxprM4n3codINLKBfXL08AFys6cpOhjNQINTcbQ9pQjEuO5h3v5hA4EJ5GlzPTFt HcqUW/xjfErcupoeQq3fRzIWosBJ7pE9UJcWWO8QE88y/bJ2g6TLXI4usfvQKknSgbEY B9SuoQWavUtfPtaTiCBeKDL8IQwDEGVB/EYjm4mEYFMueONolkqv5eunOXRcFufGQufM 4VeyXSRPTKqaqoXHZzSlbS8ReufxNwFHVm5o50vlkpfOogixRxD2I7nO9J5wdB3Fccwo F8FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=KtgF8eQjWpc7Jxy3mp0Br7Cc682vMOYBTQz37CuxyzQ=; fh=Ug1zV6045jSy6KhwlPhT2tzCEE8gXxdxDklHVyqVjug=; b=YGxKQma5yJY7nIHx2J+ZPheiYobkhOK7+GCGjmmBkLVyTnDTTJfUtiq0McL5F1s4jw 9fi8++4GsM9pHIGSEXCVAIlyj4VlvkWxWuuL7+3PXabQ/2430pQXDPPBSobnUJqxHeQm BjJ+i6y4GhUSIOx6Fw4dqUclgsfGsl4ZgsRqw4fJ6Zf8yIutW2DoKZPbwq1R2VHTSLda b7SNjam0WXVAkBrPbohwV7YOROS0tCTZ2xNrjy1tf17GKZocRz29pFjgM33kgUztW8R0 T60dxrBG8SD7O1Yevna8azacYN/DxuaX8TArb7WvK1hN1vkM9lVAOZ3zo5U0sSwfRxBP otww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=caRls0Vf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id h189-20020a6383c6000000b005c5ffa76070si3735864pge.575.2023.12.01.11.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 11:56:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=caRls0Vf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id E58EA814971B; Fri, 1 Dec 2023 11:56:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379553AbjLAT4e (ORCPT + 99 others); Fri, 1 Dec 2023 14:56:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379538AbjLAT4e (ORCPT ); Fri, 1 Dec 2023 14:56:34 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7F67D54 for ; Fri, 1 Dec 2023 11:56:39 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DDDBC433AB; Fri, 1 Dec 2023 19:56:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701460599; bh=0ThhDO5PG85pESeX+R+vIkhc1OO1alRmntPC4vwJrwQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=caRls0VfeAJboUfPO/j6zPVwJRiI4YEdBp5stpJuT+MRlfDcao8Eecxb/cOMfqnqM Q8lZfpw1XVL/Vwqc7C4i8VAABmEs4mav54E8EHfji4jJv7vMuWoFgDTDhLVmuq3KUp rCdsTuTzULAohKVJFNvGpF3YuAdF8g8Y10vlnU/tn+lHHtvHrlkNAW7ZyTOC9Yp8qB SI+ONO65F++8n8PAwPGflPW564RaWl8MGzkKKThT7QeG8P4iW9tRiVW2MX4qYLZkei VxkiHbgOOrS2aLHR3uaGcjqEiwDj16Ogq1A9gZq/7t2Fg1fcK4hs4zRn/7vd51e5xZ nqcajGgEw4wTw== Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-6d817ccaa6dso584766a34.2; Fri, 01 Dec 2023 11:56:39 -0800 (PST) X-Gm-Message-State: AOJu0YyUfL5+WzHuxj8BME5b5IIK1DT9eGRrE94QjbS6K/PZ+d6n5szH VG5xSEJ4xU4a8huNy8tn/tcnOYM71jXt7n1nK/0= X-Received: by 2002:a05:6871:591:b0:1fa:f2a4:f3fa with SMTP id u17-20020a056871059100b001faf2a4f3famr95493oan.12.1701460598606; Fri, 01 Dec 2023 11:56:38 -0800 (PST) MIME-Version: 1.0 References: <20231130203358.879796-1-sjg@chromium.org> <20231130203358.879796-3-sjg@chromium.org> In-Reply-To: From: Masahiro Yamada Date: Sat, 2 Dec 2023 04:56:01 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v8 2/2] arm64: boot: Support Flat Image Tree To: Simon Glass Cc: linux-arm-kernel@lists.infradead.org, U-Boot Mailing List , lkml , Ahmad Fatoum , Nicolas Schier , Tom Rini , Catalin Marinas , Jonathan Corbet , Nathan Chancellor , Nick Terrell , Will Deacon , linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, workflows@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_PDS_OTHER_BAD_TLD,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 01 Dec 2023 11:56:56 -0800 (PST) On Sat, Dec 2, 2023 at 3:09=E2=80=AFAM Simon Glass wrote= : > > Hi Masahiro, > > On Fri, 1 Dec 2023 at 10:30, Masahiro Yamada wrote= : > > > > On Fri, Dec 1, 2023 at 5:34=E2=80=AFAM Simon Glass w= rote: > > > > > > Add a script which produces a Flat Image Tree (FIT), a single file > > > containing the built kernel and associated devicetree files. > > > Compression defaults to gzip which gives a good balance of size and > > > performance. > > > > > > The files compress from about 86MB to 24MB using this approach. > > > > > > The FIT can be used by bootloaders which support it, such as U-Boot > > > and Linuxboot. It permits automatic selection of the correct > > > devicetree, matching the compatible string of the running board with > > > the closest compatible string in the FIT. There is no need for > > > filenames or other workarounds. > > > > > > Add a 'make image.fit' build target for arm64, as well. > > > > > > The FIT can be examined using 'dumpimage -l'. > > > > > > This features requires pylibfdt (use 'pip install libfdt'). It also > > > requires compression utilities for the algorithm being used. Supporte= d > > > compression options are the same as the Image.xxx files. For now ther= e > > > is no way to change the compression other than by editing the rule fo= r > > > $(obj)/image.fit > > > > > > While FIT supports a ramdisk / initrd, no attempt is made to support > > > this here, since it must be built separately from the Linux build. > > > > > > Signed-off-by: Simon Glass > > > --- > > > > > > Changes in v8: > > > - Drop compatible string in FDT node > > > - Correct sorting of MAINTAINERS to before ARM64 PORT > > > - Turn compress part of the make_fit.py comment in to a sentence > > > - Add two blank lines before parse_args() and setup_fit() > > > - Use 'image.fit: dtbs' instead of BUILD_DTBS var > > > - Use '$( > > - Add 'mkimage' details Documentation/process/changes.rst > > > - Allow changing the compression used > > > - Tweak cover letter since there is only one clean-up patch > > > > > > Changes in v7: > > > - Add Image as a dependency of image.fit > > > - Drop kbuild tag > > > - Add dependency on dtbs > > > - Drop unnecessary path separator for dtbs > > > - Rebase to -next > > > > > > Changes in v5: > > > - Drop patch previously applied > > > - Correct compression rule which was broken in v4 > > > > > > Changes in v4: > > > - Use single quotes for UIMAGE_NAME > > > > > > Changes in v3: > > > - Drop temporary file image.itk > > > - Drop patch 'Use double quotes for image name' > > > - Drop double quotes in use of UIMAGE_NAME > > > - Drop unnecessary CONFIG_EFI_ZBOOT condition for help > > > - Avoid hard-coding "arm64" for the DT architecture > > > > > > Changes in v2: > > > - Drop patch previously applied > > > - Add .gitignore file > > > - Move fit rule to Makefile.lib using an intermediate file > > > - Drop dependency on CONFIG_EFI_ZBOOT > > > - Pick up .dtb files separately from the kernel > > > - Correct pylint too-many-args warning for write_kernel() > > > - Include the kernel image in the file count > > > - Add a pointer to the FIT spec and mention of its wide industry usag= e > > > - Mention the kernel version in the FIT description > > > > > > Documentation/process/changes.rst | 9 + > > > MAINTAINERS | 7 + > > > arch/arm64/Makefile | 7 +- > > > arch/arm64/boot/.gitignore | 1 + > > > arch/arm64/boot/Makefile | 9 +- > > > scripts/Makefile.lib | 13 ++ > > > scripts/make_fit.py | 291 ++++++++++++++++++++++++++++= ++ > > > 7 files changed, 334 insertions(+), 3 deletions(-) > > > create mode 100755 scripts/make_fit.py > > > > > > diff --git a/Documentation/process/changes.rst b/Documentation/proces= s/changes.rst > > > index bb96ca0f774b..cad51bd5bd62 100644 > > > --- a/Documentation/process/changes.rst > > > +++ b/Documentation/process/changes.rst > > > @@ -62,6 +62,7 @@ Sphinx\ [#f1]_ 1.7 sphinx-buil= d --version > > > cpio any cpio --version > > > GNU tar 1.28 tar --version > > > gtags (optional) 6.6.5 gtags --version > > > +mkimage (optional) 2017.01 mkimage --version > > > =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=3D=3D=3D > > > > > > .. [#f1] Sphinx is needed only to build the Kernel documentation > > > @@ -189,6 +190,14 @@ The kernel build requires GNU GLOBAL version 6.6= .5 or later to generate > > > tag files through ``make gtags``. This is due to its use of the gta= gs > > > ``-C (--directory)`` flag. > > > > > > +mkimage > > > +------- > > > + > > > +This tool is used when building a Flat Image Tree (FIT), commonly us= ed on ARM > > > +platforms. The tool is available via the ``u-boot-tools`` package or= can be > > > +built from the U-Boot source code. See the instructions at > > > +https://docs.u-boot.org/en/latest/build/tools.html#building-tools-fo= r-linux > > > + > > > System utilities > > > **************** > > > > > > diff --git a/MAINTAINERS b/MAINTAINERS > > > index 14587be87a33..9f3eb476ece4 100644 > > > --- a/MAINTAINERS > > > +++ b/MAINTAINERS > > > @@ -3037,6 +3037,13 @@ F: drivers/mmc/host/sdhci-of-arasan.c > > > N: zynq > > > N: xilinx > > > > > > +ARM64 FIT SUPPORT > > > +M: Simon Glass > > > +L: linux-arm-kernel@lists.infradead.org (moderated for non-subsc= ribers) > > > +S: Maintained > > > +F: arch/arm64/boot/Makefile > > > +F: scripts/make_fit.py > > > + > > > ARM64 PORT (AARCH64 ARCHITECTURE) > > > M: Catalin Marinas > > > M: Will Deacon > > > diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile > > > index 1bd4fae6e806..6b893dc454b7 100644 > > > --- a/arch/arm64/Makefile > > > +++ b/arch/arm64/Makefile > > > @@ -150,7 +150,7 @@ libs-$(CONFIG_EFI_STUB) +=3D $(objtree)/drivers/f= irmware/efi/libstub/lib.a > > > # Default target when executing plain make > > > boot :=3D arch/arm64/boot > > > > > > -BOOT_TARGETS :=3D Image vmlinuz.efi > > > +BOOT_TARGETS :=3D Image vmlinuz.efi image.fit > > > > > > PHONY +=3D $(BOOT_TARGETS) > > > > > > @@ -162,7 +162,9 @@ endif > > > > > > all: $(notdir $(KBUILD_IMAGE)) > > > > > > -vmlinuz.efi: Image > > > +image.fit: dtbs > > > + > > > +vmlinuz.efi image.fit: Image > > > $(BOOT_TARGETS): vmlinux > > > $(Q)$(MAKE) $(build)=3D$(boot) $(boot)/$@ > > > > > > @@ -215,6 +217,7 @@ virtconfig: > > > define archhelp > > > echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boo= t/Image.gz)' > > > echo ' Image - Uncompressed kernel image (arch/$(ARCH)/b= oot/Image)' > > > + echo ' image.fit - Flat Image Tree (arch/$(ARCH)/boot/image.= fit)' > > > echo ' install - Install uncompressed kernel' > > > echo ' zinstall - Install compressed kernel' > > > echo ' Install using (your) ~/bin/installkernel = or' > > > diff --git a/arch/arm64/boot/.gitignore b/arch/arm64/boot/.gitignore > > > index af5dc61f8b43..abaae9de1bdd 100644 > > > --- a/arch/arm64/boot/.gitignore > > > +++ b/arch/arm64/boot/.gitignore > > > @@ -2,3 +2,4 @@ > > > Image > > > Image.gz > > > vmlinuz* > > > +image.fit > > > diff --git a/arch/arm64/boot/Makefile b/arch/arm64/boot/Makefile > > > index 1761f5972443..62efb533a9bc 100644 > > > --- a/arch/arm64/boot/Makefile > > > +++ b/arch/arm64/boot/Makefile > > > @@ -16,7 +16,8 @@ > > > > > > OBJCOPYFLAGS_Image :=3D-O binary -R .note -R .note.gnu.build-id -R .= comment -S > > > > > > -targets :=3D Image Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo= Image.zst > > > +targets :=3D Image Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo= \ > > > + Image.zst image.fit > > > > > > $(obj)/Image: vmlinux FORCE > > > $(call if_changed,objcopy) > > > @@ -39,6 +40,12 @@ $(obj)/Image.lzo: $(obj)/Image FORCE > > > $(obj)/Image.zst: $(obj)/Image FORCE > > > $(call if_changed,zstd) > > > > > > +# Use this to override the compression algorithm > > > +FIT_COMPRESS ?=3D gzip > > > + > > > +$(obj)/image.fit: $(obj)/Image FORCE > > > + $(call cmd,fit,$(FIT_COMPRESS)) > > > > > > > > Again, $(FIT_COMPRESS) is not used anywhere. > > > > > > Please fix it to > > > > $(call cmd,fit) > > > > > > > > > > See your code. > > > > > > cmd_fit =3D $(MAKE_FIT) -f $@ --arch $(UIMAGE_ARCH) --os linux \ > > --name '$(UIMAGE_NAME)' \ > > --compress $(UIMAGE_COMPRESSION) -k $< \ > > $( > > > > > cmd_fit does not take any argument. > > > > > > The compression is determined by $(UIMAGE_COMPRESSION). > > This references argument 2, which is how it works. I have tested this, Hah, I missed it, sorry. You want to use gzip instead of none as the default compression for the fit image, right? If so, maybe, you can directly add FIT_COMPRESSION in scripts/Makefile.lib Users are still allowed to override it from an environment variable. FIT_COMPRESSION ?=3D gzip cmd_fit =3D $(MAKE_FIT) -f $@ --arch $(UIMAGE_ARCH) --os linux \ --name '$(UIMAGE_NAME)' \ --compress $(FIT_COMPRESSION) -k $< \ $( for example: > > ARCH=3Darm64 CROSS_COMPILE=3D... make FIT_COMPRESS=3Dlzma image.fit > > I do want to support different algorithms, if possible. Is there a > better way to do this? > > Regards, > Simon --=20 Best Regards Masahiro Yamada