blob: e27377342a155759efd24ce2b411c32596535c04 [file] [log] [blame]
Simon Glassc44aa612023-06-23 13:22:04 +01001.. SPDX-License-Identifier: GPL-2.0+
2
Bin Meng75574052016-02-05 19:30:11 -08003U-Boot new uImage source file format (bindings definition)
Marian Balakowicz18710b82008-03-12 12:13:13 +01004==========================================================
5
Simon Glass47e37332023-06-23 13:22:03 +01006Introduction
7------------
Marian Balakowicz18710b82008-03-12 12:13:13 +01008
9Evolution of the 2.6 Linux kernel for embedded PowerPC systems introduced new
10booting method which requires that hardware description is available to the
11kernel in the form of Flattened Device Tree.
12
13Booting with a Flattened Device Tree is much more flexible and is intended to
14replace direct passing of 'struct bd_info' which was used to boot pre-FDT
15kernels.
16
Bin Meng75574052016-02-05 19:30:11 -080017However, U-Boot needs to support both techniques to provide backward
Marian Balakowicz18710b82008-03-12 12:13:13 +010018compatibility for platforms which are not FDT ready. Number of elements
19playing role in the booting process has increased and now includes the FDT
20blob. Kernel image, FDT blob and possibly ramdisk image - all must be placed
21in the system memory and passed to bootm as a arguments. Some of them may be
22missing: FDT is not present for legacy platforms, ramdisk is always optional.
23Additionally, old uImage format has been extended to support multi sub-images
24but the support is limited by simple format of the legacy uImage structure.
Simon Glassbb7d3bb2022-09-06 20:26:52 -060025Single binary header 'struct legacy_img_hdr' is not flexible enough to cover all
Marian Balakowicz18710b82008-03-12 12:13:13 +010026possible scenarios.
27
28All those factors combined clearly show that there is a need for new, more
29flexible, multi component uImage format.
30
31
Simon Glass47e37332023-06-23 13:22:03 +010032New uImage format assumptions
33-----------------------------
Marian Balakowicz18710b82008-03-12 12:13:13 +010034
Simon Glass47e37332023-06-23 13:22:03 +010035Implementation
36~~~~~~~~~~~~~~
Marian Balakowicz18710b82008-03-12 12:13:13 +010037
38Libfdt has been selected for the new uImage format implementation as (1) it
39provides needed functionality, (2) is actively maintained and developed and
Bin Meng75574052016-02-05 19:30:11 -080040(3) increases code reuse as it is already part of the U-Boot source tree.
Marian Balakowicz18710b82008-03-12 12:13:13 +010041
Simon Glass47e37332023-06-23 13:22:03 +010042Terminology
43~~~~~~~~~~~
Marian Balakowicz18710b82008-03-12 12:13:13 +010044
45This document defines new uImage structure by providing FDT bindings for new
Bin Meng75574052016-02-05 19:30:11 -080046uImage internals. Bindings are defined from U-Boot perspective, i.e. describe
47final form of the uImage at the moment when it reaches U-Boot. User
Marian Balakowicz18710b82008-03-12 12:13:13 +010048perspective may be simpler, as some of the properties (like timestamps and
Bin Meng75574052016-02-05 19:30:11 -080049hashes) will need to be filled in automatically by the U-Boot mkimage tool.
Marian Balakowicz18710b82008-03-12 12:13:13 +010050
51To avoid confusion with the kernel FDT the following naming convention is
52proposed for the new uImage format related terms:
53
Simon Glass47e37332023-06-23 13:22:03 +010054FIT
55 Flattened uImage Tree
Marian Balakowicz18710b82008-03-12 12:13:13 +010056
57FIT is formally a flattened device tree (in the libfdt meaning), which
58conforms to bindings defined in this document.
59
Simon Glass47e37332023-06-23 13:22:03 +010060.its
61 image tree source
Marian Balakowicz18710b82008-03-12 12:13:13 +010062
Simon Glass47e37332023-06-23 13:22:03 +010063.itb
64 flattened image tree blob
65
66Image building procedure
67~~~~~~~~~~~~~~~~~~~~~~~~
Marian Balakowicz18710b82008-03-12 12:13:13 +010068
69The following picture shows how the new uImage is prepared. Input consists of
70image source file (.its) and a set of data files. Image is created with the
Bin Meng75574052016-02-05 19:30:11 -080071help of standard U-Boot mkimage tool which in turn uses dtc (device tree
Masahiro Yamada89af9302013-09-13 20:28:21 +090072compiler) to produce image tree blob (.itb). Resulting .itb file is the
Simon Glassa37a8f22023-06-23 13:22:02 +010073actual binary of a new uImage::
Marian Balakowicz18710b82008-03-12 12:13:13 +010074
Simon Glassa37a8f22023-06-23 13:22:02 +010075 tqm5200.its
76 +
77 vmlinux.bin.gz mkimage + dtc xfer to target
78 eldk-4.2-ramdisk --------------> tqm5200.itb --------------> bootm
79 tqm5200.dtb /|\
80 |
81 'new uImage'
Marian Balakowicz18710b82008-03-12 12:13:13 +010082
Simon Glass47e37332023-06-23 13:22:03 +010083Steps:
84
85#. Create .its file, automatically filled-in properties are omitted
86
87#. Call mkimage tool on a .its file
88
89#. mkimage calls dtc to create .itb image and assures that
90 missing properties are added
91
92#. .itb (new uImage) is uploaded onto the target and used therein
Marian Balakowicz18710b82008-03-12 12:13:13 +010093
94
Simon Glass47e37332023-06-23 13:22:03 +010095Unique identifiers
96~~~~~~~~~~~~~~~~~~
Marian Balakowicz18710b82008-03-12 12:13:13 +010097
98To identify FIT sub-nodes representing images, hashes, configurations (which
99are defined in the following sections), the "unit name" of the given sub-node
100is used as it's identifier as it assures uniqueness without additional
101checking required.
102
103
Simon Glass47e37332023-06-23 13:22:03 +0100104Root node properties
105--------------------
Marian Balakowicz18710b82008-03-12 12:13:13 +0100106
Simon Glassa37a8f22023-06-23 13:22:02 +0100107Root node of the uImage Tree should have the following layout::
Marian Balakowicz18710b82008-03-12 12:13:13 +0100108
Simon Glassa37a8f22023-06-23 13:22:02 +0100109 / o image-tree
110 |- description = "image description"
111 |- timestamp = <12399321>
112 |- #address-cells = <1>
113 |
114 o images
115 | |
116 | o image-1 {...}
117 | o image-2 {...}
118 | ...
119 |
120 o configurations
121 |- default = "conf-1"
122 |
123 o conf-1 {...}
124 o conf-2 {...}
125 ...
Marian Balakowicz18710b82008-03-12 12:13:13 +0100126
Simon Glass47e37332023-06-23 13:22:03 +0100127Optional property
128~~~~~~~~~~~~~~~~~
Marian Balakowicz18710b82008-03-12 12:13:13 +0100129
Simon Glass47e37332023-06-23 13:22:03 +0100130description
131 Textual description of the uImage
132
133Mandatory property
134~~~~~~~~~~~~~~~~~~
135
136timestamp
137 Last image modification time being counted in seconds since
Marian Balakowicz18710b82008-03-12 12:13:13 +0100138 1970-01-01 00:00:00 - to be automatically calculated by mkimage tool.
139
Simon Glass47e37332023-06-23 13:22:03 +0100140Conditionally mandatory property
141~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
142
143#address-cells
144 Number of 32bit cells required to represent entry and
Marian Balakowicz18710b82008-03-12 12:13:13 +0100145 load addresses supplied within sub-image nodes. May be omitted when no
146 entry or load addresses are used.
147
Simon Glass47e37332023-06-23 13:22:03 +0100148Mandatory nodes
149~~~~~~~~~~~~~~~
150
151images
152 This node contains a set of sub-nodes, each of them representing
Marian Balakowicz18710b82008-03-12 12:13:13 +0100153 single component sub-image (like kernel, ramdisk, etc.). At least one
154 sub-image is required.
Simon Glass47e37332023-06-23 13:22:03 +0100155
156configurations
157 Contains a set of available configuration nodes and
Marian Balakowicz18710b82008-03-12 12:13:13 +0100158 defines a default configuration.
159
160
Simon Glass47e37332023-06-23 13:22:03 +0100161'/images' node
162--------------
Marian Balakowicz18710b82008-03-12 12:13:13 +0100163
164This node is a container node for component sub-image nodes. Each sub-node of
Simon Glassa37a8f22023-06-23 13:22:02 +0100165the '/images' node should have the following layout::
Marian Balakowicz18710b82008-03-12 12:13:13 +0100166
Simon Glassa37a8f22023-06-23 13:22:02 +0100167 o image-1
168 |- description = "component sub-image description"
169 |- data = /incbin/("path/to/data/file.bin")
170 |- type = "sub-image type name"
171 |- arch = "ARCH name"
172 |- os = "OS name"
173 |- compression = "compression name"
174 |- load = <00000000>
175 |- entry = <00000000>
176 |
177 o hash-1 {...}
178 o hash-2 {...}
179 ...
Marian Balakowicz18710b82008-03-12 12:13:13 +0100180
Simon Glass47e37332023-06-23 13:22:03 +0100181Mandatory properties
182~~~~~~~~~~~~~~~~~~~~
183
184description
185 Textual description of the component sub-image
186
187type
188 Name of component sub-image type, supported types are:
189
Tom Rini96496f82017-07-18 14:14:19 -0400190 "standalone", "kernel", "kernel_noload", "ramdisk", "firmware", "script",
191 "filesystem", "flat_dt" and others (see uimage_type in common/image.c).
Simon Glass47e37332023-06-23 13:22:03 +0100192
193data
194 Path to the external file which contains this node's binary data.
195
196compression
197 Compression used by included data. Supported compressions
Marian Balakowicz18710b82008-03-12 12:13:13 +0100198 are "gzip" and "bzip2". If no compression is used compression property
Simon Goldschmidt9fded7b2018-07-30 12:53:18 +0200199 should be set to "none". If the data is compressed but it should not be
200 uncompressed by U-Boot (e.g. compressed ramdisk), this should also be set
201 to "none".
Marian Balakowicz18710b82008-03-12 12:13:13 +0100202
Simon Glass47e37332023-06-23 13:22:03 +0100203Conditionally mandatory property
204~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
205
206os
207 OS name, mandatory for types "kernel". Valid OS names are:
Alexandru Gagniuc5638c5f2020-12-15 13:15:43 -0600208 "openbsd", "netbsd", "freebsd", "4_4bsd", "linux", "svr4", "esix",
Guilherme Maciel Ferreira5e398312015-01-15 02:37:33 -0200209 "solaris", "irix", "sco", "dell", "ncr", "lynxos", "vxworks", "psos", "qnx",
Sean Anderson075757d2020-08-07 13:13:31 -0400210 "u-boot", "rtems", "unity", "integrity".
Simon Glass47e37332023-06-23 13:22:03 +0100211
212arch
213 Architecture name, mandatory for types: "standalone", "kernel",
Marian Balakowicz18710b82008-03-12 12:13:13 +0100214 "firmware", "ramdisk" and "fdt". Valid architecture names are: "alpha",
215 "arm", "i386", "ia64", "mips", "mips64", "ppc", "s390", "sh", "sparc",
Simon Glass750d66c2014-10-19 21:11:23 -0600216 "sparc64", "m68k", "microblaze", "nios2", "blackfin", "avr32", "st200",
217 "sandbox".
Simon Glass47e37332023-06-23 13:22:03 +0100218
219entry
220 entry point address, address size is determined by
Alexandru Gagniuc5638c5f2020-12-15 13:15:43 -0600221 '#address-cells' property of the root node.
222 Mandatory for types: "firmware", and "kernel".
Simon Glass47e37332023-06-23 13:22:03 +0100223
224load
225 load address, address size is determined by '#address-cells'
Alexandru Gagniuc5638c5f2020-12-15 13:15:43 -0600226 property of the root node.
227 Mandatory for types: "firmware", and "kernel".
Simon Glass47e37332023-06-23 13:22:03 +0100228
229compatible
230 compatible method for loading image.
Alexandru Gagniuc5638c5f2020-12-15 13:15:43 -0600231 Mandatory for types: "fpga", and images that do not specify a load address.
Oleksandr Suvorov17773572022-07-22 17:16:13 +0300232 Supported compatible methods:
Simon Glass47e37332023-06-23 13:22:03 +0100233
234 "u-boot,fpga-legacy"
235 the generic fpga loading routine.
236
237 "u-boot,zynqmp-fpga-ddrauth"
238 signed non-encrypted FPGA bitstream for
239 Xilinx Zynq UltraScale+ (ZymqMP) device.
240
241 "u-boot,zynqmp-fpga-enc"
242 encrypted FPGA bitstream for Xilinx Zynq
243
Adrian Fiergolski0d6bb432022-07-22 17:16:14 +0300244 UltraScale+ (ZynqMP) device.
Simon Glass47e37332023-06-23 13:22:03 +0100245
246phase
247 U-Boot phase for which the image is intended.
248
249 "spl"
250 image is an SPL image
251
252 "u-boot"
253 image is a U-Boot image
254
255Optional nodes:
Marian Balakowicz18710b82008-03-12 12:13:13 +0100256
Simon Glass47e37332023-06-23 13:22:03 +0100257hash-1
258 Each hash sub-node represents separate hash or checksum
Marian Balakowicz18710b82008-03-12 12:13:13 +0100259 calculated for node's data according to specified algorithm.
260
261
Simon Glass47e37332023-06-23 13:22:03 +0100262Hash nodes
263----------
Marian Balakowicz18710b82008-03-12 12:13:13 +0100264
Simon Glassa37a8f22023-06-23 13:22:02 +0100265::
266
267 o hash-1
268 |- algo = "hash or checksum algorithm name"
269 |- value = [hash or checksum value]
Marian Balakowicz18710b82008-03-12 12:13:13 +0100270
Simon Glass47e37332023-06-23 13:22:03 +0100271Mandatory properties
272~~~~~~~~~~~~~~~~~~~~
273
274algo
275 Algorithm name, supported are "crc32", "md5" and "sha1".
276
277value
278 Actual checksum or hash value, correspondingly 4, 16 or 20 bytes long.
Marian Balakowicz18710b82008-03-12 12:13:13 +0100279
280
Simon Glass47e37332023-06-23 13:22:03 +0100281'/configurations' node
282----------------------
Marian Balakowicz18710b82008-03-12 12:13:13 +0100283
Alexandru Gagniuc5638c5f2020-12-15 13:15:43 -0600284The 'configurations' node creates convenient, labeled boot configurations,
285which combine together kernel images with their ramdisks and fdt blobs.
Marian Balakowicz18710b82008-03-12 12:13:13 +0100286
Simon Glassa37a8f22023-06-23 13:22:02 +0100287The 'configurations' node has the following structure::
Marian Balakowicz18710b82008-03-12 12:13:13 +0100288
Simon Glassa37a8f22023-06-23 13:22:02 +0100289 o configurations
290 |- default = "default configuration sub-node unit name"
291 |
292 o config-1 {...}
293 o config-2 {...}
294 ...
Marian Balakowicz18710b82008-03-12 12:13:13 +0100295
296
Simon Glass47e37332023-06-23 13:22:03 +0100297Optional property
298~~~~~~~~~~~~~~~~~
Marian Balakowicz18710b82008-03-12 12:13:13 +0100299
Simon Glass47e37332023-06-23 13:22:03 +0100300default
301 Selects one of the configuration sub-nodes as a default configuration.
Marian Balakowicz18710b82008-03-12 12:13:13 +0100302
Simon Glass47e37332023-06-23 13:22:03 +0100303Mandatory nodes
304~~~~~~~~~~~~~~~
Marian Balakowicz18710b82008-03-12 12:13:13 +0100305
Simon Glass47e37332023-06-23 13:22:03 +0100306configuration-sub-node-unit-name
307 At least one of the configuration sub-nodes is required.
308
309
310Configuration nodes
311-------------------
Marian Balakowicz18710b82008-03-12 12:13:13 +0100312
Simon Glassa37a8f22023-06-23 13:22:02 +0100313Each configuration has the following structure::
Marian Balakowicz18710b82008-03-12 12:13:13 +0100314
Simon Glassa37a8f22023-06-23 13:22:02 +0100315 o config-1
316 |- description = "configuration description"
317 |- kernel = "kernel sub-node unit name"
318 |- fdt = "fdt sub-node unit-name" [, "fdt overlay sub-node unit-name", ...]
319 |- loadables = "loadables sub-node unit-name"
320 |- script = "
321 |- compatible = "vendor,board-style device tree compatible string"
Marian Balakowicz18710b82008-03-12 12:13:13 +0100322
Simon Glass47e37332023-06-23 13:22:03 +0100323
324Mandatory properties
325~~~~~~~~~~~~~~~~~~~~
326
327description
328 Textual configuration description.
Marian Balakowicz18710b82008-03-12 12:13:13 +0100329
Simon Glass47e37332023-06-23 13:22:03 +0100330kernel or firmware
331 Unit name of the corresponding kernel or firmware
Alexandru Gagniuc5638c5f2020-12-15 13:15:43 -0600332 (u-boot, op-tee, etc) image. If both "kernel" and "firmware" are specified,
333 control is passed to the firmware image.
Marian Balakowicz18710b82008-03-12 12:13:13 +0100334
Simon Glass47e37332023-06-23 13:22:03 +0100335Optional properties
336~~~~~~~~~~~~~~~~~~~
337
338fdt
339 Unit name of the corresponding fdt blob (component image node of a
Pantelis Antonioub2256522017-09-04 23:12:17 +0300340 "fdt type"). Additional fdt overlay nodes can be supplied which signify
341 that the resulting device tree blob is generated by the first base fdt
342 blob with all subsequent overlays applied.
Simon Glass47e37332023-06-23 13:22:03 +0100343
344fpga
345 Unit name of the corresponding fpga bitstream blob
Michal Simek0a130b12016-05-17 13:58:44 +0200346 (component image node of a "fpga type").
Simon Glass47e37332023-06-23 13:22:03 +0100347
348loadables
349 Unit name containing a list of additional binaries to be
Karl Apsite8f0537d2015-05-21 09:52:47 -0400350 loaded at their given locations. "loadables" is a comma-separated list
Andrew F. Davis28b28f72016-11-29 16:33:20 -0600351 of strings. U-Boot will load each binary at its given start-address and
Thomas Hebbfd37f242019-11-13 18:18:03 -0800352 may optionally invoke additional post-processing steps on this binary based
Andrew F. Davis28b28f72016-11-29 16:33:20 -0600353 on its component image node type.
Simon Glass47e37332023-06-23 13:22:03 +0100354
355script
356 The image to use when loading a U-Boot script (for use with the
Sean Andersond3e7e202022-12-12 14:12:11 -0500357 source command).
Simon Glass47e37332023-06-23 13:22:03 +0100358
359compatible
360 The root compatible string of the U-Boot device tree that
Julius Werner4e823522019-07-24 19:37:56 -0700361 this configuration shall automatically match when CONFIG_FIT_BEST_MATCH is
362 enabled. If this property is not provided, the compatible string will be
363 extracted from the fdt blob instead. This is only possible if the fdt is
364 not compressed, so images with compressed fdts that want to use compatible
365 string matching must always provide this property.
Marian Balakowicz18710b82008-03-12 12:13:13 +0100366
367The FDT blob is required to properly boot FDT based kernel, so the minimal
368configuration for 2.6 FDT kernel is (kernel, fdt) pair.
369
370Older, 2.4 kernel and 2.6 non-FDT kernel do not use FDT blob, in such cases
371'struct bd_info' must be passed instead of FDT blob, thus fdt property *must
372not* be specified in a configuration node.
373
374
Simon Glass47e37332023-06-23 13:22:03 +0100375External data
376-------------
Simon Glassafd728c2016-02-22 22:55:53 -0700377
378The above format shows a 'data' property which holds the data for each image.
379It is also possible for this data to reside outside the FIT itself. This
380allows the FIT to be quite small, so that it can be loaded and scanned
381without loading a large amount of data. Then when an image is needed it can
382be loaded from an external source.
383
384In this case the 'data' property is omitted. Instead you can use:
385
Simon Glass47e37332023-06-23 13:22:03 +0100386data-offset
387 offset of the data in a separate image store. The image
Simon Glassafd728c2016-02-22 22:55:53 -0700388 store is placed immediately after the last byte of the device tree binary,
389 aligned to a 4-byte boundary.
Simon Glass47e37332023-06-23 13:22:03 +0100390
Simon Glassc44aa612023-06-23 13:22:04 +0100391data-size
392 size of the data in bytes
Simon Glassafd728c2016-02-22 22:55:53 -0700393
Teddy Reeda8457622016-06-09 19:38:02 -0700394The 'data-offset' property can be substituted with 'data-position', which
395defines an absolute position or address as the offset. This is helpful when
Peng Fan8876c7e2017-12-05 13:20:59 +0800396booting U-Boot proper before performing relocation. Pass '-p [offset]' to
397mkimage to enable 'data-position'.
Simon Glassafd728c2016-02-22 22:55:53 -0700398
York Sunadf99fa2017-08-15 11:14:44 -0700399Normal kernel FIT image has data embedded within FIT structure. U-Boot image
400for SPL boot has external data. Existence of 'data-offset' can be used to
401identify which format is used.
402
Kever Yang8e238b52020-03-30 11:56:24 +0800403For FIT image with external data, it would be better to align each blob of data
404to block(512 byte) for block device, so that we don't need to do the copy when
405read the image data in SPL. Pass '-B 0x200' to mkimage to align the FIT
406structure and data to 512 byte, other values available for other align size.
407
Simon Glass47e37332023-06-23 13:22:03 +0100408Examples
409--------
Marian Balakowicz18710b82008-03-12 12:13:13 +0100410
Simon Glassc44aa612023-06-23 13:22:04 +0100411Some example files are available here, showing various scenarios
412
413.. toctree::
414 :maxdepth: 1
415
416 kernel
417 kernel_fdt
418 kernel_fdts_compressed
419 kernel
420 multi
421 multi_spl
422 multi-with-fpga
423 multi-with-loadables
424 sec_firmware_ppa
425 sign-configs
426 sign-images
427 uefi
428 update3
429 update_uboot
Simon Glass47e37332023-06-23 13:22:03 +0100430
431.. sectionauthor:: Marian Balakowicz <m8@semihalf.com>
432.. sectionauthor:: External data additions, 25/1/16 Simon Glass <sjg@chromium.org>