diff mbox series

[08/19] powerpc: boot: Enable FIT image generation

Message ID 20250102-mpc83xx-v1-8-86f78ba2a7af@posteo.net (mailing list archive)
State Changes Requested
Headers show
Series powerpc: MPC83xx cleanup and LANCOM NWAPP2 board | expand

Commit Message

J. Neuschäfer via B4 Relay Jan. 2, 2025, 6:31 p.m. UTC
From: "J. Neuschäfer" <j.ne@posteo.net>

The Flat Image Tree (FIT) format combines a kernel, a set of
devicetrees, and optionally additional resources into a single file that
can be loaded by a bootloader such as U-Boot. Generating a FIT image as
part of the kernel build reduces the need for additional build scripts,
and produces a single boot image without falling back to one of the
many legacy methods implemented in arch/powerpc/boot/Makefile, which
would require additional changes for arch/powerpc/boot for each board.

Signed-off-by: J. Neuschäfer <j.ne@posteo.net>
---

Checkpatch warns:

  arch/powerpc/boot/Makefile:364: WARNING: Possible repeated word: 'Image'

for this line:

  image-y += Image image.fit

This is bogus and can be ignored.
---
 arch/powerpc/Makefile      |  3 ++-
 arch/powerpc/boot/Makefile | 11 +++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

Comments

