Skip to content

Commit cf2a5e0

Browse files
paulburtonralfbaechle
authored andcommitted
MIPS: Support generating Flattened Image Trees (.itb)
Add support for generating kernel images in the Flattened Image Tree (.itb) format as supported by U-Boot. This format is essentially a Flattened Device Tree binary containing images (kernels, DTBs, ramdisks) and configurations which link those images together. The big advantages of FIT images over the uImage format are: - We can include FDTs in the kernel image in a way that the bootloader can extract it & manipulate it before providing it to the kernel. Thus we can ship FDTs as part of the kernel giving us the advantages of being able to develop & maintain the DT within the kernel tree, but also have the benefits of the bootloader being able to manipulate the FDT. Example uses for this would be to inject the kernel command line into the chosen node, or to fill in the correct memory size. - We can include multiple configurations in a single kernel image. This means that a single FIT image can, given appropriate bootloaders, be booted on different boards with the bootloader selecting an appropriate configuration & providing the correct FDT to the kernel. - We can support a multitude of hashes over the data. Signed-off-by: Paul Burton <[email protected]> Cc: [email protected] Patchwork: https://patchwork.linux-mips.org/patch/14352/ Signed-off-by: Ralf Baechle <[email protected]>
1 parent 3ffc17d commit cf2a5e0

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

arch/mips/Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ KBUILD_CPPFLAGS += -DVMLINUX_LOAD_ADDRESS=$(load-y)
262262
KBUILD_CPPFLAGS += -DDATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0)
263263

264264
bootvars-y = VMLINUX_LOAD_ADDRESS=$(load-y) \
265-
VMLINUX_ENTRY_ADDRESS=$(entry-y)
265+
VMLINUX_ENTRY_ADDRESS=$(entry-y) \
266+
PLATFORM=$(platform-y)
266267

267268
LDFLAGS += -m $(ld-emul)
268269

@@ -302,6 +303,11 @@ boot-y += uImage.gz
302303
boot-y += uImage.lzma
303304
boot-y += uImage.lzo
304305
endif
306+
boot-y += vmlinux.itb
307+
boot-y += vmlinux.gz.itb
308+
boot-y += vmlinux.bz2.itb
309+
boot-y += vmlinux.lzma.itb
310+
boot-y += vmlinux.lzo.itb
305311

306312
# compressed boot image targets (arch/mips/boot/compressed/)
307313
bootz-y := vmlinuz

arch/mips/boot/Makefile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,60 @@ $(obj)/uImage.lzo: $(obj)/vmlinux.bin.lzo FORCE
100100
$(obj)/uImage: $(obj)/uImage.$(suffix-y)
101101
@ln -sf $(notdir $<) $@
102102
@echo ' Image $@ is ready'
103+
104+
#
105+
# Flattened Image Tree (.itb) images
106+
#
107+
108+
targets += vmlinux.itb
109+
targets += vmlinux.gz.itb
110+
targets += vmlinux.bz2.itb
111+
targets += vmlinux.lzma.itb
112+
targets += vmlinux.lzo.itb
113+
114+
quiet_cmd_cpp_its_S = ITS $@
115+
cmd_cpp_its_S = $(CPP) $(cpp_flags) -P -C -o $@ $< \
116+
-DKERNEL_NAME="\"Linux $(KERNELRELEASE)\"" \
117+
-DVMLINUX_BINARY="\"$(3)\"" \
118+
-DVMLINUX_COMPRESSION="\"$(2)\"" \
119+
-DVMLINUX_LOAD_ADDRESS=$(VMLINUX_LOAD_ADDRESS) \
120+
-DVMLINUX_ENTRY_ADDRESS=$(VMLINUX_ENTRY_ADDRESS)
121+
122+
$(obj)/vmlinux.its: $(srctree)/arch/mips/$(PLATFORM)/vmlinux.its.S FORCE
123+
$(call if_changed_dep,cpp_its_S,none,vmlinux.bin)
124+
125+
$(obj)/vmlinux.gz.its: $(srctree)/arch/mips/$(PLATFORM)/vmlinux.its.S FORCE
126+
$(call if_changed_dep,cpp_its_S,gzip,vmlinux.bin.gz)
127+
128+
$(obj)/vmlinux.bz2.its: $(srctree)/arch/mips/$(PLATFORM)/vmlinux.its.S FORCE
129+
$(call if_changed_dep,cpp_its_S,bzip2,vmlinux.bin.bz2)
130+
131+
$(obj)/vmlinux.lzma.its: $(srctree)/arch/mips/$(PLATFORM)/vmlinux.its.S FORCE
132+
$(call if_changed_dep,cpp_its_S,lzma,vmlinux.bin.lzma)
133+
134+
$(obj)/vmlinux.lzo.its: $(srctree)/arch/mips/$(PLATFORM)/vmlinux.its.S FORCE
135+
$(call if_changed_dep,cpp_its_S,lzo,vmlinux.bin.lzo)
136+
137+
quiet_cmd_itb-image = ITB $@
138+
cmd_itb-image = \
139+
env PATH="$(objtree)/scripts/dtc:$(PATH)" \
140+
$(CONFIG_SHELL) $(MKIMAGE) \
141+
-D "-I dts -O dtb -p 500 \
142+
--include $(objtree)/arch/mips \
143+
--warning no-unit_address_vs_reg" \
144+
-f $(2) $@
145+
146+
$(obj)/vmlinux.itb: $(obj)/vmlinux.its $(obj)/vmlinux.bin FORCE
147+
$(call if_changed,itb-image,$<)
148+
149+
$(obj)/vmlinux.gz.itb: $(obj)/vmlinux.gz.its $(obj)/vmlinux.bin.gz FORCE
150+
$(call if_changed,itb-image,$<)
151+
152+
$(obj)/vmlinux.bz2.itb: $(obj)/vmlinux.bz2.its $(obj)/vmlinux.bin.bz2 FORCE
153+
$(call if_changed,itb-image,$<)
154+
155+
$(obj)/vmlinux.lzma.itb: $(obj)/vmlinux.lzma.its $(obj)/vmlinux.bin.lzma FORCE
156+
$(call if_changed,itb-image,$<)
157+
158+
$(obj)/vmlinux.lzo.itb: $(obj)/vmlinux.lzo.its $(obj)/vmlinux.bin.lzo FORCE
159+
$(call if_changed,itb-image,$<)

0 commit comments

Comments
 (0)