xref: /OK3568_Linux_fs/u-boot/doc/uImage.FIT/howto.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunHow to use images in the new image format
2*4882a593Smuzhiyun=========================================
3*4882a593Smuzhiyun
4*4882a593SmuzhiyunAuthor: Bartlomiej Sieka <tur@semihalf.com>
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunOverview
8*4882a593Smuzhiyun--------
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunThe new uImage format allows more flexibility in handling images of various
11*4882a593Smuzhiyuntypes (kernel, ramdisk, etc.), it also enhances integrity protection of images
12*4882a593Smuzhiyunwith sha1 and md5 checksums.
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunTwo auxiliary tools are needed on the development host system in order to
15*4882a593Smuzhiyuncreate an uImage in the new format: mkimage and dtc, although only one
16*4882a593Smuzhiyun(mkimage) is invoked directly. dtc is called from within mkimage and operates
17*4882a593Smuzhiyunbehind the scenes, but needs to be present in the $PATH nevertheless. It is
18*4882a593Smuzhiyunimportant that the dtc used has support for binary includes -- refer to
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun	git://git.kernel.org/pub/scm/utils/dtc/dtc.git
21*4882a593Smuzhiyun
22*4882a593Smuzhiyunfor its latest version. mkimage (together with dtc) takes as input
23*4882a593Smuzhiyunan image source file, which describes the contents of the image and defines
24*4882a593Smuzhiyunits various properties used during booting. By convention, image source file
25*4882a593Smuzhiyunhas the ".its" extension, also, the details of its format are given in
26*4882a593Smuzhiyundoc/uImage.FIT/source_file_format.txt. The actual data that is to be included in
27*4882a593Smuzhiyunthe uImage (kernel, ramdisk, etc.) is specified in the image source file in the
28*4882a593Smuzhiyunform of paths to appropriate data files. The outcome of the image creation
29*4882a593Smuzhiyunprocess is a binary file (by convention with the ".itb" extension) that
30*4882a593Smuzhiyuncontains all the referenced data (kernel, ramdisk, etc.) and other information
31*4882a593Smuzhiyunneeded by U-Boot to handle the uImage properly. The uImage file is then
32*4882a593Smuzhiyuntransferred to the target (e.g., via tftp) and booted using the bootm command.
33*4882a593Smuzhiyun
34*4882a593SmuzhiyunTo summarize the prerequisites needed for new uImage creation:
35*4882a593Smuzhiyun- mkimage
36*4882a593Smuzhiyun- dtc (with support for binary includes)
37*4882a593Smuzhiyun- image source file (*.its)
38*4882a593Smuzhiyun- image data file(s)
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun
41*4882a593SmuzhiyunHere's a graphical overview of the image creation and booting process:
42*4882a593Smuzhiyun
43*4882a593Smuzhiyunimage source file     mkimage + dtc		  transfer to target
44*4882a593Smuzhiyun	+	     ---------------> image file --------------------> bootm
45*4882a593Smuzhiyunimage data file(s)
46*4882a593Smuzhiyun
47*4882a593SmuzhiyunSPL usage
48*4882a593Smuzhiyun---------
49*4882a593Smuzhiyun
50*4882a593SmuzhiyunThe SPL can make use of the new image format as well, this traditionally
51*4882a593Smuzhiyunis used to ship multiple device tree files within one image. Code in the SPL
52*4882a593Smuzhiyunwill choose the one matching the current board and append this to the
53*4882a593SmuzhiyunU-Boot proper binary to be automatically used up by it.
54*4882a593SmuzhiyunAside from U-Boot proper and one device tree blob the SPL can load multiple,
55*4882a593Smuzhiyunarbitrary image files as well. These binaries should be specified in their
56*4882a593Smuzhiyunown subnode under the /images node, which should then be referenced from one or
57*4882a593Smuzhiyunmultiple /configurations subnodes. The required images must be enumerated in
58*4882a593Smuzhiyunthe "loadables" property as a list of strings.
59*4882a593Smuzhiyun
60*4882a593SmuzhiyunIf a platform specific image source file (.its) is shipped with the U-Boot
61*4882a593Smuzhiyunsource, it can be specified using the CONFIG_SPL_FIT_SOURCE Kconfig symbol.
62*4882a593SmuzhiyunIn this case it will be automatically used by U-Boot's Makefile to generate
63*4882a593Smuzhiyunthe image.
64*4882a593SmuzhiyunIf a static source file is not flexible enough, CONFIG_SPL_FIT_GENERATOR
65*4882a593Smuzhiyuncan point to a script which generates this image source file during
66*4882a593Smuzhiyunthe build process. It gets passed a list of device tree files (taken from the
67*4882a593SmuzhiyunCONFIG_OF_LIST symbol).
68*4882a593Smuzhiyun
69*4882a593SmuzhiyunExample 1 -- old-style (non-FDT) kernel booting
70*4882a593Smuzhiyun-----------------------------------------------
71*4882a593Smuzhiyun
72*4882a593SmuzhiyunConsider a simple scenario, where a PPC Linux kernel built from sources on the
73*4882a593Smuzhiyundevelopment host is to be booted old-style (non-FDT) by U-Boot on an embedded
74*4882a593Smuzhiyuntarget. Assume that the outcome of the build is vmlinux.bin.gz, a file which
75*4882a593Smuzhiyuncontains a gzip-compressed PPC Linux kernel (the only data file in this case).
76*4882a593SmuzhiyunThe uImage can be produced using the image source file
77*4882a593Smuzhiyundoc/uImage.FIT/kernel.its (note that kernel.its assumes that vmlinux.bin.gz is
78*4882a593Smuzhiyunin the current working directory; if desired, an alternative path can be
79*4882a593Smuzhiyunspecified in the kernel.its file). Here's how to create the image and inspect
80*4882a593Smuzhiyunits contents:
81*4882a593Smuzhiyun
82*4882a593Smuzhiyun[on the host system]
83*4882a593Smuzhiyun$ mkimage -f kernel.its kernel.itb
84*4882a593SmuzhiyunDTC: dts->dtb  on file "kernel.its"
85*4882a593Smuzhiyun$
86*4882a593Smuzhiyun$ mkimage -l kernel.itb
87*4882a593SmuzhiyunFIT description: Simple image with single Linux kernel
88*4882a593SmuzhiyunCreated:	 Tue Mar 11 17:26:15 2008
89*4882a593Smuzhiyun Image 0 (kernel@1)
90*4882a593Smuzhiyun  Description:	Vanilla Linux kernel
91*4882a593Smuzhiyun  Type:		Kernel Image
92*4882a593Smuzhiyun  Compression:	gzip compressed
93*4882a593Smuzhiyun  Data Size:	943347 Bytes = 921.24 kB = 0.90 MB
94*4882a593Smuzhiyun  Architecture: PowerPC
95*4882a593Smuzhiyun  OS:		Linux
96*4882a593Smuzhiyun  Load Address: 0x00000000
97*4882a593Smuzhiyun  Entry Point:	0x00000000
98*4882a593Smuzhiyun  Hash algo:	crc32
99*4882a593Smuzhiyun  Hash value:	2ae2bb40
100*4882a593Smuzhiyun  Hash algo:	sha1
101*4882a593Smuzhiyun  Hash value:	3c200f34e2c226ddc789240cca0c59fc54a67cf4
102*4882a593Smuzhiyun Default Configuration: 'config@1'
103*4882a593Smuzhiyun Configuration 0 (config@1)
104*4882a593Smuzhiyun  Description:	Boot Linux kernel
105*4882a593Smuzhiyun  Kernel:	kernel@1
106*4882a593Smuzhiyun
107*4882a593Smuzhiyun
108*4882a593SmuzhiyunThe resulting image file kernel.itb can be now transferred to the target,
109*4882a593Smuzhiyuninspected and booted (note that first three U-Boot commands below are shown
110*4882a593Smuzhiyunfor completeness -- they are part of the standard booting procedure and not
111*4882a593Smuzhiyunspecific to the new image format).
112*4882a593Smuzhiyun
113*4882a593Smuzhiyun[on the target system]
114*4882a593Smuzhiyun=> print nfsargs
115*4882a593Smuzhiyunnfsargs=setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:${rootpath}
116*4882a593Smuzhiyun=> print addip
117*4882a593Smuzhiyunaddip=setenv bootargs ${bootargs} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}:${netdev}:off panic=1
118*4882a593Smuzhiyun=> run nfsargs addip
119*4882a593Smuzhiyun=> tftp 900000 /path/to/tftp/location/kernel.itb
120*4882a593SmuzhiyunUsing FEC device
121*4882a593SmuzhiyunTFTP from server 192.168.1.1; our IP address is 192.168.160.5
122*4882a593SmuzhiyunFilename '/path/to/tftp/location/kernel.itb'.
123*4882a593SmuzhiyunLoad address: 0x900000
124*4882a593SmuzhiyunLoading: #################################################################
125*4882a593Smuzhiyundone
126*4882a593SmuzhiyunBytes transferred = 944464 (e6950 hex)
127*4882a593Smuzhiyun=> iminfo
128*4882a593Smuzhiyun
129*4882a593Smuzhiyun## Checking Image at 00900000 ...
130*4882a593Smuzhiyun   FIT image found
131*4882a593Smuzhiyun   FIT description: Simple image with single Linux kernel
132*4882a593Smuzhiyun   Created:	    2008-03-11	16:26:15 UTC
133*4882a593Smuzhiyun    Image 0 (kernel@1)
134*4882a593Smuzhiyun     Description:  Vanilla Linux kernel
135*4882a593Smuzhiyun     Type:	   Kernel Image
136*4882a593Smuzhiyun     Compression:  gzip compressed
137*4882a593Smuzhiyun     Data Start:   0x009000e0
138*4882a593Smuzhiyun     Data Size:    943347 Bytes = 921.2 kB
139*4882a593Smuzhiyun     Architecture: PowerPC
140*4882a593Smuzhiyun     OS:	   Linux
141*4882a593Smuzhiyun     Load Address: 0x00000000
142*4882a593Smuzhiyun     Entry Point:  0x00000000
143*4882a593Smuzhiyun     Hash algo:    crc32
144*4882a593Smuzhiyun     Hash value:   2ae2bb40
145*4882a593Smuzhiyun     Hash algo:    sha1
146*4882a593Smuzhiyun     Hash value:   3c200f34e2c226ddc789240cca0c59fc54a67cf4
147*4882a593Smuzhiyun    Default Configuration: 'config@1'
148*4882a593Smuzhiyun    Configuration 0 (config@1)
149*4882a593Smuzhiyun     Description:  Boot Linux kernel
150*4882a593Smuzhiyun     Kernel:	   kernel@1
151*4882a593Smuzhiyun
152*4882a593Smuzhiyun=> bootm
153*4882a593Smuzhiyun## Booting kernel from FIT Image at 00900000 ...
154*4882a593Smuzhiyun   Using 'config@1' configuration
155*4882a593Smuzhiyun   Trying 'kernel@1' kernel subimage
156*4882a593Smuzhiyun     Description:  Vanilla Linux kernel
157*4882a593Smuzhiyun     Type:	   Kernel Image
158*4882a593Smuzhiyun     Compression:  gzip compressed
159*4882a593Smuzhiyun     Data Start:   0x009000e0
160*4882a593Smuzhiyun     Data Size:    943347 Bytes = 921.2 kB
161*4882a593Smuzhiyun     Architecture: PowerPC
162*4882a593Smuzhiyun     OS:	   Linux
163*4882a593Smuzhiyun     Load Address: 0x00000000
164*4882a593Smuzhiyun     Entry Point:  0x00000000
165*4882a593Smuzhiyun     Hash algo:    crc32
166*4882a593Smuzhiyun     Hash value:   2ae2bb40
167*4882a593Smuzhiyun     Hash algo:    sha1
168*4882a593Smuzhiyun     Hash value:   3c200f34e2c226ddc789240cca0c59fc54a67cf4
169*4882a593Smuzhiyun   Verifying Hash Integrity ... crc32+ sha1+ OK
170*4882a593Smuzhiyun   Uncompressing Kernel Image ... OK
171*4882a593SmuzhiyunMemory BAT mapping: BAT2=256Mb, BAT3=0Mb, residual: 0Mb
172*4882a593SmuzhiyunLinux 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
173*4882a593SmuzhiyunOn node 0 totalpages: 65536
174*4882a593Smuzhiyunzone(0): 65536 pages.
175*4882a593Smuzhiyunzone(1): 0 pages.
176*4882a593Smuzhiyunzone(2): 0 pages.
177*4882a593SmuzhiyunKernel 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
178*4882a593SmuzhiyunCalibrating delay loop... 307.20 BogoMIPS
179*4882a593Smuzhiyun
180*4882a593Smuzhiyun
181*4882a593SmuzhiyunExample 2 -- new-style (FDT) kernel booting
182*4882a593Smuzhiyun-------------------------------------------
183*4882a593Smuzhiyun
184*4882a593SmuzhiyunConsider another simple scenario, where a PPC Linux kernel is to be booted
185*4882a593Smuzhiyunnew-style, i.e., with a FDT blob. In this case there are two prerequisite data
186*4882a593Smuzhiyunfiles: vmlinux.bin.gz (Linux kernel) and target.dtb (FDT blob). The uImage can
187*4882a593Smuzhiyunbe produced using image source file doc/uImage.FIT/kernel_fdt.its like this
188*4882a593Smuzhiyun(note again, that both prerequisite data files are assumed to be present in
189*4882a593Smuzhiyunthe current working directory -- image source file kernel_fdt.its can be
190*4882a593Smuzhiyunmodified to take the files from some other location if needed):
191*4882a593Smuzhiyun
192*4882a593Smuzhiyun[on the host system]
193*4882a593Smuzhiyun$ mkimage -f kernel_fdt.its kernel_fdt.itb
194*4882a593SmuzhiyunDTC: dts->dtb  on file "kernel_fdt.its"
195*4882a593Smuzhiyun$
196*4882a593Smuzhiyun$ mkimage -l kernel_fdt.itb
197*4882a593SmuzhiyunFIT description: Simple image with single Linux kernel and FDT blob
198*4882a593SmuzhiyunCreated:	 Tue Mar 11 16:29:22 2008
199*4882a593Smuzhiyun Image 0 (kernel@1)
200*4882a593Smuzhiyun  Description:	Vanilla Linux kernel
201*4882a593Smuzhiyun  Type:		Kernel Image
202*4882a593Smuzhiyun  Compression:	gzip compressed
203*4882a593Smuzhiyun  Data Size:	1092037 Bytes = 1066.44 kB = 1.04 MB
204*4882a593Smuzhiyun  Architecture: PowerPC
205*4882a593Smuzhiyun  OS:		Linux
206*4882a593Smuzhiyun  Load Address: 0x00000000
207*4882a593Smuzhiyun  Entry Point:	0x00000000
208*4882a593Smuzhiyun  Hash algo:	crc32
209*4882a593Smuzhiyun  Hash value:	2c0cc807
210*4882a593Smuzhiyun  Hash algo:	sha1
211*4882a593Smuzhiyun  Hash value:	264b59935470e42c418744f83935d44cdf59a3bb
212*4882a593Smuzhiyun Image 1 (fdt@1)
213*4882a593Smuzhiyun  Description:	Flattened Device Tree blob
214*4882a593Smuzhiyun  Type:		Flat Device Tree
215*4882a593Smuzhiyun  Compression:	uncompressed
216*4882a593Smuzhiyun  Data Size:	16384 Bytes = 16.00 kB = 0.02 MB
217*4882a593Smuzhiyun  Architecture: PowerPC
218*4882a593Smuzhiyun  Hash algo:	crc32
219*4882a593Smuzhiyun  Hash value:	0d655d71
220*4882a593Smuzhiyun  Hash algo:	sha1
221*4882a593Smuzhiyun  Hash value:	25ab4e15cd4b8a5144610394560d9c318ce52def
222*4882a593Smuzhiyun Default Configuration: 'conf@1'
223*4882a593Smuzhiyun Configuration 0 (conf@1)
224*4882a593Smuzhiyun  Description:	Boot Linux kernel with FDT blob
225*4882a593Smuzhiyun  Kernel:	kernel@1
226*4882a593Smuzhiyun  FDT:		fdt@1
227*4882a593Smuzhiyun
228*4882a593Smuzhiyun
229*4882a593SmuzhiyunThe resulting image file kernel_fdt.itb can be now transferred to the target,
230*4882a593Smuzhiyuninspected and booted:
231*4882a593Smuzhiyun
232*4882a593Smuzhiyun[on the target system]
233*4882a593Smuzhiyun=> tftp 900000 /path/to/tftp/location/kernel_fdt.itb
234*4882a593SmuzhiyunUsing FEC device
235*4882a593SmuzhiyunTFTP from server 192.168.1.1; our IP address is 192.168.160.5
236*4882a593SmuzhiyunFilename '/path/to/tftp/location/kernel_fdt.itb'.
237*4882a593SmuzhiyunLoad address: 0x900000
238*4882a593SmuzhiyunLoading: #################################################################
239*4882a593Smuzhiyun	 ###########
240*4882a593Smuzhiyundone
241*4882a593SmuzhiyunBytes transferred = 1109776 (10ef10 hex)
242*4882a593Smuzhiyun=> iminfo
243*4882a593Smuzhiyun
244*4882a593Smuzhiyun## Checking Image at 00900000 ...
245*4882a593Smuzhiyun   FIT image found
246*4882a593Smuzhiyun   FIT description: Simple image with single Linux kernel and FDT blob
247*4882a593Smuzhiyun   Created:	    2008-03-11	15:29:22 UTC
248*4882a593Smuzhiyun    Image 0 (kernel@1)
249*4882a593Smuzhiyun     Description:  Vanilla Linux kernel
250*4882a593Smuzhiyun     Type:	   Kernel Image
251*4882a593Smuzhiyun     Compression:  gzip compressed
252*4882a593Smuzhiyun     Data Start:   0x009000ec
253*4882a593Smuzhiyun     Data Size:    1092037 Bytes =  1 MB
254*4882a593Smuzhiyun     Architecture: PowerPC
255*4882a593Smuzhiyun     OS:	   Linux
256*4882a593Smuzhiyun     Load Address: 0x00000000
257*4882a593Smuzhiyun     Entry Point:  0x00000000
258*4882a593Smuzhiyun     Hash algo:    crc32
259*4882a593Smuzhiyun     Hash value:   2c0cc807
260*4882a593Smuzhiyun     Hash algo:    sha1
261*4882a593Smuzhiyun     Hash value:   264b59935470e42c418744f83935d44cdf59a3bb
262*4882a593Smuzhiyun    Image 1 (fdt@1)
263*4882a593Smuzhiyun     Description:  Flattened Device Tree blob
264*4882a593Smuzhiyun     Type:	   Flat Device Tree
265*4882a593Smuzhiyun     Compression:  uncompressed
266*4882a593Smuzhiyun     Data Start:   0x00a0abdc
267*4882a593Smuzhiyun     Data Size:    16384 Bytes = 16 kB
268*4882a593Smuzhiyun     Architecture: PowerPC
269*4882a593Smuzhiyun     Hash algo:    crc32
270*4882a593Smuzhiyun     Hash value:   0d655d71
271*4882a593Smuzhiyun     Hash algo:    sha1
272*4882a593Smuzhiyun     Hash value:   25ab4e15cd4b8a5144610394560d9c318ce52def
273*4882a593Smuzhiyun    Default Configuration: 'conf@1'
274*4882a593Smuzhiyun    Configuration 0 (conf@1)
275*4882a593Smuzhiyun     Description:  Boot Linux kernel with FDT blob
276*4882a593Smuzhiyun     Kernel:	   kernel@1
277*4882a593Smuzhiyun     FDT:	   fdt@1
278*4882a593Smuzhiyun=> bootm
279*4882a593Smuzhiyun## Booting kernel from FIT Image at 00900000 ...
280*4882a593Smuzhiyun   Using 'conf@1' configuration
281*4882a593Smuzhiyun   Trying 'kernel@1' kernel subimage
282*4882a593Smuzhiyun     Description:  Vanilla Linux kernel
283*4882a593Smuzhiyun     Type:	   Kernel Image
284*4882a593Smuzhiyun     Compression:  gzip compressed
285*4882a593Smuzhiyun     Data Start:   0x009000ec
286*4882a593Smuzhiyun     Data Size:    1092037 Bytes =  1 MB
287*4882a593Smuzhiyun     Architecture: PowerPC
288*4882a593Smuzhiyun     OS:	   Linux
289*4882a593Smuzhiyun     Load Address: 0x00000000
290*4882a593Smuzhiyun     Entry Point:  0x00000000
291*4882a593Smuzhiyun     Hash algo:    crc32
292*4882a593Smuzhiyun     Hash value:   2c0cc807
293*4882a593Smuzhiyun     Hash algo:    sha1
294*4882a593Smuzhiyun     Hash value:   264b59935470e42c418744f83935d44cdf59a3bb
295*4882a593Smuzhiyun   Verifying Hash Integrity ... crc32+ sha1+ OK
296*4882a593Smuzhiyun   Uncompressing Kernel Image ... OK
297*4882a593Smuzhiyun## Flattened Device Tree from FIT Image at 00900000
298*4882a593Smuzhiyun   Using 'conf@1' configuration
299*4882a593Smuzhiyun   Trying 'fdt@1' FDT blob subimage
300*4882a593Smuzhiyun     Description:  Flattened Device Tree blob
301*4882a593Smuzhiyun     Type:	   Flat Device Tree
302*4882a593Smuzhiyun     Compression:  uncompressed
303*4882a593Smuzhiyun     Data Start:   0x00a0abdc
304*4882a593Smuzhiyun     Data Size:    16384 Bytes = 16 kB
305*4882a593Smuzhiyun     Architecture: PowerPC
306*4882a593Smuzhiyun     Hash algo:    crc32
307*4882a593Smuzhiyun     Hash value:   0d655d71
308*4882a593Smuzhiyun     Hash algo:    sha1
309*4882a593Smuzhiyun     Hash value:   25ab4e15cd4b8a5144610394560d9c318ce52def
310*4882a593Smuzhiyun   Verifying Hash Integrity ... crc32+ sha1+ OK
311*4882a593Smuzhiyun   Booting using the fdt blob at 0xa0abdc
312*4882a593Smuzhiyun   Loading Device Tree to 007fc000, end 007fffff ... OK
313*4882a593Smuzhiyun[    0.000000] Using lite5200 machine description
314*4882a593Smuzhiyun[    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
315*4882a593Smuzhiyun
316*4882a593Smuzhiyun
317*4882a593SmuzhiyunExample 3 -- advanced booting
318*4882a593Smuzhiyun-----------------------------
319*4882a593Smuzhiyun
320*4882a593SmuzhiyunRefer to doc/uImage.FIT/multi.its for an image source file that allows more
321*4882a593Smuzhiyunsophisticated booting scenarios (multiple kernels, ramdisks and fdt blobs).
322