Christophe Leroy Jan. 6, 2025, 1:52 p.m. UTC | #1
Le 02/01/2025 à 19:31, J. Neuschäfer via B4 Relay a écrit :
> [Vous ne recevez pas souvent de courriers de devnull+j.ne.posteo.net@kernel.org. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
> 
> From: "J. Neuschäfer" <j.ne@posteo.net>
> 
> The Flat Image Tree (FIT) format combines a kernel, a set of
> devicetrees, and optionally additional resources into a single file that
> can be loaded by a bootloader such as U-Boot. Generating a FIT image as
> part of the kernel build reduces the need for additional build scripts,
> and produces a single boot image without falling back to one of the
> many legacy methods implemented in arch/powerpc/boot/Makefile, which
> would require additional changes for arch/powerpc/boot for each board.

Will that allow compressed vmlinux ?

Looking at the change I have the feeling it only includes raw 
uncompressed images.


> 
> Signed-off-by: J. Neuschäfer <j.ne@posteo.net>
> ---
> 
> Checkpatch warns:
> 
>    arch/powerpc/boot/Makefile:364: WARNING: Possible repeated word: 'Image'
> 
> for this line:
> 
>    image-y += Image image.fit
> 
> This is bogus and can be ignored.
> ---
>   arch/powerpc/Makefile      |  3 ++-
>   arch/powerpc/boot/Makefile | 11 +++++++++++
>   2 files changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index f3804103c56ccfdb16289468397ccaea71bf721e..693c82c06072fb0529288736efee460e375b2476 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -225,7 +225,7 @@ KBUILD_CFLAGS += $(cflags-y)
>   all: zImage
> 
>   # With make 3.82 we cannot mix normal and wildcard targets
> -BOOT_TARGETS1 := zImage zImage.initrd uImage
> +BOOT_TARGETS1 := zImage zImage.initrd uImage image.fit
>   BOOT_TARGETS2 := zImage% dtbImage% treeImage.% cuImage.% simpleImage.% uImage.%
> 
>   PHONY += $(BOOT_TARGETS1) $(BOOT_TARGETS2)
> @@ -237,6 +237,7 @@ $(BOOT_TARGETS1): vmlinux
>   $(BOOT_TARGETS2): vmlinux
>          $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
> 
> +image.fit: dtbs
> 
>   PHONY += bootwrapper_install
>   bootwrapper_install:
> diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
> index 1ff6ad4f6cd27755ea7bfe5b02af4a47ca33cea7..e0c62ab1cc5af99e43f6639be11bf1c64d352db8 100644
> --- a/arch/powerpc/boot/Makefile
> +++ b/arch/powerpc/boot/Makefile
> @@ -360,6 +360,9 @@ ifdef CONFIG_PPC32
>   image-$(CONFIG_PPC_PMAC)       += zImage.coff zImage.miboot
>   endif
> 
> +# FIT support (generic)
> +image-y += Image image.fit
> +
>   # Allow extra targets to be added to the defconfig
>   image-y        += $(CONFIG_EXTRA_TARGETS)
> 
> @@ -398,6 +401,14 @@ $(obj)/dtbImage.%: vmlinux $(wrapperbits) $(obj)/dts/%.dtb FORCE
>   $(obj)/vmlinux.strip: vmlinux
>          $(STRIP) -s -R .comment $< -o $@
> 
> +OBJCOPYFLAGS += -O binary
> +
> +$(obj)/Image: vmlinux FORCE
> +       $(call if_changed,objcopy)
> +
> +$(obj)/image.fit: $(obj)/Image $(obj)/dts/dtbs-list FORCE
> +       $(call if_changed,fit)
> +
>   $(obj)/uImage: vmlinux $(wrapperbits) FORCE
>          $(call if_changed,wrap,uboot)
> 
> 
> --
> 2.45.2
> 
>
J. Neuschäfer Jan. 7, 2025, 11 p.m. UTC | #2
On Mon, Jan 06, 2025 at 02:52:59PM +0100, Christophe Leroy wrote:
> 
> 
> Le 02/01/2025 à 19:31, J. Neuschäfer via B4 Relay a écrit :
> > [Vous ne recevez pas souvent de courriers de devnull+j.ne.posteo.net@kernel.org. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
> > 
> > From: "J. Neuschäfer" <j.ne@posteo.net>
> > 
> > The Flat Image Tree (FIT) format combines a kernel, a set of
> > devicetrees, and optionally additional resources into a single file that
> > can be loaded by a bootloader such as U-Boot. Generating a FIT image as
> > part of the kernel build reduces the need for additional build scripts,
> > and produces a single boot image without falling back to one of the
> > many legacy methods implemented in arch/powerpc/boot/Makefile, which
> > would require additional changes for arch/powerpc/boot for each board.
> 
> Will that allow compressed vmlinux ?

Yes, the make_fit.py script can compress included data (kernel, dtb),
and the logic in scripts/Makefile.lib makes use of this feature.
By default, gzip is used:

# Use this to override the compression algorithm
FIT_COMPRESSION ?= gzip

quiet_cmd_fit = FIT     $@
      cmd_fit = $(MAKE_FIT) -o $@ --arch $(UIMAGE_ARCH) --os linux \
		--name '$(UIMAGE_NAME)' \
		$(if $(findstring 1,$(KBUILD_VERBOSE)),-v) \
		$(if $(FIT_DECOMPOSE_DTBS),--decompose-dtbs) \
		--compress $(FIT_COMPRESSION) -k $< @$(word 2,$^)


Best regards,
J. Neuschäfer
diff mbox series

Patch

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index f3804103c56ccfdb16289468397ccaea71bf721e..693c82c06072fb0529288736efee460e375b2476 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -225,7 +225,7 @@  KBUILD_CFLAGS += $(cflags-y)
 all: zImage
 
 # With make 3.82 we cannot mix normal and wildcard targets
-BOOT_TARGETS1 := zImage zImage.initrd uImage
+BOOT_TARGETS1 := zImage zImage.initrd uImage image.fit
 BOOT_TARGETS2 := zImage% dtbImage% treeImage.% cuImage.% simpleImage.% uImage.%
 
 PHONY += $(BOOT_TARGETS1) $(BOOT_TARGETS2)
@@ -237,6 +237,7 @@  $(BOOT_TARGETS1): vmlinux
 $(BOOT_TARGETS2): vmlinux
 	$(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
 
+image.fit: dtbs
 
 PHONY += bootwrapper_install
 bootwrapper_install:
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 1ff6ad4f6cd27755ea7bfe5b02af4a47ca33cea7..e0c62ab1cc5af99e43f6639be11bf1c64d352db8 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -360,6 +360,9 @@  ifdef CONFIG_PPC32
 image-$(CONFIG_PPC_PMAC)	+= zImage.coff zImage.miboot
 endif
 
+# FIT support (generic)
+image-y += Image image.fit
+
 # Allow extra targets to be added to the defconfig
 image-y	+= $(CONFIG_EXTRA_TARGETS)
 
@@ -398,6 +401,14 @@  $(obj)/dtbImage.%: vmlinux $(wrapperbits) $(obj)/dts/%.dtb FORCE
 $(obj)/vmlinux.strip: vmlinux
 	$(STRIP) -s -R .comment $< -o $@
 
+OBJCOPYFLAGS += -O binary
+
+$(obj)/Image: vmlinux FORCE
+	$(call if_changed,objcopy)
+
+$(obj)/image.fit: $(obj)/Image $(obj)/dts/dtbs-list FORCE
+	$(call if_changed,fit)
+
 $(obj)/uImage: vmlinux $(wrapperbits) FORCE
 	$(call if_changed,wrap,uboot)