1 How to use images in the new image format
2 =========================================
4 Author: Bartlomiej Sieka <tur@semihalf.com>
10 The new uImage format allows more flexibility in handling images of various
11 types (kernel, ramdisk, etc.), it also enhances integrity protection of images
12 with sha1 and md5 checksums.
14 Two auxiliary tools are needed on the development host system in order to
15 create an uImage in the new format: mkimage and dtc, although only one
16 (mkimage) is invoked directly. dtc is called from within mkimage and operates
17 behind the scenes, but needs to be present in the $PATH nevertheless. It is
18 important that the dtc used has support for binary includes -- refer to
20 git://git.kernel.org/pub/scm/utils/dtc/dtc.git
22 for its latest version. mkimage (together with dtc) takes as input
23 an image source file, which describes the contents of the image and defines
24 its various properties used during booting. By convention, image source file
25 has the ".its" extension, also, the details of its format are given in
26 doc/uImage.FIT/source_file_format.txt. The actual data that is to be included in
27 the uImage (kernel, ramdisk, etc.) is specified in the image source file in the
28 form of paths to appropriate data files. The outcome of the image creation
29 process is a binary file (by convention with the ".itb" extension) that
30 contains all the referenced data (kernel, ramdisk, etc.) and other information
31 needed by U-Boot to handle the uImage properly. The uImage file is then
32 transferred to the target (e.g., via tftp) and booted using the bootm command.
34 To summarize the prerequisites needed for new uImage creation:
36 - dtc (with support for binary includes)
37 - image source file (*.its)
41 Here's a graphical overview of the image creation and booting process:
43 image source file mkimage + dtc transfer to target
44 + ---------------> image file --------------------> bootm
50 The SPL can make use of the new image format as well, this traditionally
51 is used to ship multiple device tree files within one image. Code in the SPL
52 will choose the one matching the current board and append this to the
53 U-Boot proper binary to be automatically used up by it.
54 Aside from U-Boot proper and one device tree blob the SPL can load multiple,
55 arbitrary image files as well. These binaries should be specified in their
56 own subnode under the /images node, which should then be referenced from one or
57 multiple /configurations subnodes. The required images must be enumerated in
58 the "loadables" property as a list of strings.
60 If a platform specific image source file (.its) is shipped with the U-Boot
61 source, it can be specified using the CONFIG_SPL_FIT_SOURCE Kconfig symbol.
62 In this case it will be automatically used by U-Boot's Makefile to generate
64 If a static source file is not flexible enough, CONFIG_SPL_FIT_GENERATOR
65 can point to a script which generates this image source file during
66 the build process. It gets passed a list of device tree files (taken from the
67 CONFIG_OF_LIST symbol).
69 The SPL also records to a DT all additional images (called loadables) which are
70 loaded. The information about loadables locations is passed via the DT node with
73 Finally, if there are multiple xPL phases (e.g. SPL, VPL), images can be marked
74 as intended for a particular phase using the 'phase' property. For example, if
75 fit_image_load() is called with image_ph(IH_PHASE_SPL, IH_TYPE_FIRMWARE), then
76 only the image listed into the "firmware" property where phase is set to "spl"
81 Consider the following case for an ARM64 platform where U-Boot runs in EL2
82 started by ATF where SPL is loading U-Boot (as loadables) and ATF (as firmware).
87 description = "Configuration to load ATF before U-Boot";
91 description = "U-Boot (64-bit)";
92 data = /incbin/("u-boot-nodtb.bin");
97 load = <0x8 0x8000000>;
98 entry = <0x8 0x8000000>;
104 description = "ARM Trusted Firmware";
105 data = /incbin/("bl31.bin");
107 os = "arm-trusted-firmware";
109 compression = "none";
111 entry = <0xfffea000>;
117 description = "zynqmp-zcu102-revA";
118 data = /incbin/("arch/arm/dts/zynqmp-zcu102-revA.dtb");
121 compression = "none";
129 default = "config_1";
132 description = "zynqmp-zcu102-revA";
140 In this case the SPL records via fit-images DT node the information about
141 loadables U-Boot image.
143 ZynqMP> fdt addr $fdtcontroladdr
144 ZynqMP> fdt print /fit-images
150 entry = <0x00000008 0x08000000>;
151 load = <0x00000008 0x08000000>;
155 As you can see entry and load properties are 64bit wide to support loading
156 images above 4GB (in past entry and load properties where just 32bit).
159 Example 1 -- old-style (non-FDT) kernel booting
160 -----------------------------------------------
162 Consider a simple scenario, where a PPC Linux kernel built from sources on the
163 development host is to be booted old-style (non-FDT) by U-Boot on an embedded
164 target. Assume that the outcome of the build is vmlinux.bin.gz, a file which
165 contains a gzip-compressed PPC Linux kernel (the only data file in this case).
166 The uImage can be produced using the image source file
167 doc/uImage.FIT/kernel.its (note that kernel.its assumes that vmlinux.bin.gz is
168 in the current working directory; if desired, an alternative path can be
169 specified in the kernel.its file). Here's how to create the image and inspect
173 $ mkimage -f kernel.its kernel.itb
174 DTC: dts->dtb on file "kernel.its"
176 $ mkimage -l kernel.itb
177 FIT description: Simple image with single Linux kernel
178 Created: Tue Mar 11 17:26:15 2008
180 Description: Vanilla Linux kernel
182 Compression: gzip compressed
183 Data Size: 943347 Bytes = 921.24 kB = 0.90 MB
184 Architecture: PowerPC
186 Load Address: 0x00000000
187 Entry Point: 0x00000000
191 Hash value: 3c200f34e2c226ddc789240cca0c59fc54a67cf4
192 Default Configuration: 'config-1'
193 Configuration 0 (config-1)
194 Description: Boot Linux kernel
198 The resulting image file kernel.itb can be now transferred to the target,
199 inspected and booted (note that first three U-Boot commands below are shown
200 for completeness -- they are part of the standard booting procedure and not
201 specific to the new image format).
203 [on the target system]
205 nfsargs=setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:${rootpath}
207 addip=setenv bootargs ${bootargs} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}:${netdev}:off panic=1
209 => tftp 900000 /path/to/tftp/location/kernel.itb
211 TFTP from server 192.168.1.1; our IP address is 192.168.160.5
212 Filename '/path/to/tftp/location/kernel.itb'.
213 Load address: 0x900000
214 Loading: #################################################################
216 Bytes transferred = 944464 (e6950 hex)
219 ## Checking Image at 00900000 ...
221 FIT description: Simple image with single Linux kernel
222 Created: 2008-03-11 16:26:15 UTC
224 Description: Vanilla Linux kernel
226 Compression: gzip compressed
227 Data Start: 0x009000e0
228 Data Size: 943347 Bytes = 921.2 kB
229 Architecture: PowerPC
231 Load Address: 0x00000000
232 Entry Point: 0x00000000
236 Hash value: 3c200f34e2c226ddc789240cca0c59fc54a67cf4
237 Default Configuration: 'config-1'
238 Configuration 0 (config-1)
239 Description: Boot Linux kernel
243 ## Booting kernel from FIT Image at 00900000 ...
244 Using 'config-1' configuration
245 Trying 'kernel' kernel subimage
246 Description: Vanilla Linux kernel
248 Compression: gzip compressed
249 Data Start: 0x009000e0
250 Data Size: 943347 Bytes = 921.2 kB
251 Architecture: PowerPC
253 Load Address: 0x00000000
254 Entry Point: 0x00000000
258 Hash value: 3c200f34e2c226ddc789240cca0c59fc54a67cf4
259 Verifying Hash Integrity ... crc32+ sha1+ OK
260 Uncompressing Kernel Image ... OK
261 Memory BAT mapping: BAT2=256Mb, BAT3=0Mb, residual: 0Mb
262 Linux version 2.4.25 (m8@hekate) (gcc version 4.0.0 (DENX ELDK 4.0 4.0.0)) #2 czw lip 5 17:56:18 CEST 2007
263 On node 0 totalpages: 65536
264 zone(0): 65536 pages.
267 Kernel command line: root=/dev/nfs rw nfsroot=192.168.1.1:/opt/eldk-4.1/ppc_6xx ip=192.168.160.5:192.168.1.1::255.255.0.0:lite5200b:eth0:off panic=1
268 Calibrating delay loop... 307.20 BogoMIPS
271 Example 2 -- new-style (FDT) kernel booting
272 -------------------------------------------
274 Consider another simple scenario, where a PPC Linux kernel is to be booted
275 new-style, i.e., with a FDT blob. In this case there are two prerequisite data
276 files: vmlinux.bin.gz (Linux kernel) and target.dtb (FDT blob). The uImage can
277 be produced using image source file doc/uImage.FIT/kernel_fdt.its like this
278 (note again, that both prerequisite data files are assumed to be present in
279 the current working directory -- image source file kernel_fdt.its can be
280 modified to take the files from some other location if needed):
283 $ mkimage -f kernel_fdt.its kernel_fdt.itb
284 DTC: dts->dtb on file "kernel_fdt.its"
286 $ mkimage -l kernel_fdt.itb
287 FIT description: Simple image with single Linux kernel and FDT blob
288 Created: Tue Mar 11 16:29:22 2008
290 Description: Vanilla Linux kernel
292 Compression: gzip compressed
293 Data Size: 1092037 Bytes = 1066.44 kB = 1.04 MB
294 Architecture: PowerPC
296 Load Address: 0x00000000
297 Entry Point: 0x00000000
301 Hash value: 264b59935470e42c418744f83935d44cdf59a3bb
303 Description: Flattened Device Tree blob
304 Type: Flat Device Tree
305 Compression: uncompressed
306 Data Size: 16384 Bytes = 16.00 kB = 0.02 MB
307 Architecture: PowerPC
311 Hash value: 25ab4e15cd4b8a5144610394560d9c318ce52def
312 Default Configuration: 'conf-1'
313 Configuration 0 (conf-1)
314 Description: Boot Linux kernel with FDT blob
319 The resulting image file kernel_fdt.itb can be now transferred to the target,
320 inspected and booted:
322 [on the target system]
323 => tftp 900000 /path/to/tftp/location/kernel_fdt.itb
325 TFTP from server 192.168.1.1; our IP address is 192.168.160.5
326 Filename '/path/to/tftp/location/kernel_fdt.itb'.
327 Load address: 0x900000
328 Loading: #################################################################
331 Bytes transferred = 1109776 (10ef10 hex)
334 ## Checking Image at 00900000 ...
336 FIT description: Simple image with single Linux kernel and FDT blob
337 Created: 2008-03-11 15:29:22 UTC
339 Description: Vanilla Linux kernel
341 Compression: gzip compressed
342 Data Start: 0x009000ec
343 Data Size: 1092037 Bytes = 1 MB
344 Architecture: PowerPC
346 Load Address: 0x00000000
347 Entry Point: 0x00000000
351 Hash value: 264b59935470e42c418744f83935d44cdf59a3bb
353 Description: Flattened Device Tree blob
354 Type: Flat Device Tree
355 Compression: uncompressed
356 Data Start: 0x00a0abdc
357 Data Size: 16384 Bytes = 16 kB
358 Architecture: PowerPC
362 Hash value: 25ab4e15cd4b8a5144610394560d9c318ce52def
363 Default Configuration: 'conf-1'
364 Configuration 0 (conf-1)
365 Description: Boot Linux kernel with FDT blob
369 ## Booting kernel from FIT Image at 00900000 ...
370 Using 'conf-1' configuration
371 Trying 'kernel' kernel subimage
372 Description: Vanilla Linux kernel
374 Compression: gzip compressed
375 Data Start: 0x009000ec
376 Data Size: 1092037 Bytes = 1 MB
377 Architecture: PowerPC
379 Load Address: 0x00000000
380 Entry Point: 0x00000000
384 Hash value: 264b59935470e42c418744f83935d44cdf59a3bb
385 Verifying Hash Integrity ... crc32+ sha1+ OK
386 Uncompressing Kernel Image ... OK
387 ## Flattened Device Tree from FIT Image at 00900000
388 Using 'conf-1' configuration
389 Trying 'fdt-1' FDT blob subimage
390 Description: Flattened Device Tree blob
391 Type: Flat Device Tree
392 Compression: uncompressed
393 Data Start: 0x00a0abdc
394 Data Size: 16384 Bytes = 16 kB
395 Architecture: PowerPC
399 Hash value: 25ab4e15cd4b8a5144610394560d9c318ce52def
400 Verifying Hash Integrity ... crc32+ sha1+ OK
401 Booting using the fdt blob at 0xa0abdc
402 Loading Device Tree to 007fc000, end 007fffff ... OK
403 [ 0.000000] Using lite5200 machine description
404 [ 0.000000] Linux version 2.6.24-rc6-gaebecdfc (m8@hekate) (gcc version 4.0.0 (DENX ELDK 4.1 4.0.0)) #1 Sat Jan 12 15:38:48 CET 2008
407 Example 3 -- advanced booting
408 -----------------------------
410 Refer to doc/uImage.FIT/multi.its for an image source file that allows more
411 sophisticated booting scenarios (multiple kernels, ramdisks and fdt blobs).