[PATCH 26/28] MIPS: support for generating FIT (.itb) images

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Introduce support for generating Flattened Image Tree images containing
the kernel & platform-specific configuration such as a device tree
binary. The FIT format is supported by U-Boot and has a number of
advantages over the older legacy uImage format:

  - It includes device tree binaries inside the image without embedding
    them directly into the kernel ELF, allowing the bootloader to easily
    find & manipulate the DTB whilst still only requiring a single file
    to be loaded during boot or distributed to users.

  - It allows for an arbitrary number of images & configurations to be
    included in a single file. Once the code for various systems built
    around the MIPS Coherent Processing System architecture (ie.
    Imagination Technologies MIPS cores with optional CM, GIC & CPC) is
    consolidated sufficiently this will allow for a single binary to
    include multiple device trees & boot on multiple boards.

  - It allows for a choice of hash algorithms to verify the contents of
    the image.

  - It allows for cryptographically signed images should that ever be
    desired.

Signed-off-by: Paul Burton <paul.burton@xxxxxxxxxx>
---

 arch/mips/Makefile          |  6 ++++-
 arch/mips/boot/Makefile     | 61 +++++++++++++++++++++++++++++++++++++++++++++
 arch/mips/boot/skeleton.its | 24 ++++++++++++++++++
 3 files changed, 90 insertions(+), 1 deletion(-)
 create mode 100644 arch/mips/boot/skeleton.its

diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 3f70ba5..bf4606f 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -267,7 +267,8 @@ KBUILD_CPPFLAGS += -DVMLINUX_LOAD_ADDRESS=$(load-y)
 KBUILD_CPPFLAGS += -DDATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0)
 
 bootvars-y	= VMLINUX_LOAD_ADDRESS=$(load-y) \
-		  VMLINUX_ENTRY_ADDRESS=$(entry-y)
+		  VMLINUX_ENTRY_ADDRESS=$(entry-y) \
+		  PLATFORM_ITS=$(its-y)
 
 LDFLAGS			+= -m $(ld-emul)
 
@@ -307,6 +308,9 @@ boot-y			+= uImage.gz
 boot-y			+= uImage.lzma
 boot-y			+= uImage.lzo
 endif
+boot-y			+= vmlinux.itb
+boot-y			+= vmlinux.bz2.itb
+boot-y			+= vmlinux.gz.itb
 
 # compressed boot image targets (arch/mips/boot/compressed/)
 bootz-y			:= vmlinuz
diff --git a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile
index acb1988..82de53d 100644
--- a/arch/mips/boot/Makefile
+++ b/arch/mips/boot/Makefile
@@ -100,3 +100,64 @@ $(obj)/uImage.lzo: $(obj)/vmlinux.bin.lzo FORCE
 $(obj)/uImage: $(obj)/uImage.$(suffix-y)
 	@ln -sf $(notdir $<) $@
 	@echo '  Image $@ is ready'
