mips: boot: add support for self-extracting FIT images (vmlinuz.itb)
authorAlexander Lobakin <alobakin@pm.me>
Sun, 1 Nov 2020 15:13:01 +0000 (15:13 +0000)
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>
Thu, 12 Nov 2020 22:47:22 +0000 (23:47 +0100)
Commit c3e2ee657418 ("MIPS: generic: Add support for zboot") added
support for self-extracting images to Generic MIPS. However, the
intended way to boot Generic MIPS kernels is using FIT Images and
UHI boot protocol, but currently there's no way to make self-extracting
FIT Image (only legacy uzImages).
Add a target for this named "vmlinuz.itb", which will consist of
vmlinuz.bin and selected DT blobs. It will allow to have the advantages
of both UHI and self-extracting images.

Signed-off-by: Alexander Lobakin <alobakin@pm.me>
Acked-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
arch/mips/Makefile
arch/mips/boot/compressed/Makefile

index 622ee83..cd4343e 100644 (file)
@@ -347,6 +347,7 @@ bootz-y                     += vmlinuz.srec
 ifeq ($(shell expr $(zload-y) \< 0xffffffff80000000 2> /dev/null), 0)
 bootz-y                        += uzImage.bin
 endif
+bootz-y                        += vmlinuz.itb
 
 #
 # Some machines like the Indy need 32-bit ELF binaries for booting purposes.
index fa2c1e1..4c3bc7e 100644 (file)
@@ -172,3 +172,51 @@ targets += ../uzImage.bin
 
 $(objboot)/uzImage.bin: $(objboot)/vmlinuz.bin FORCE
        $(call if_changed,uimage,none)
+
+#
+# Flattened Image Tree (.itb) image
+#
+
+ifeq ($(ADDR_BITS),32)
+itb_addr_cells = 1
+endif
+ifeq ($(ADDR_BITS),64)
+itb_addr_cells = 2
+endif
+
+targets += ../vmlinuz.its.S
+
+quiet_cmd_its_cat = CAT     $@
+      cmd_its_cat = cat $(real-prereqs) >$@
+
+$(objboot)/vmlinuz.its.S: $(addprefix $(srctree)/arch/mips/$(PLATFORM)/,$(ITS_INPUTS)) FORCE
+       $(call if_changed,its_cat)
+
+targets += ../vmlinuz.its
+
+quiet_cmd_cpp_its_S = ITS     $@
+      cmd_cpp_its_S = $(CPP) -P -C -o $@ $< \
+                       -DKERNEL_NAME="\"Linux $(KERNELRELEASE)\"" \
+                       -DVMLINUX_BINARY="\"$(2)\"" \
+                       -DVMLINUX_COMPRESSION="\"none\"" \
+                       -DVMLINUX_LOAD_ADDRESS=$(VMLINUZ_LOAD_ADDRESS) \
+                       -DVMLINUX_ENTRY_ADDRESS=$(VMLINUZ_LOAD_ADDRESS) \
+                       -DADDR_BITS=$(ADDR_BITS) \
+                       -DADDR_CELLS=$(itb_addr_cells)
+
+$(objboot)/vmlinuz.its: $(objboot)/vmlinuz.its.S FORCE
+       $(call if_changed,cpp_its_S,vmlinuz.bin)
+
+targets += ../vmlinuz.itb
+
+quiet_cmd_itb-image = ITB     $@
+      cmd_itb-image = \
+               env PATH="$(objtree)/scripts/dtc:$(PATH)" \
+               $(BASH) $(MKIMAGE) \
+               -D "-I dts -O dtb -p 500 \
+                       --include $(objtree)/arch/mips \
+                       --warning no-unit_address_vs_reg" \
+               -f $(2) $@
+
+$(objboot)/vmlinuz.itb: $(objboot)/vmlinuz.its $(objboot)/vmlinuz.bin FORCE
+       $(call if_changed,itb-image,$<)