Re: [PATCH v9 2/2] arm64: boot: Support Flat Image Tree

2023-12-08 Thread Nicolas Schier
On Fri, Dec 01, 2023 at 08:54:42PM -0700, Simon Glass 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. Use
> FIT_COMPRESSION to select a different algorithm.
> 
> 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 
> ---

for the kbuild parts:

Reviewed-by: Nicolas Schier 



> Changes in v9:
> - Move the compression control into Makefile.lib
> 
> 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 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  |   6 +-
>  scripts/Makefile.lib  |  16 ++
>  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 tar1.28 tar --version
>  gtags (optional)   6.6.5gtags --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/

Re: [PATCH v9 1/2] arm64: Add BOOT_TARGETS variable

2023-12-08 Thread Nicolas Schier
On Fri, Dec 01, 2023 at 08:54:41PM -0700, Simon Glass wrote:
> Add a new variable containing a list of possible targets. Mark them as
> phony. This matches the approach taken for arch/arm
> 
> Signed-off-by: Simon Glass 
> ---

Reviewed-by: Nicolas Schier 


signature.asc
Description: PGP signature


Re: [PATCH v7 2/2] arm64: boot: Support Flat Image Tree

2023-11-30 Thread Nicolas Schier
Simon,

thanks for the patch!  Below are some nitpicks and bike-shedding 
questions.

On Wed 29 Nov 2023 10:21:53 GMT, Simon Glass 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.

Have you thought about updating the arch/mips ITB rules to also use the 
new scripts/make_fit.py?  Or is the FIT/ITB format for mips different 
from the one for arm64?

> 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 
> ---
> 
> 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
> 
>  MAINTAINERS|   7 +
>  arch/arm64/Makefile|   9 +-
>  arch/arm64/boot/.gitignore |   1 +
>  arch/arm64/boot/Makefile   |   6 +-
>  scripts/Makefile.lib   |  13 ++
>  scripts/make_fit.py| 289 +
>  6 files changed, 322 insertions(+), 3 deletions(-)
>  create mode 100755 scripts/make_fit.py
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 14587be87a33..d609f0e8deb3 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1585,6 +1585,13 @@ F: Documentation/process/maintainer-soc*.rst
>  F:   arch/arm/boot/dts/Makefile
>  F:   arch/arm64/boot/dts/Makefile
>  
> +ARM64 FIT SUPPORT
> +M:   Simon Glass 
> +L:   linux-arm-ker...@lists.infradead.org (moderated for non-subscribers)
> +S:   Maintained
> +F:   arch/arm64/boot/Makefile
> +F:   scripts/make_fit.py
> +

I'm afraid that the location does not match the requested sorting, it 
should be right before "ARM64 PORT".

>  ARM ARCHITECTED TIMER DRIVER
>  M:   Mark Rutland 
>  M:   Marc Zyngier 
> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
> index 1bd4fae6e806..18e092de7cdb 100644
> --- a/arch/arm64/Makefile
> +++ b/arch/arm64/Makefile
> @@ -36,6 +36,8 @@ ifeq ($(CONFIG_BROKEN_GAS_INST),y)
>  $(warning Detected assembler with broken .inst; disassembly will be 
> unreliable)
>  endif
>  
> +KBUILD_DTBS  := dtbs

Might you want to use tabs here as in the lines below?

> +
>  KBUILD_CFLAGS+= -mgeneral-regs-only  \
>  $(compat_vdso) $(cc_has_k_constraint)
>  KBUILD_CFLAGS+= $(call cc-disable-warning, psabi)
> @@ -150,7 +152,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 +164,9 @@ endif
>  
>  all: $(notdir $(KBUILD_IMAGE))
>  
> -vmlinuz.efi: Image
> +image.fit: $(KBUILD_DTBS)
> +
> +vmlinuz.efi image.fit: Image
>  $(BOOT_TARGETS): vmlinux
>   $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
>  
> @@ -215,6 +219,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.f