+
+#
+# Flattened Image Tree (.itb) images
+#
+
+targets += vmlinux.itb
+targets += vmlinux.gz.itb
+
+# Split a 64bit address into 2x32bit hex integers
+its_addr = $(shell echo $(1) | sed 's/0x\(........\)\(........\)/0x\1 0x\2/')
+
+its_load_addr := $(call its_addr,$(VMLINUX_LOAD_ADDRESS))
+its_entry_addr := $(call its_addr,$(VMLINUX_ENTRY_ADDRESS))
+
+its_files := $(patsubst %,$(srctree)/arch/mips/%,$(PLATFORM_ITS))
+its_inc := $(patsubst %,/include/ \"%\"\n,$(PLATFORM_ITS))
+
+quiet_cmd_gen-its = ITS     $@
+      cmd_gen-its = sed "s|__VMLINUX__|$(2)|g" $< | \
+		sed "s|__VMLINUX_COMPRESSION__|$(3)|g" | \
+		sed "s|__PLATFORM_INCLUDES__|$(its_inc)|g" | \
+		sed "s|__LOAD_ADDR__|$(its_load_addr)|g" | \
+		sed "s|__ENTRY_ADDR__|$(its_entry_addr)|g" \
+		>$@
+
+quiet_cmd_itb-image = ITB     $@
+      cmd_itb-image = \
+		env PATH="$(objtree)/scripts/dtc:$(PATH)" \
+		$(CONFIG_SHELL) $(MKIMAGE) \
+		-D "-I dts -O dtb -p 500 --include $(srctree)/arch/mips --include $(objtree)/arch/mips" \
+		-f $(3) $@
+
+$(obj)/vmlinux.its: $(srctree)/arch/mips/boot/skeleton.its $(its_files) FORCE
+	$(call if_changed,gen-its,boot/vmlinux.bin,none)
+
+$(obj)/vmlinux.itb: $(obj)/vmlinux.bin $(obj)/vmlinux.its FORCE
+	$(call if_changed,itb-image,none,$(obj)/vmlinux.its)
+
+$(obj)/vmlinux.bz2.its: $(srctree)/arch/mips/boot/skeleton.its $(its_files) FORCE
+	$(call if_changed,gen-its,boot/vmlinux.bin.bz2,bzip2)
+
+$(obj)/vmlinux.bz2.itb: $(obj)/vmlinux.bin.bz2 $(obj)/vmlinux.bz2.its FORCE
+	$(call if_changed,itb-image,bzip2,$(obj)/vmlinux.bz2.its)
+
+$(obj)/vmlinux.gz.its: $(srctree)/arch/mips/boot/skeleton.its $(its_files) FORCE
+	$(call if_changed,gen-its,boot/vmlinux.bin.gz,gzip)
+
+$(obj)/vmlinux.gz.itb: $(obj)/vmlinux.bin.gz $(obj)/vmlinux.gz.its FORCE
+	$(call if_changed,itb-image,gzip,$(obj)/vmlinux.gz.its)
+
+$(obj)/vmlinux.lzma.its: $(srctree)/arch/mips/boot/skeleton.its $(its_files) FORCE
+	$(call if_changed,gen-its,boot/vmlinux.bin.lzma,lzmaip)
+
+$(obj)/vmlinux.lzma.itb: $(obj)/vmlinux.bin.lzma $(obj)/vmlinux.lzma.its FORCE
+	$(call if_changed,itb-image,lzma,$(obj)/vmlinux.lzma.its)
+
+$(obj)/vmlinux.lzo.its: $(srctree)/arch/mips/boot/skeleton.its $(its_files) FORCE
+	$(call if_changed,gen-its,boot/vmlinux.bin.lzo,lzoip)
+
+$(obj)/vmlinux.lzo.itb: $(obj)/vmlinux.bin.lzo $(obj)/vmlinux.lzo.its FORCE
+	$(call if_changed,itb-image,lzo,$(obj)/vmlinux.lzo.its)
diff --git a/arch/mips/boot/skeleton.its b/arch/mips/boot/skeleton.its
new file mode 100644
index 0000000..a49c3d2
--- /dev/null
+++ b/arch/mips/boot/skeleton.its
@@ -0,0 +1,24 @@
+/dts-v1/;
+
+/ {
+	description = "MIPS Linux";
+	#address-cells = <1>;
+
+	images {
+		kernel@0 {
+			description = "Linux";
+			data = /incbin/("__VMLINUX__");
+			type = "kernel";
+			arch = "mips";
+			os = "linux";
+			compression = "__VMLINUX_COMPRESSION__";
+			load = <__LOAD_ADDR__>;
+			entry = <__ENTRY_ADDR__>;
+			hash@1 {
+				algo = "sha1";
+			};
+		};
+	};
+};
+
+__PLATFORM_INCLUDES__
-- 
2.6.2





[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux