Hi Masahiro, On Fri, 1 Dec 2023 at 10:30, Masahiro Yamada <masahiroy@xxxxxxxxxx> wrote: > > On Fri, Dec 1, 2023 at 5:34 AM Simon Glass <sjg@xxxxxxxxxxxx> wrote: > > > > 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. Supported > > compression options are the same as the Image.xxx files. For now there > > is no way to change the compression other than by editing the rule for > > $(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 <sjg@xxxxxxxxxxxx> > > --- > > > > 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 '$(<D)/dts' instead of '$(dir $<)dts' > > - 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 usage > > - 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/process/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-build --version > > cpio any cpio --version > > GNU tar 1.28 tar --version > > gtags (optional) 6.6.5 gtags --version > > +mkimage (optional) 2017.01 mkimage --version > > ====================== =============== ======================================== > > > > .. [#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 gtags > > ``-C (--directory)`` flag. > > > > +mkimage > > +------- > > + > > +This tool is used when building a Flat Image Tree (FIT), commonly used 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-for-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 <sjg@xxxxxxxxxxxx> > > +L: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx (moderated for non-subscribers) > > +S: Maintained > > +F: arch/arm64/boot/Makefile > > +F: scripts/make_fit.py > > + > > ARM64 PORT (AARCH64 ARCHITECTURE) > > M: Catalin Marinas <catalin.marinas@xxxxxxx> > > M: Will Deacon <will@xxxxxxxxxx> > > 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) += $(objtree)/drivers/firmware/efi/libstub/lib.a > > # Default target when executing plain make > > boot := arch/arm64/boot > > > > -BOOT_TARGETS := Image vmlinuz.efi > > +BOOT_TARGETS := Image vmlinuz.efi image.fit > > > > PHONY += $(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)=$(boot) $(boot)/$@ > > > > @@ -215,6 +217,7 @@ virtconfig: > > define archhelp > > echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)' > > echo ' Image - Uncompressed kernel image (arch/$(ARCH)/boot/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 :=-O binary -R .note -R .note.gnu.build-id -R .comment -S > > > > -targets := Image Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo Image.zst > > +targets := 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 ?= 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 = $(MAKE_FIT) -f $@ --arch $(UIMAGE_ARCH) --os linux \ > --name '$(UIMAGE_NAME)' \ > --compress $(UIMAGE_COMPRESSION) -k $< \ > $(<D)/dts > > > 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, for example: ARCH=arm64 CROSS_COMPILE=... make FIT_COMPRESS=lzma image.fit I do want to support different algorithms, if possible. Is there a better way to do this? Regards, Simon