scripts: Fix to not skip some option parameters for rpi4 fusing script
[platform/kernel/u-boot.git] / doc / mkimage.1
1 .\" SPDX-License-Identifier: GPL-2.0
2 .\" Copyright (C) 2022 Sean Anderson <seanga2@gmail.com>
3 .\" Copyright (C) 2013-20 Simon Glass <sjg@chromium.org>
4 .\" Copyright (C) 2010 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
5 .\" Copyright (C) 2010 Wolfgang Denk <wd@denx.de>
6 .TH MKIMAGE 1 2022-06-11 U-Boot
7 .
8 .SH NAME
9 mkimage \- generate images for U-Boot
10 .SH SYNOPSIS
11 .SY mkimage
12 .OP \-T type
13 .BI \-l\~ image-file-name
14 .YS
15 .
16 .SY mkimage
17 .RI [ option\~ .\|.\|.\&]
18 .OP \-T type
19 .I image-file-name
20 .YS
21 .
22 .SY mkimage
23 .RI [ option\~ .\|.\|.\&]
24 .BI \-f\~ image-tree-source-file\c
25 .RB | auto
26 .I image-file-name
27 .YS
28 .
29 .SY mkimage
30 .RI [ option\~ .\|.\|.\&]
31 .BI \-F\~ image-file-name
32 .YS
33 .
34 .SH DESCRIPTION
35 The
36 .B mkimage
37 command is used to create images for use with the U-Boot boot loader.  These
38 images can contain the Linux kernel, device tree blob, root file system image,
39 firmware images etc., either separate or combined.
40 .P
41 .B mkimage
42 supports many image formats. Some of these formats may be used by embedded boot
43 firmware to load U-Boot. Others may be used by U-Boot to load Linux (or some
44 other kernel):
45 .P
46 The legacy image format concatenates the individual parts (for example, kernel
47 image, device tree blob and ramdisk image) and adds a 64 byte header containing
48 information about the target architecture, operating system, image type,
49 compression method, entry points, time stamp, checksums, etc.
50 .P
51 The new
52 .I FIT
53 (Flattened Image Tree) format allows for more flexibility in handling images of
54 various types and also enhances integrity protection of images with stronger
55 checksums. It also supports verified boot.
56 .
57 .SH OPTIONS
58 .
59 .SS General options
60 .
61 .TP
62 .B \-h
63 .TQ
64 .B \-\-help
65 Print a help message and exit.
66 .
67 .TP
68 .B \-l
69 .TQ
70 .B \-\-list
71 .B mkimage
72 lists the information contained in the header of an existing U-Boot image.
73 .
74 .TP
75 .B \-s
76 .TQ
77 .B \-\-no\-copy
78 Don't copy in the image data. Depending on the image type, this may create
79 just the header, everything but the image data, or nothing at all.
80 .
81 .TP
82 .BI \-T " image-type"
83 .TQ
84 .BI \-\-type " image-type"
85 Parse image file as
86 .IR image-type .
87 Pass
88 .B list
89 as
90 .I image-type
91 to see the list of supported image types. If this option is absent, then it
92 defaults to
93 .B kernel
94 (legacy image). If this option is absent when
95 .B \-l
96 is passed, then
97 .B mkimage
98 will attempt to automatically detect the image type. Not all image types support
99 automatic detection, so it may be necessary to pass
100 .B \-T
101 explicitly.
102 .IP
103 When creating a FIT image with
104 .BR \-f ,
105 the image type is always set to
106 .BR flat_dt .
107 In this case,
108 .B \-T
109 specifies the image node's \(oqtype\(cq property. If
110 .B \-T
111 is absent, then the \(oqtype\(cq property will default to
112 .BR kernel .
113 .
114 .TP
115 .B \-q
116 .TQ
117 .B \-\-quiet
118 Quiet. Don't print the image header.
119 .
120 .TP
121 .B \-v
122 .TQ
123 .B \-\-verbose
124 Verbose. Print file names as they are added to the image.
125 .
126 .TP
127 .B \-V
128 .TQ
129 .B \-\-version
130 Print version information and exit.
131 .
132 .SS General image-creation options
133 .
134 .TP
135 .BI \-A " architecture"
136 .TQ
137 .BI \-\-architecture " architecture"
138 Set the architecture. Pass
139 .B \-h
140 as the architecture to see the list of supported architectures. If
141 .B \-A
142 is absent, it defaults to
143 .BR ppc .
144 .
145 .TP
146 .BI \-O " os"
147 .TQ
148 .BI \-\-os " os"
149 Set the operating system. The U-Boot
150 .I bootm
151 command changes boot method based on the OS type.
152 Pass
153 .B \-h
154 as the
155 .I os
156 to see the list of supported OSs. If
157 .B \-O
158 is absent, it defaults to
159 .BR linux .
160 .
161 .TP
162 .BI \-C " compression-type"
163 .TQ
164 .BI \-\-compression " compression-type"
165 Set the compression type. The image data should have already been compressed
166 using this compression type.
167 .B mkimage
168 will not automatically compress image data.
169 Pass
170 .B \-h
171 as the
172 .I compression-type
173 to see the list of supported compression types. If
174 .B \-C
175 is absent, it defaults to
176 .BR gzip .
177 .
178 .TP
179 .BI \-a " load-address"
180 .TQ
181 .BI \-\-load\-address " load-address"
182 Set the absolute address to load the image data to.
183 .I load-address
184 will be interpreted as a hexadecimal number.
185 .
186 .TP
187 .BI \-e " entry-point"
188 .TQ
189 .BI \-\-entry\-point " entry-point"
190 Set the absolute address of the image entry point. The U-Boot
191 .I bootm
192 command will jump to this address after loading the image.
193 .I entry-point
194 will be interpreted as a hexadecimal number.
195 .
196 .TP
197 .BI \-n " primary-configuration"
198 .TQ
199 .BI \-\-config " primary-configuration"
200 Images may require additional configuration not specified with other options,
201 often in a image-type-specific format. The image types which support this
202 option and the format of their configuration are listed in
203 .BR CONFIGURATION .
204 .
205 .TP
206 .BI \-R " secondary-configuration"
207 .TQ
208 .BI \-\-secondary\-config " secondary-configuration"
209 Some image types support a second set of configuration data. The image types
210 which support secondary configuration and the formap of their configuration are
211 listed in
212 .BR CONFIGURATION .
213 .
214 .TP
215 .BI \-d " image-data-file"
216 .TQ
217 .BI \-\-image " image-data-file"
218 Use image data from
219 .IR image-data-file .
220 If the
221 .I image-type
222 is
223 .BR multi ,
224 then multiple images may be specified, separated by colons:
225 .RS
226 .IP
227 .IR image-data-file [\fB:\fP image-data-file .\|.\|.]
228 .RE
229 .
230 .TP
231 .B \-x
232 .TQ
233 .B \-\-xip
234 Set the
235 .I XIP
236 (execute in place) flag. The U-Boot
237 .I bootm
238 command will not load the image data, and instead will assume it is already
239 accessible at the load address (such as via memory-mapped flash).
240 .
241 .SS Options for creating FIT images
242 .
243 .TP
244 .BI \-b " device-tree-file"
245 .TQ
246 .BI \-\-device\-tree " device-tree-file"
247 Appends the device tree binary file (.dtb) to the FIT.
248 .
249 .TP
250 .BI \-c " comment"
251 .TQ
252 .BI \-\-comment " comment"
253 Specifies a comment to be added when signing. This is typically a message which
254 describes how the image was signed or some other useful information.
255 .
256 .TP
257 .BI \-D " dtc-options"
258 .TQ
259 .BI \-\-dtcopts " dtc-options"
260 Provide additional options to the device tree compiler when creating the image.
261 See
262 .BR dtc (1)
263 for documentation of possible options. If
264 .B \-D
265 is absent, it defaults to
266 .BR "\-I dts \-O dtb \-p 500" .
267 .
268 .TP
269 .BI \-E
270 .TQ
271 .BI \-\-external
272 After processing, move the image data outside the FIT and store a data offset
273 in the FIT. Images will be placed one after the other immediately after the FIT,
274 with each one aligned to a 4-byte boundary. The existing \(oqdata\(cq property
275 in each image will be replaced with \(oqdata-offset\(cq and \(oqdata-size\(cq
276 properties.  A \(oqdata-offset\(cq of 0 indicates that it starts in the first
277 (4-byte-aligned) byte after the FIT.
278 .
279 .TP
280 .BI \-B " alignment"
281 .TQ
282 .BI \-\-alignment " alignment"
283 The alignment, in hexadecimal, that external data will be aligned to. This
284 option only has an effect when \-E is specified.
285 .
286 .TP
287 .BI \-p " external-position"
288 .TQ
289 .BI \-\-position " external-position"
290 Place external data at a static external position. Instead of writing a
291 \(oqdata-offset\(cq property defining the offset from the end of the FIT,
292 .B \-p
293 will use \(oqdata-position\(cq as the absolute position from the base of the
294 FIT. See
295 .B \-E
296 for details on using external data.
297 .
298 .TP
299 \fB\-f \fIimage-tree-source-file\fR | \fBauto
300 .TQ
301 \fB\-\-fit \fIimage-tree-source-file\fR | \fBauto
302 Image tree source file that describes the structure and contents of the
303 FIT image.
304 .IP
305 In some simple cases, the image tree source can be generated automatically. To
306 use this feature, pass
307 .BR "\-f auto" .
308 The
309 .BR \-d ,
310 .BR \-A ,
311 .BR \-O ,
312 .BR \-T ,
313 .BR \-C ,
314 .BR \-a ,
315 and
316 .B \-e
317 options may be used to specify the image to include in the FIT and its
318 attributes. No
319 .I image-tree-source-file
320 is required.
321 .
322 .TP
323 .B \-F
324 .TQ
325 .B \-\-update
326 Indicates that an existing FIT image should be modified. No dtc compilation will
327 be performed and
328 .B \-f
329 should not be passed. This can be used to sign images with additional keys
330 after initial image creation.
331 .
332 .TP
333 .BI \-i " ramdisk-file"
334 .TQ
335 .BI \-\-initramfs " ramdisk-file"
336 Append a ramdisk or initramfs file to the image.
337 .
338 .TP
339 .BI \-k " key-directory"
340 .TQ
341 .BI \-\-key\-dir " key-directory"
342 Specifies the directory containing keys to use for signing. This directory
343 should contain a private key file
344 .IR name .key
345 for use with signing, and a certificate
346 .IR name .crt
347 (containing the public key) for use with verification. The public key is only
348 necessary when embedding it into another device tree using
349 .BR \-K .
350 .I name
351 defaults to the value of the signature node's \(oqkey-name-hint\(cq property,
352 but may be overridden using
353 .BR \-g .
354 .
355 .TP
356 .BI \-G " key-file"
357 .TQ
358 .BI \-\-key\-file " key-file"
359 Specifies the private key file to use when signing. This option may be used
360 instead of \-k.
361 .
362 .TP
363 .BI \-K " key-destination"
364 .TQ
365 .BI \-\-key\-dest " key-destination"
366 Specifies a compiled device tree binary file (typically .dtb) to write
367 public key information into. When a private key is used to sign an image,
368 the corresponding public key is written into this file for for run-time
369 verification. Typically the file here is the device tree binary used by
370 CONFIG_OF_CONTROL in U-Boot.
371 .
372 .TP
373 .BI \-g " key-name-hint"
374 .TQ
375 .BI \-\-key\-name\-hint " key-name-hint"
376 Overrides the signature node's \(oqkey-name-hint\(cq property. This is
377 especially useful when signing an image with
378 .BR "\-f auto" .
379 This is the
380 .I name
381 part of the key. The directory part is set by
382 .BR \-k .
383 This option also indicates that the images included in the FIT should be signed.
384 If this option is specified, then
385 .B \-o
386 must be specified as well.
387 .
388 .TP
389 .BI \-o " crypto" , checksum
390 .TQ
391 .BI \-\-algo " crypto" , checksum
392 Specifies the algorithm to be used for signing a FIT image. The default is
393 taken from the signature node's \(oqalgo\(cq property.
394 The valid values for
395 .I crypto
396 are:
397 .RS
398 .IP
399 .TS
400 lb.
401 rsa2048
402 rsa3072
403 rsa4096
404 ecdsa256
405 .TE
406 .RE
407 .IP
408 The valid values for
409 .I checksum
410 are
411 .RS
412 .IP
413 .TS
414 lb.
415 sha1
416 sha256
417 sha384
418 sha512
419 .TE
420 .RE
421 .
422 .TP
423 .B \-r
424 .TQ
425 .B \-\-key\-required
426 Specifies that keys used to sign the FIT are required. This means that they
427 must be verified for the image to boot. Without this option, the verification
428 will be optional (useful for testing but not for release).
429 .
430 .TP
431 .BI \-N " engine"
432 .TQ
433 .BI \-\-engine " engine"
434 The openssl engine to use when signing and verifying the image. For a complete
435 list of available engines, refer to
436 .BR engine (1).
437 .
438 .TP
439 .B \-t
440 .TQ
441 .B \-\-touch
442 Update the timestamp in the FIT.
443 .IP
444 Normally the FIT timestamp is created the first time mkimage runs,
445 when converting the source .its to the binary .fit file. This corresponds to
446 using
447 .BR -f .
448 But if the original input to mkimage is a binary file (already compiled), then
449 the timestamp is assumed to have been set previously.
450 .
451 .SH CONFIGURATION
452 This section documents the formats of the primary and secondary configuration
453 options for each image type which supports them.
454 .
455 .SS aisimage
456 The primary configuration is a file containing a series of
457 .I AIS
458 (Application Image Script) commands, one per line. Each command has the form
459 .RS
460 .P
461 .IR "command argument " .\|.\|.
462 .RE
463 .P
464 See
465 .UR https://\:www\:.ti\:.com/\:lit/\:pdf/\:spraag0
466 TI application report SPRAAG0E
467 .UE
468 for details.
469 .
470 .SS atmelimage
471 The primary configuration is a comma-separated list of NAND Flash parameters of
472 the form
473 .RS
474 .P
475 \fIparameter\fB=\fIvalue\fR[\fB,\fIparameter\fB=\fIvalue\fR.\|.\|.\&]
476 .RE
477 .P
478 Valid
479 .IR parameter s
480 are
481 .RS
482 .P
483 .TS
484 lb.
485 usePmecc
486 nbSectorPerPage
487 spareSize
488 eccBitReq
489 sectorSize
490 eccOffset
491 .TE
492 .RE
493 .P
494 and valid
495 .IR value s
496 are decimal numbers. See section 11.4.4.1 of the SAMA5D3 Series Data Sheet for
497 valid values for each parameter.
498 .
499 .SS imximage
500 The primary configuration is a file containing configuration commands, as
501 documented in doc/\:imx/\:mkimage/\:imximage.txt of the U-Boot source.
502 .
503 .SS imx8image and imx8mimage
504 The primary configuration is a file containing configuration commands, as
505 documented in doc/\:imx/\:mkimage/\:imx8image.txt of the U-Boot source.
506 .
507 .SS kwbimage
508 The primary configuration is a file containing configuration commands, as
509 documented in doc/\:imx/\:mkimage/\:kwbimage.txt of the U-Boot source.
510 .
511 .SS mtk_image
512 The primary configuration is a semicolon-separated list of header options of the
513 form
514 .RS
515 .P
516 \fIkey\fB=\fIvalue\fR[\fB;\fIkey\fB=\fIvalue\fR.\|.\|.\&]
517 .RE
518 .P
519 where the valid keys are:
520 .RS
521 .P
522 .TS
523 lb lbx
524 lb l.
525 Key     Description
526 _
527 lk      T{
528 If \fB1\fP, then an \fILK\fP (legacy) image header is used. Otherwise, a
529 \fIBootROM\fP image header is used.
530 T}
531 lkname  T{
532 The name of the LK image header. The maximum length is 32 ASCII characters. If
533 not specified, the default value is \fBU-Boot\fP.
534 T}
535 media   The boot device. See below for valid values.
536 nandinfo        The desired NAND device type. See below for valid values.
537 arm64   If \fB1\fP, then this denotes an AArch64 image.
538 hdroffset       Increase the reported size of the BRLYT header by this amount.
539 .TE
540 .RE
541 .P
542 Valid values for
543 .B media
544 are:
545 .RS
546 .P
547 .TS
548 lb lb
549 lb l.
550 Value   Description
551 _
552 nand    Parallel NAND flash
553 snand   Serial NAND flash
554 nor     Serial NOR flash
555 emmc    \fIeMMC\fP (Embedded Multi-Media Card)
556 sdmmc   \fISD\fP (Secure Digital) card
557 .TE
558 .RE
559 .P
560 Valid values for
561 .B nandinfo
562 are:
563 .RS
564 .P
565 .TS
566 lb lb lb        lb      lb
567 lb l    l       l       l.
568 Value   NAND type       Page size       OOB size        Total size
569 _
570 2k+64   Serial  2KiB    64B
571 2k+120  Serial  2KiB    120B
572 2k+128  Serial  2KiB    128B
573 4k+256  Serial  4KiB    256B
574 1g:2k+64        Parallel        2KiB    64B     1Gbit
575 2g:2k+64        Parallel        2KiB    64B     2Gbit
576 4g:2k+64        Parallel        2KiB    64B     4Gbit
577 2g:2k+128       Parallel        2KiB    128B    2Gbit
578 4g:2k+128       Parallel        2KiB    128B    4Gbit
579 .TE
580 .RE
581 .
582 .SS mxsimage
583 The primary configuration is a file containing configuration commands, as
584 documented in doc/\:imx/\:mkimage/\:mxsimage.txt of the U-Boot source.
585 .
586 .SS omapimage
587 The primary configuration is the optional value
588 .BR byteswap .
589 If present, each 32-bit word of the image will have its bytes swapped
590 (converting from little-endian to big-endian, or vice versa).
591 .
592 .SS pblimage
593 The primary configuration is a file containing the
594 .I PBI
595 (Pre-Boot Image) header. Each line of the configuration has the format
596 .RS
597 .P
598 .IR value "[ " value .\|.\|.\&]
599 .RE
600 .P
601 Where
602 .I value
603 is a 32-bit hexadecimal integer. Each
604 .I value
605 will, after being converted to raw bytes, be literally prepended to the PBI.
606 .P
607 The secondary configuration is a file with the same format as the primary
608 configuration file. It will be inserted into the image after the primary
609 configuration data and before the image data.
610 .P
611 It is traditional to use the primary configuration file for the
612 .I RCW
613 (Reset Configuration Word), and the secondary configuration file for any
614 additional PBI commands. However, it is also possible to convert an existing PBI
615 to the above format and \(lqchain\(rq additional data onto the end of the
616 image. This may be especially useful for creating secure boot images.
617 .
618 .SS rkimage
619 The primary configuration is the name of the processor to generate the image
620 for. Valid values are:
621 .RS
622 .P
623 .TS
624 lb.
625 px30
626 rk3036
627 rk3066
628 rk3128
629 rk3188
630 rk322x
631 rk3288
632 rk3308
633 rk3328
634 rk3368
635 rk3399
636 rv1108
637 rk3568
638 .TE
639 .RE
640 .
641 .SS sunxi_egon
642 The primary configuration is the name to use for the device tree.
643 .
644 .SS ublimage
645 The primary configuration is a file containing configuration commands, as
646 documented in doc/\:README.ublimage of the U-Boot source.
647 .
648 .SS zynqimage and zynqmpimage
649 For
650 .BR zynqmpimage ,
651 the primary configuration is a file containing the
652 .I PMUFW
653 (Power Management Unit Firmware).
654 .B zynqimage
655 does not use the primary configuration.
656 .P
657 For both image types, the secondary configuration is a file containinig
658 initialization parameters, one per line. Each parameter has the form
659 .RS
660 .P
661 .I address data
662 .RE
663 .P
664 where
665 .I address
666 and
667 .I data
668 are hexadecimal integers. The boot ROM will write each
669 .I data
670 to
671 .I address
672 when loading the image. At most 256 parameters may be specified in this
673 manner.
674 .
675 .SH BUGS
676 Please report bugs to the
677 .UR https://\:source\:.denx\:.de/\:u-boot/\:u-boot/\:issues
678 U-Boot bug tracker
679 .UE .
680 .SH EXAMPLES
681 .\" Reduce the width of the tab stops to something reasonable
682 .ta T 1i
683 List image information:
684 .RS
685 .P
686 .EX
687 \fBmkimage \-l uImage
688 .EE
689 .RE
690 .P
691 Create legacy image with compressed PowerPC Linux kernel:
692 .RS
693 .P
694 .EX
695 \fBmkimage \-A powerpc \-O linux \-T kernel \-C gzip \\
696         \-a 0 \-e 0 \-n Linux \-d vmlinux.gz uImage
697 .EE
698 .RE
699 .P
700 Create FIT image with compressed PowerPC Linux kernel:
701 .RS
702 .P
703 .EX
704 \fBmkimage \-f kernel.its kernel.itb
705 .EE
706 .RE
707 .P
708 Create FIT image with compressed kernel and sign it with keys in the
709 /public/signing\-keys directory. Add corresponding public keys into u\-boot.dtb,
710 skipping those for which keys cannot be found. Also add a comment.
711 .RS
712 .P
713 .EX
714 \fBmkimage \-f kernel.its \-k /public/signing\-keys \-K u\-boot.dtb \\
715         \-c \(dqKernel 3.8 image for production devices\(dq kernel.itb
716 .EE
717 .RE
718 .P
719 Add public keys to u\-boot.dtb without needing a FIT to sign. This will also
720 create a FIT containing an images node with no data named unused.itb.
721 .RS
722 .P
723 .EX
724 \fBmkimage \-f auto \-d /dev/null \-k /public/signing\-keys \-g dev \\
725         \-o sha256,rsa2048 \-K u\-boot.dtb unused.itb
726 .EE
727 .RE
728 .P
729 Update an existing FIT image, signing it with additional keys.
730 Add corresponding public keys into u\-boot.dtb. This will resign all images
731 with keys that are available in the new directory. Images that request signing
732 with unavailable keys are skipped.
733 .RS
734 .P
735 .EX
736 \fBmkimage \-F \-k /secret/signing\-keys \-K u\-boot.dtb \\
737         \-c \(dqKernel 3.8 image for production devices\(dq kernel.itb
738 .EE
739 .RE
740 .P
741 Create a FIT image containing a kernel, using automatic mode. No .its file
742 is required.
743 .RS
744 .P
745 .EX
746 \fBmkimage \-f auto \-A arm \-O linux \-T kernel \-C none \-a 43e00000 \-e 0 \\
747         \-c \(dqKernel 4.4 image for production devices\(dq \-d vmlinuz kernel.itb
748 .EE
749 .RE
750 .P
751 Create a FIT image containing a kernel and some device tree files, using
752 automatic mode. No .its file is required.
753 .RS
754 .P
755 .EX
756 \fBmkimage \-f auto \-A arm \-O linux \-T kernel \-C none \-a 43e00000 \-e 0 \\
757         \-c \(dqKernel 4.4 image for production devices\(dq \-d vmlinuz \\
758         \-b /path/to/rk3288\-firefly.dtb \-b /path/to/rk3288\-jerry.dtb kernel.itb
759 .EE
760 .RE
761 .P
762 Create a FIT image containing a signed kernel, using automatic mode. No .its
763 file is required.
764 .RS
765 .P
766 .EX
767 \fBmkimage \-f auto \-A arm \-O linux \-T kernel \-C none \-a 43e00000 \-e 0 \\
768         \-d vmlinuz \-k /secret/signing\-keys \-g dev \-o sha256,rsa2048 kernel.itb
769 .EE
770 .RE
771 .
772 .SH SEE ALSO
773 .BR dtc (1),
774 .BR dumpimage (1),
775 .BR openssl (1),
776 the\~
777 .UR https://\:u-boot\:.readthedocs\:.io/\:en/\:latest/\:index.html
778 U-Boot documentation
779 .UE