blob: 6dbd17dc8ca024308dae006268a0019228474e1e [file] [log] [blame]
Marian Balakowicz3310c542008-03-12 12:13:13 +01001How to use images in the new image format
2=========================================
3
4Author: Bartlomiej Sieka <tur@semihalf.com>
5
6
7Overview
8--------
9
10The new uImage format allows more flexibility in handling images of various
11types (kernel, ramdisk, etc.), it also enhances integrity protection of images
12with sha1 and md5 checksums.
13
14Two auxiliary tools are needed on the development host system in order to
15create 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
17behind the scenes, but needs to be present in the $PATH nevertheless. It is
18important that the dtc used has support for binary includes -- refer to
Jon Loeliger5f658262014-05-27 09:12:48 -050019
20 git://git.kernel.org/pub/scm/utils/dtc/dtc.git
21
22for its latest version. mkimage (together with dtc) takes as input
Marian Balakowicz3310c542008-03-12 12:13:13 +010023an image source file, which describes the contents of the image and defines
24its various properties used during booting. By convention, image source file
25has the ".its" extension, also, the details of its format are given in
Masahiro Yamada09b72d62014-01-16 11:05:23 +090026doc/uImage.FIT/source_file_format.txt. The actual data that is to be included in
27the uImage (kernel, ramdisk, etc.) is specified in the image source file in the
Marian Balakowicz3310c542008-03-12 12:13:13 +010028form of paths to appropriate data files. The outcome of the image creation
29process is a binary file (by convention with the ".itb" extension) that
30contains all the referenced data (kernel, ramdisk, etc.) and other information
31needed by U-Boot to handle the uImage properly. The uImage file is then
32transferred to the target (e.g., via tftp) and booted using the bootm command.
33
34To summarize the prerequisites needed for new uImage creation:
35- mkimage
36- dtc (with support for binary includes)
37- image source file (*.its)
38- image data file(s)
39
40
41Here's a graphical overview of the image creation and booting process:
42
Wolfgang Denk438a4c12008-03-26 11:48:46 +010043image source file mkimage + dtc transfer to target
44 + ---------------> image file --------------------> bootm
Masahiro Yamada09b72d62014-01-16 11:05:23 +090045image data file(s)
Marian Balakowicz3310c542008-03-12 12:13:13 +010046
Andre Przywara411cf322017-04-26 01:32:37 +010047SPL usage
48---------
49
50The SPL can make use of the new image format as well, this traditionally
51is used to ship multiple device tree files within one image. Code in the SPL
52will choose the one matching the current board and append this to the
53U-Boot proper binary to be automatically used up by it.
54Aside from U-Boot proper and one device tree blob the SPL can load multiple,
55arbitrary image files as well. These binaries should be specified in their
56own subnode under the /images node, which should then be referenced from one or
57multiple /configurations subnodes. The required images must be enumerated in
58the "loadables" property as a list of strings.
59
60If a platform specific image source file (.its) is shipped with the U-Boot
61source, it can be specified using the CONFIG_SPL_FIT_SOURCE Kconfig symbol.
62In this case it will be automatically used by U-Boot's Makefile to generate
63the image.
64If a static source file is not flexible enough, CONFIG_SPL_FIT_GENERATOR
65can point to a script which generates this image source file during
66the build process. It gets passed a list of device tree files (taken from the
67CONFIG_OF_LIST symbol).
Marian Balakowicz3310c542008-03-12 12:13:13 +010068
Michal Simekcaa7fc22020-09-03 11:24:28 +020069The SPL also records to a DT all additional images (called loadables) which are
70loaded. The information about loadables locations is passed via the DT node with
71fit-images name.
72
Simon Glassbbe285c2022-10-20 18:23:04 -060073Finally, if there are multiple xPL phases (e.g. SPL, VPL), images can be marked
74as intended for a particular phase using the 'phase' property. For example, if
75fit_image_load() is called with image_ph(IH_PHASE_SPL, IH_TYPE_FIRMWARE), then
76only the image listed into the "firmware" property where phase is set to "spl"
77will be loaded.
78
Michal Simekcaa7fc22020-09-03 11:24:28 +020079Loadables Example
80-----------------
81Consider the following case for an ARM64 platform where U-Boot runs in EL2
82started by ATF where SPL is loading U-Boot (as loadables) and ATF (as firmware).
83
84/dts-v1/;
85
86/ {
87 description = "Configuration to load ATF before U-Boot";
88
89 images {
90 uboot {
91 description = "U-Boot (64-bit)";
92 data = /incbin/("u-boot-nodtb.bin");
93 type = "firmware";
94 os = "u-boot";
95 arch = "arm64";
96 compression = "none";
97 load = <0x8 0x8000000>;
98 entry = <0x8 0x8000000>;
99 hash {
100 algo = "md5";
101 };
102 };
103 atf {
104 description = "ARM Trusted Firmware";
105 data = /incbin/("bl31.bin");
106 type = "firmware";
107 os = "arm-trusted-firmware";
108 arch = "arm64";
109 compression = "none";
110 load = <0xfffea000>;
111 entry = <0xfffea000>;
112 hash {
113 algo = "md5";
114 };
115 };
116 fdt_1 {
117 description = "zynqmp-zcu102-revA";
118 data = /incbin/("arch/arm/dts/zynqmp-zcu102-revA.dtb");
119 type = "flat_dt";
120 arch = "arm64";
121 compression = "none";
122 load = <0x100000>;
123 hash {
124 algo = "md5";
125 };
126 };
127 };
128 configurations {
129 default = "config_1";
130
131 config_1 {
132 description = "zynqmp-zcu102-revA";
133 firmware = "atf";
134 loadables = "uboot";
135 fdt = "fdt_1";
136 };
137 };
138};
139
140In this case the SPL records via fit-images DT node the information about
141loadables U-Boot image.
142
143ZynqMP> fdt addr $fdtcontroladdr
144ZynqMP> fdt print /fit-images
145fit-images {
146 uboot {
147 os = "u-boot";
148 type = "firmware";
149 size = <0x001017c8>;
150 entry = <0x00000008 0x08000000>;
151 load = <0x00000008 0x08000000>;
152 };
153};
154
155As you can see entry and load properties are 64bit wide to support loading
156images above 4GB (in past entry and load properties where just 32bit).
157
158
Marian Balakowicz3310c542008-03-12 12:13:13 +0100159Example 1 -- old-style (non-FDT) kernel booting
160-----------------------------------------------
161
162Consider a simple scenario, where a PPC Linux kernel built from sources on the
163development host is to be booted old-style (non-FDT) by U-Boot on an embedded
164target. Assume that the outcome of the build is vmlinux.bin.gz, a file which
165contains a gzip-compressed PPC Linux kernel (the only data file in this case).
Bartlomiej Sieka43142e82008-03-20 23:10:19 +0100166The uImage can be produced using the image source file
167doc/uImage.FIT/kernel.its (note that kernel.its assumes that vmlinux.bin.gz is
168in the current working directory; if desired, an alternative path can be
169specified in the kernel.its file). Here's how to create the image and inspect
170its contents:
Marian Balakowicz3310c542008-03-12 12:13:13 +0100171
172[on the host system]
173$ mkimage -f kernel.its kernel.itb
174DTC: dts->dtb on file "kernel.its"
175$
176$ mkimage -l kernel.itb
177FIT description: Simple image with single Linux kernel
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100178Created: Tue Mar 11 17:26:15 2008
Andre Przywara83840402017-12-04 02:05:07 +0000179 Image 0 (kernel)
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100180 Description: Vanilla Linux kernel
181 Type: Kernel Image
182 Compression: gzip compressed
183 Data Size: 943347 Bytes = 921.24 kB = 0.90 MB
Marian Balakowicz3310c542008-03-12 12:13:13 +0100184 Architecture: PowerPC
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100185 OS: Linux
Marian Balakowicz3310c542008-03-12 12:13:13 +0100186 Load Address: 0x00000000
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100187 Entry Point: 0x00000000
188 Hash algo: crc32
189 Hash value: 2ae2bb40
190 Hash algo: sha1
191 Hash value: 3c200f34e2c226ddc789240cca0c59fc54a67cf4
Andre Przywara83840402017-12-04 02:05:07 +0000192 Default Configuration: 'config-1'
193 Configuration 0 (config-1)
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100194 Description: Boot Linux kernel
Andre Przywara83840402017-12-04 02:05:07 +0000195 Kernel: kernel
Marian Balakowicz3310c542008-03-12 12:13:13 +0100196
197
198The resulting image file kernel.itb can be now transferred to the target,
199inspected and booted (note that first three U-Boot commands below are shown
200for completeness -- they are part of the standard booting procedure and not
201specific to the new image format).
202
203[on the target system]
204=> print nfsargs
205nfsargs=setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:${rootpath}
206=> print addip
207addip=setenv bootargs ${bootargs} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}:${netdev}:off panic=1
208=> run nfsargs addip
209=> tftp 900000 /path/to/tftp/location/kernel.itb
Heiko Schocher48690d82010-07-20 17:45:02 +0200210Using FEC device
Marian Balakowicz3310c542008-03-12 12:13:13 +0100211TFTP from server 192.168.1.1; our IP address is 192.168.160.5
212Filename '/path/to/tftp/location/kernel.itb'.
213Load address: 0x900000
214Loading: #################################################################
215done
216Bytes transferred = 944464 (e6950 hex)
217=> iminfo
218
219## Checking Image at 00900000 ...
220 FIT image found
221 FIT description: Simple image with single Linux kernel
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100222 Created: 2008-03-11 16:26:15 UTC
Andre Przywara83840402017-12-04 02:05:07 +0000223 Image 0 (kernel)
Marian Balakowicz3310c542008-03-12 12:13:13 +0100224 Description: Vanilla Linux kernel
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100225 Type: Kernel Image
Marian Balakowicz3310c542008-03-12 12:13:13 +0100226 Compression: gzip compressed
227 Data Start: 0x009000e0
228 Data Size: 943347 Bytes = 921.2 kB
229 Architecture: PowerPC
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100230 OS: Linux
Marian Balakowicz3310c542008-03-12 12:13:13 +0100231 Load Address: 0x00000000
232 Entry Point: 0x00000000
233 Hash algo: crc32
234 Hash value: 2ae2bb40
235 Hash algo: sha1
236 Hash value: 3c200f34e2c226ddc789240cca0c59fc54a67cf4
Andre Przywara83840402017-12-04 02:05:07 +0000237 Default Configuration: 'config-1'
238 Configuration 0 (config-1)
Marian Balakowicz3310c542008-03-12 12:13:13 +0100239 Description: Boot Linux kernel
Andre Przywara83840402017-12-04 02:05:07 +0000240 Kernel: kernel
Marian Balakowicz3310c542008-03-12 12:13:13 +0100241
242=> bootm
243## Booting kernel from FIT Image at 00900000 ...
Andre Przywara83840402017-12-04 02:05:07 +0000244 Using 'config-1' configuration
245 Trying 'kernel' kernel subimage
Marian Balakowicz3310c542008-03-12 12:13:13 +0100246 Description: Vanilla Linux kernel
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100247 Type: Kernel Image
Marian Balakowicz3310c542008-03-12 12:13:13 +0100248 Compression: gzip compressed
249 Data Start: 0x009000e0
250 Data Size: 943347 Bytes = 921.2 kB
251 Architecture: PowerPC
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100252 OS: Linux
Marian Balakowicz3310c542008-03-12 12:13:13 +0100253 Load Address: 0x00000000
254 Entry Point: 0x00000000
255 Hash algo: crc32
256 Hash value: 2ae2bb40
257 Hash algo: sha1
258 Hash value: 3c200f34e2c226ddc789240cca0c59fc54a67cf4
259 Verifying Hash Integrity ... crc32+ sha1+ OK
260 Uncompressing Kernel Image ... OK
261Memory BAT mapping: BAT2=256Mb, BAT3=0Mb, residual: 0Mb
262Linux 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
263On node 0 totalpages: 65536
264zone(0): 65536 pages.
265zone(1): 0 pages.
266zone(2): 0 pages.
267Kernel 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
268Calibrating delay loop... 307.20 BogoMIPS
269
270
271Example 2 -- new-style (FDT) kernel booting
272-------------------------------------------
273
274Consider another simple scenario, where a PPC Linux kernel is to be booted
275new-style, i.e., with a FDT blob. In this case there are two prerequisite data
276files: vmlinux.bin.gz (Linux kernel) and target.dtb (FDT blob). The uImage can
Bartlomiej Sieka43142e82008-03-20 23:10:19 +0100277be 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
279the current working directory -- image source file kernel_fdt.its can be
280modified to take the files from some other location if needed):
Marian Balakowicz3310c542008-03-12 12:13:13 +0100281
282[on the host system]
283$ mkimage -f kernel_fdt.its kernel_fdt.itb
284DTC: dts->dtb on file "kernel_fdt.its"
285$
286$ mkimage -l kernel_fdt.itb
287FIT description: Simple image with single Linux kernel and FDT blob
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100288Created: Tue Mar 11 16:29:22 2008
Andre Przywara83840402017-12-04 02:05:07 +0000289 Image 0 (kernel)
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100290 Description: Vanilla Linux kernel
291 Type: Kernel Image
292 Compression: gzip compressed
293 Data Size: 1092037 Bytes = 1066.44 kB = 1.04 MB
Marian Balakowicz3310c542008-03-12 12:13:13 +0100294 Architecture: PowerPC
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100295 OS: Linux
Marian Balakowicz3310c542008-03-12 12:13:13 +0100296 Load Address: 0x00000000
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100297 Entry Point: 0x00000000
298 Hash algo: crc32
299 Hash value: 2c0cc807
300 Hash algo: sha1
301 Hash value: 264b59935470e42c418744f83935d44cdf59a3bb
Andre Przywara83840402017-12-04 02:05:07 +0000302 Image 1 (fdt-1)
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100303 Description: Flattened Device Tree blob
304 Type: Flat Device Tree
305 Compression: uncompressed
306 Data Size: 16384 Bytes = 16.00 kB = 0.02 MB
Marian Balakowicz3310c542008-03-12 12:13:13 +0100307 Architecture: PowerPC
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100308 Hash algo: crc32
309 Hash value: 0d655d71
310 Hash algo: sha1
311 Hash value: 25ab4e15cd4b8a5144610394560d9c318ce52def
Andre Przywara83840402017-12-04 02:05:07 +0000312 Default Configuration: 'conf-1'
313 Configuration 0 (conf-1)
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100314 Description: Boot Linux kernel with FDT blob
Andre Przywara83840402017-12-04 02:05:07 +0000315 Kernel: kernel
316 FDT: fdt-1
Marian Balakowicz3310c542008-03-12 12:13:13 +0100317
318
319The resulting image file kernel_fdt.itb can be now transferred to the target,
320inspected and booted:
321
322[on the target system]
323=> tftp 900000 /path/to/tftp/location/kernel_fdt.itb
Heiko Schocher48690d82010-07-20 17:45:02 +0200324Using FEC device
Marian Balakowicz3310c542008-03-12 12:13:13 +0100325TFTP from server 192.168.1.1; our IP address is 192.168.160.5
326Filename '/path/to/tftp/location/kernel_fdt.itb'.
327Load address: 0x900000
328Loading: #################################################################
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100329 ###########
Marian Balakowicz3310c542008-03-12 12:13:13 +0100330done
331Bytes transferred = 1109776 (10ef10 hex)
332=> iminfo
333
334## Checking Image at 00900000 ...
335 FIT image found
336 FIT description: Simple image with single Linux kernel and FDT blob
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100337 Created: 2008-03-11 15:29:22 UTC
Andre Przywara83840402017-12-04 02:05:07 +0000338 Image 0 (kernel)
Marian Balakowicz3310c542008-03-12 12:13:13 +0100339 Description: Vanilla Linux kernel
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100340 Type: Kernel Image
Marian Balakowicz3310c542008-03-12 12:13:13 +0100341 Compression: gzip compressed
342 Data Start: 0x009000ec
343 Data Size: 1092037 Bytes = 1 MB
344 Architecture: PowerPC
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100345 OS: Linux
Marian Balakowicz3310c542008-03-12 12:13:13 +0100346 Load Address: 0x00000000
347 Entry Point: 0x00000000
348 Hash algo: crc32
349 Hash value: 2c0cc807
350 Hash algo: sha1
351 Hash value: 264b59935470e42c418744f83935d44cdf59a3bb
Andre Przywara83840402017-12-04 02:05:07 +0000352 Image 1 (fdt-1)
Marian Balakowicz3310c542008-03-12 12:13:13 +0100353 Description: Flattened Device Tree blob
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100354 Type: Flat Device Tree
Marian Balakowicz3310c542008-03-12 12:13:13 +0100355 Compression: uncompressed
356 Data Start: 0x00a0abdc
357 Data Size: 16384 Bytes = 16 kB
358 Architecture: PowerPC
359 Hash algo: crc32
360 Hash value: 0d655d71
361 Hash algo: sha1
362 Hash value: 25ab4e15cd4b8a5144610394560d9c318ce52def
Andre Przywara83840402017-12-04 02:05:07 +0000363 Default Configuration: 'conf-1'
364 Configuration 0 (conf-1)
Marian Balakowicz3310c542008-03-12 12:13:13 +0100365 Description: Boot Linux kernel with FDT blob
Andre Przywara83840402017-12-04 02:05:07 +0000366 Kernel: kernel
367 FDT: fdt-1
Marian Balakowicz3310c542008-03-12 12:13:13 +0100368=> bootm
369## Booting kernel from FIT Image at 00900000 ...
Andre Przywara83840402017-12-04 02:05:07 +0000370 Using 'conf-1' configuration
371 Trying 'kernel' kernel subimage
Marian Balakowicz3310c542008-03-12 12:13:13 +0100372 Description: Vanilla Linux kernel
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100373 Type: Kernel Image
Marian Balakowicz3310c542008-03-12 12:13:13 +0100374 Compression: gzip compressed
375 Data Start: 0x009000ec
376 Data Size: 1092037 Bytes = 1 MB
377 Architecture: PowerPC
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100378 OS: Linux
Marian Balakowicz3310c542008-03-12 12:13:13 +0100379 Load Address: 0x00000000
380 Entry Point: 0x00000000
381 Hash algo: crc32
382 Hash value: 2c0cc807
383 Hash algo: sha1
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
Andre Przywara83840402017-12-04 02:05:07 +0000388 Using 'conf-1' configuration
389 Trying 'fdt-1' FDT blob subimage
Marian Balakowicz3310c542008-03-12 12:13:13 +0100390 Description: Flattened Device Tree blob
Wolfgang Denk438a4c12008-03-26 11:48:46 +0100391 Type: Flat Device Tree
Marian Balakowicz3310c542008-03-12 12:13:13 +0100392 Compression: uncompressed
393 Data Start: 0x00a0abdc
394 Data Size: 16384 Bytes = 16 kB
395 Architecture: PowerPC
396 Hash algo: crc32
397 Hash value: 0d655d71
398 Hash algo: sha1
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
405
406
407Example 3 -- advanced booting
408-----------------------------
409
Bartlomiej Sieka43142e82008-03-20 23:10:19 +0100410Refer to doc/uImage.FIT/multi.its for an image source file that allows more
Marian Balakowicz3310c542008-03-12 12:13:13 +0100411sophisticated booting scenarios (multiple kernels, ramdisks and fdt blobs).