Commit 7a23b027 authored by Simon Glass's avatar Simon Glass Committed by Will Deacon
Browse files

arm64: boot: Support Flat Image Tree



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 uses the 'dtbs-list' file but processes only .dtb files, ignoring
the overlay .dtbo files.

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. Use
FIT_COMPRESSION to select an algorithm other than gzip.

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: default avatarSimon Glass <sjg@chromium.org>
Acked-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
Link: https://lore.kernel.org/r/20240329032836.141899-3-sjg@chromium.org


Signed-off-by: default avatarWill Deacon <will@kernel.org>
parent 0dc1670b
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ Sphinx\ [#f1]_ 2.4.4 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
****************

+7 −0
Original line number Diff line number Diff line
@@ -3051,6 +3051,13 @@ F: drivers/mmc/host/sdhci-of-arasan.c
N:	zynq
N:	xilinx
ARM64 FIT SUPPORT
M:	Simon Glass <sjg@chromium.org>
L:	linux-arm-kernel@lists.infradead.org (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@arm.com>
M:	Will Deacon <will@kernel.org>
+5 −2
Original line number Diff line number Diff line
@@ -154,7 +154,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)

@@ -166,7 +166,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)/$@

@@ -219,6 +221,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'
+1 −0
Original line number Diff line number Diff line
@@ -2,3 +2,4 @@
Image
Image.gz
vmlinuz*
image.fit
+5 −1
Original line number Diff line number Diff line
@@ -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,9 @@ $(obj)/Image.lzo: $(obj)/Image FORCE
$(obj)/Image.zst: $(obj)/Image FORCE
	$(call if_changed,zstd)

$(obj)/image.fit: $(obj)/Image $(obj)/dts/dtbs-list FORCE
	$(call if_changed,fit)

EFI_ZBOOT_PAYLOAD	:= Image
EFI_ZBOOT_BFD_TARGET	:= elf64-littleaarch64
EFI_ZBOOT_MACH_TYPE	:= ARM64
Loading