wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1 | /* |
Bartlomiej Sieka | d7816fb | 2008-03-11 12:34:47 +0100 | [diff] [blame] | 2 | * (C) Copyright 2008 Semihalf |
| 3 | * |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 4 | * (C) Copyright 2000-2009 |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 5 | * DENX Software Engineering |
| 6 | * Wolfgang Denk, wd@denx.de |
wdenk | db82c8e | 2004-02-26 23:01:04 +0000 | [diff] [blame] | 7 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 8 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
Marian Balakowicz | 41d71ed | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 11 | #include "mkimage.h" |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 12 | #include <image.h> |
Wolfgang Denk | e97ab72 | 2011-02-12 10:37:11 +0100 | [diff] [blame] | 13 | #include <version.h> |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 14 | |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 15 | static void copy_file(int, const char *, int); |
| 16 | static void usage(void); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 17 | |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 18 | /* parameters initialized by core will be used by the image type code */ |
Guilherme Maciel Ferreira | 8ed4d1c | 2013-12-01 12:43:10 -0700 | [diff] [blame] | 19 | struct image_tool_params params = { |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 20 | .os = IH_OS_LINUX, |
| 21 | .arch = IH_ARCH_PPC, |
| 22 | .type = IH_TYPE_KERNEL, |
| 23 | .comp = IH_COMP_GZIP, |
| 24 | .dtc = MKIMAGE_DEFAULT_DTC_OPTIONS, |
Wolfgang Denk | 23416b8 | 2010-03-27 23:37:46 +0100 | [diff] [blame] | 25 | .imagename = "", |
Shaohui Xie | ea65fd8 | 2012-08-10 02:49:35 +0000 | [diff] [blame] | 26 | .imagename2 = "", |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 27 | }; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 28 | |
Simon Glass | 434a31b | 2015-06-23 15:38:25 -0600 | [diff] [blame] | 29 | static int h_compare_image_name(const void *vtype1, const void *vtype2) |
| 30 | { |
| 31 | const int *type1 = vtype1; |
| 32 | const int *type2 = vtype2; |
| 33 | const char *name1 = genimg_get_type_short_name(*type1); |
| 34 | const char *name2 = genimg_get_type_short_name(*type2); |
| 35 | |
| 36 | return strcmp(name1, name2); |
| 37 | } |
| 38 | |
| 39 | /* Show all image types supported by mkimage */ |
| 40 | static void show_image_types(void) |
| 41 | { |
| 42 | struct image_type_params *tparams; |
| 43 | int order[IH_TYPE_COUNT]; |
| 44 | int count; |
| 45 | int type; |
| 46 | int i; |
| 47 | |
| 48 | /* Sort the names in order of short name for easier reading */ |
| 49 | memset(order, '\0', sizeof(order)); |
| 50 | for (count = 0, type = 0; type < IH_TYPE_COUNT; type++) { |
| 51 | tparams = imagetool_get_type(type); |
| 52 | if (tparams) |
| 53 | order[count++] = type; |
| 54 | } |
| 55 | qsort(order, count, sizeof(int), h_compare_image_name); |
| 56 | |
| 57 | fprintf(stderr, "\nInvalid image type. Supported image types:\n"); |
| 58 | for (i = 0; i < count; i++) { |
| 59 | type = order[i]; |
| 60 | tparams = imagetool_get_type(type); |
| 61 | if (tparams) { |
| 62 | fprintf(stderr, "\t%-15s %s\n", |
| 63 | genimg_get_type_short_name(type), |
| 64 | genimg_get_type_name(type)); |
| 65 | } |
| 66 | } |
| 67 | fprintf(stderr, "\n"); |
| 68 | } |
| 69 | |
Simon Glass | 7106bd4 | 2016-02-22 22:55:33 -0700 | [diff] [blame^] | 70 | static void process_args(int argc, char **argv) |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 71 | { |
Peter Tyser | 632d9ca | 2010-04-04 22:36:03 -0500 | [diff] [blame] | 72 | char *ptr; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 73 | |
| 74 | while (--argc > 0 && **++argv == '-') { |
| 75 | while (*++*argv) { |
| 76 | switch (**argv) { |
| 77 | case 'l': |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 78 | params.lflag = 1; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 79 | break; |
| 80 | case 'A': |
| 81 | if ((--argc <= 0) || |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 82 | (params.arch = |
| 83 | genimg_get_arch_id (*++argv)) < 0) |
Simon Glass | 7106bd4 | 2016-02-22 22:55:33 -0700 | [diff] [blame^] | 84 | usage(); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 85 | goto NXTARG; |
Simon Glass | bf27d3d | 2013-06-13 15:10:06 -0700 | [diff] [blame] | 86 | case 'c': |
| 87 | if (--argc <= 0) |
| 88 | usage(); |
| 89 | params.comment = *++argv; |
| 90 | goto NXTARG; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 91 | case 'C': |
| 92 | if ((--argc <= 0) || |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 93 | (params.comp = |
| 94 | genimg_get_comp_id (*++argv)) < 0) |
Simon Glass | 7106bd4 | 2016-02-22 22:55:33 -0700 | [diff] [blame^] | 95 | usage(); |
Bartlomiej Sieka | d7816fb | 2008-03-11 12:34:47 +0100 | [diff] [blame] | 96 | goto NXTARG; |
| 97 | case 'D': |
| 98 | if (--argc <= 0) |
Simon Glass | 7106bd4 | 2016-02-22 22:55:33 -0700 | [diff] [blame^] | 99 | usage(); |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 100 | params.dtc = *++argv; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 101 | goto NXTARG; |
Bartlomiej Sieka | d7816fb | 2008-03-11 12:34:47 +0100 | [diff] [blame] | 102 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 103 | case 'O': |
| 104 | if ((--argc <= 0) || |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 105 | (params.os = |
| 106 | genimg_get_os_id (*++argv)) < 0) |
Simon Glass | 7106bd4 | 2016-02-22 22:55:33 -0700 | [diff] [blame^] | 107 | usage(); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 108 | goto NXTARG; |
| 109 | case 'T': |
Simon Glass | 434a31b | 2015-06-23 15:38:25 -0600 | [diff] [blame] | 110 | params.type = -1; |
| 111 | if (--argc >= 0 && argv[1]) { |
| 112 | params.type = |
| 113 | genimg_get_type_id(*++argv); |
| 114 | } |
| 115 | if (params.type < 0) { |
| 116 | show_image_types(); |
| 117 | usage(); |
| 118 | } |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 119 | goto NXTARG; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 120 | case 'a': |
| 121 | if (--argc <= 0) |
Simon Glass | 7106bd4 | 2016-02-22 22:55:33 -0700 | [diff] [blame^] | 122 | usage(); |
William Cohen | a4e80c5 | 2016-02-16 08:57:46 -0500 | [diff] [blame] | 123 | params.addr = strtoull(*++argv, &ptr, 16); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 124 | if (*ptr) { |
| 125 | fprintf (stderr, |
| 126 | "%s: invalid load address %s\n", |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 127 | params.cmdname, *argv); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 128 | exit (EXIT_FAILURE); |
| 129 | } |
| 130 | goto NXTARG; |
| 131 | case 'd': |
| 132 | if (--argc <= 0) |
Simon Glass | 7106bd4 | 2016-02-22 22:55:33 -0700 | [diff] [blame^] | 133 | usage(); |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 134 | params.datafile = *++argv; |
| 135 | params.dflag = 1; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 136 | goto NXTARG; |
| 137 | case 'e': |
| 138 | if (--argc <= 0) |
Simon Glass | 7106bd4 | 2016-02-22 22:55:33 -0700 | [diff] [blame^] | 139 | usage(); |
William Cohen | a4e80c5 | 2016-02-16 08:57:46 -0500 | [diff] [blame] | 140 | params.ep = strtoull(*++argv, &ptr, 16); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 141 | if (*ptr) { |
| 142 | fprintf (stderr, |
| 143 | "%s: invalid entry point %s\n", |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 144 | params.cmdname, *argv); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 145 | exit (EXIT_FAILURE); |
| 146 | } |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 147 | params.eflag = 1; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 148 | goto NXTARG; |
Bartlomiej Sieka | d7816fb | 2008-03-11 12:34:47 +0100 | [diff] [blame] | 149 | case 'f': |
| 150 | if (--argc <= 0) |
Simon Glass | 7106bd4 | 2016-02-22 22:55:33 -0700 | [diff] [blame^] | 151 | usage(); |
Simon Glass | ce8c3ca | 2013-06-13 15:10:05 -0700 | [diff] [blame] | 152 | params.datafile = *++argv; |
| 153 | /* no break */ |
| 154 | case 'F': |
Peter Tyser | 94734e6 | 2009-11-24 16:42:08 -0600 | [diff] [blame] | 155 | /* |
| 156 | * The flattened image tree (FIT) format |
| 157 | * requires a flattened device tree image type |
| 158 | */ |
| 159 | params.type = IH_TYPE_FLATDT; |
Peter Tyser | 54cd539 | 2009-12-06 01:33:24 -0600 | [diff] [blame] | 160 | params.fflag = 1; |
Bartlomiej Sieka | d7816fb | 2008-03-11 12:34:47 +0100 | [diff] [blame] | 161 | goto NXTARG; |
Simon Glass | b148974 | 2013-06-13 15:10:03 -0700 | [diff] [blame] | 162 | case 'k': |
| 163 | if (--argc <= 0) |
| 164 | usage(); |
| 165 | params.keydir = *++argv; |
| 166 | goto NXTARG; |
Simon Glass | b4d8b09 | 2013-06-13 15:10:04 -0700 | [diff] [blame] | 167 | case 'K': |
| 168 | if (--argc <= 0) |
| 169 | usage(); |
| 170 | params.keydest = *++argv; |
| 171 | goto NXTARG; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 172 | case 'n': |
| 173 | if (--argc <= 0) |
Simon Glass | 7106bd4 | 2016-02-22 22:55:33 -0700 | [diff] [blame^] | 174 | usage(); |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 175 | params.imagename = *++argv; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 176 | goto NXTARG; |
Simon Glass | 817278a | 2013-06-13 15:10:07 -0700 | [diff] [blame] | 177 | case 'r': |
| 178 | params.require_keys = 1; |
| 179 | break; |
Shaohui Xie | ea65fd8 | 2012-08-10 02:49:35 +0000 | [diff] [blame] | 180 | case 'R': |
| 181 | if (--argc <= 0) |
| 182 | usage(); |
| 183 | /* |
| 184 | * This entry is for the second configuration |
| 185 | * file, if only one is not enough. |
| 186 | */ |
| 187 | params.imagename2 = *++argv; |
| 188 | goto NXTARG; |
Stefano Babic | 4a96330 | 2011-09-15 23:50:16 +0000 | [diff] [blame] | 189 | case 's': |
| 190 | params.skipcpy = 1; |
| 191 | break; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 192 | case 'v': |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 193 | params.vflag++; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 194 | break; |
Wolfgang Denk | e97ab72 | 2011-02-12 10:37:11 +0100 | [diff] [blame] | 195 | case 'V': |
| 196 | printf("mkimage version %s\n", PLAIN_VERSION); |
| 197 | exit(EXIT_SUCCESS); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 198 | case 'x': |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 199 | params.xflag++; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 200 | break; |
| 201 | default: |
Simon Glass | 7106bd4 | 2016-02-22 22:55:33 -0700 | [diff] [blame^] | 202 | usage(); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 203 | } |
| 204 | } |
| 205 | NXTARG: ; |
| 206 | } |
| 207 | |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 208 | if (argc != 1) |
Simon Glass | 7106bd4 | 2016-02-22 22:55:33 -0700 | [diff] [blame^] | 209 | usage(); |
| 210 | params.imagefile = *argv; |
| 211 | } |
| 212 | |
| 213 | |
| 214 | int main(int argc, char **argv) |
| 215 | { |
| 216 | int ifd = -1; |
| 217 | struct stat sbuf; |
| 218 | char *ptr; |
| 219 | int retval = 0; |
| 220 | struct image_type_params *tparams = NULL; |
| 221 | int pad_len = 0; |
| 222 | int dfd; |
| 223 | |
| 224 | params.cmdname = *argv; |
| 225 | params.addr = 0; |
| 226 | params.ep = 0; |
| 227 | |
| 228 | process_args(argc, argv); |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 229 | |
| 230 | /* set tparams as per input type_id */ |
Guilherme Maciel Ferreira | 28be1cf | 2015-01-15 02:48:07 -0200 | [diff] [blame] | 231 | tparams = imagetool_get_type(params.type); |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 232 | if (tparams == NULL) { |
| 233 | fprintf (stderr, "%s: unsupported type %s\n", |
| 234 | params.cmdname, genimg_get_type_name(params.type)); |
| 235 | exit (EXIT_FAILURE); |
| 236 | } |
| 237 | |
| 238 | /* |
| 239 | * check the passed arguments parameters meets the requirements |
| 240 | * as per image type to be generated/listed |
| 241 | */ |
| 242 | if (tparams->check_params) |
| 243 | if (tparams->check_params (¶ms)) |
Simon Glass | 7106bd4 | 2016-02-22 22:55:33 -0700 | [diff] [blame^] | 244 | usage(); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 245 | |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 246 | if (!params.eflag) { |
| 247 | params.ep = params.addr; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 248 | /* If XIP, entry point must be after the U-Boot header */ |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 249 | if (params.xflag) |
| 250 | params.ep += tparams->header_size; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 251 | } |
| 252 | |
Peter Tyser | b2f8b94 | 2009-11-24 16:42:10 -0600 | [diff] [blame] | 253 | if (params.fflag){ |
| 254 | if (tparams->fflag_handle) |
| 255 | /* |
| 256 | * in some cases, some additional processing needs |
| 257 | * to be done if fflag is defined |
| 258 | * |
| 259 | * For ex. fit_handle_file for Fit file support |
| 260 | */ |
| 261 | retval = tparams->fflag_handle(¶ms); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 262 | |
Peter Tyser | b2f8b94 | 2009-11-24 16:42:10 -0600 | [diff] [blame] | 263 | if (retval != EXIT_SUCCESS) |
| 264 | exit (retval); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 265 | } |
| 266 | |
Peter Tyser | b2f8b94 | 2009-11-24 16:42:10 -0600 | [diff] [blame] | 267 | if (params.lflag || params.fflag) { |
| 268 | ifd = open (params.imagefile, O_RDONLY|O_BINARY); |
| 269 | } else { |
| 270 | ifd = open (params.imagefile, |
| 271 | O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0666); |
| 272 | } |
| 273 | |
| 274 | if (ifd < 0) { |
| 275 | fprintf (stderr, "%s: Can't open %s: %s\n", |
| 276 | params.cmdname, params.imagefile, |
| 277 | strerror(errno)); |
| 278 | exit (EXIT_FAILURE); |
| 279 | } |
| 280 | |
| 281 | if (params.lflag || params.fflag) { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 282 | /* |
| 283 | * list header information of existing image |
| 284 | */ |
| 285 | if (fstat(ifd, &sbuf) < 0) { |
| 286 | fprintf (stderr, "%s: Can't stat %s: %s\n", |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 287 | params.cmdname, params.imagefile, |
| 288 | strerror(errno)); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 289 | exit (EXIT_FAILURE); |
| 290 | } |
| 291 | |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 292 | if ((unsigned)sbuf.st_size < tparams->header_size) { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 293 | fprintf (stderr, |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 294 | "%s: Bad size: \"%s\" is not valid image\n", |
| 295 | params.cmdname, params.imagefile); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 296 | exit (EXIT_FAILURE); |
| 297 | } |
| 298 | |
Mike Frysinger | cd7e1a3 | 2008-05-01 04:13:05 -0400 | [diff] [blame] | 299 | ptr = mmap(0, sbuf.st_size, PROT_READ, MAP_SHARED, ifd, 0); |
| 300 | if (ptr == MAP_FAILED) { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 301 | fprintf (stderr, "%s: Can't read %s: %s\n", |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 302 | params.cmdname, params.imagefile, |
| 303 | strerror(errno)); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 304 | exit (EXIT_FAILURE); |
| 305 | } |
| 306 | |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 307 | /* |
| 308 | * scan through mkimage registry for all supported image types |
| 309 | * and verify the input image file header for match |
| 310 | * Print the image information for matched image type |
| 311 | * Returns the error code if not matched |
| 312 | */ |
Guilherme Maciel Ferreira | 0b33803 | 2015-01-15 02:48:05 -0200 | [diff] [blame] | 313 | retval = imagetool_verify_print_header(ptr, &sbuf, |
| 314 | tparams, ¶ms); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 315 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 316 | (void) munmap((void *)ptr, sbuf.st_size); |
| 317 | (void) close (ifd); |
| 318 | |
Prafulla Wadaskar | 139cb08 | 2009-08-10 18:49:37 +0530 | [diff] [blame] | 319 | exit (retval); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 320 | } |
| 321 | |
Marek Vasut | 4cc8627 | 2015-12-07 18:01:54 +0100 | [diff] [blame] | 322 | if ((params.type != IH_TYPE_MULTI) && (params.type != IH_TYPE_SCRIPT)) { |
Philippe De Swert | 3edd041 | 2015-12-04 00:11:23 +0200 | [diff] [blame] | 323 | dfd = open(params.datafile, O_RDONLY | O_BINARY); |
| 324 | if (dfd < 0) { |
| 325 | fprintf(stderr, "%s: Can't open %s: %s\n", |
| 326 | params.cmdname, params.datafile, |
| 327 | strerror(errno)); |
| 328 | exit(EXIT_FAILURE); |
| 329 | } |
Simon Glass | 139651f | 2015-06-23 15:39:12 -0600 | [diff] [blame] | 330 | |
Philippe De Swert | 3edd041 | 2015-12-04 00:11:23 +0200 | [diff] [blame] | 331 | if (fstat(dfd, &sbuf) < 0) { |
| 332 | fprintf(stderr, "%s: Can't stat %s: %s\n", |
| 333 | params.cmdname, params.datafile, |
| 334 | strerror(errno)); |
| 335 | exit(EXIT_FAILURE); |
| 336 | } |
Simon Glass | 139651f | 2015-06-23 15:39:12 -0600 | [diff] [blame] | 337 | |
Philippe De Swert | 3edd041 | 2015-12-04 00:11:23 +0200 | [diff] [blame] | 338 | params.file_size = sbuf.st_size + tparams->header_size; |
| 339 | close(dfd); |
| 340 | } |
Simon Glass | 139651f | 2015-06-23 15:39:12 -0600 | [diff] [blame] | 341 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 342 | /* |
Stefano Babic | 4a96330 | 2011-09-15 23:50:16 +0000 | [diff] [blame] | 343 | * In case there an header with a variable |
| 344 | * length will be added, the corresponding |
| 345 | * function is called. This is responsible to |
| 346 | * allocate memory for the header itself. |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 347 | */ |
Stefano Babic | 4a96330 | 2011-09-15 23:50:16 +0000 | [diff] [blame] | 348 | if (tparams->vrec_header) |
Stefano Babic | 6531bd9 | 2013-08-19 19:03:19 +0200 | [diff] [blame] | 349 | pad_len = tparams->vrec_header(¶ms, tparams); |
Stefano Babic | 4a96330 | 2011-09-15 23:50:16 +0000 | [diff] [blame] | 350 | else |
| 351 | memset(tparams->hdr, 0, tparams->header_size); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 352 | |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 353 | if (write(ifd, tparams->hdr, tparams->header_size) |
| 354 | != tparams->header_size) { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 355 | fprintf (stderr, "%s: Write error on %s: %s\n", |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 356 | params.cmdname, params.imagefile, strerror(errno)); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 357 | exit (EXIT_FAILURE); |
| 358 | } |
| 359 | |
Christian Riesch | c14f281 | 2011-12-09 09:47:38 +0000 | [diff] [blame] | 360 | if (!params.skipcpy) { |
| 361 | if (params.type == IH_TYPE_MULTI || |
| 362 | params.type == IH_TYPE_SCRIPT) { |
| 363 | char *file = params.datafile; |
| 364 | uint32_t size; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 365 | |
Christian Riesch | c14f281 | 2011-12-09 09:47:38 +0000 | [diff] [blame] | 366 | for (;;) { |
| 367 | char *sep = NULL; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 368 | |
Christian Riesch | c14f281 | 2011-12-09 09:47:38 +0000 | [diff] [blame] | 369 | if (file) { |
| 370 | if ((sep = strchr(file, ':')) != NULL) { |
| 371 | *sep = '\0'; |
| 372 | } |
| 373 | |
| 374 | if (stat (file, &sbuf) < 0) { |
| 375 | fprintf (stderr, "%s: Can't stat %s: %s\n", |
| 376 | params.cmdname, file, strerror(errno)); |
| 377 | exit (EXIT_FAILURE); |
| 378 | } |
| 379 | size = cpu_to_uimage (sbuf.st_size); |
| 380 | } else { |
| 381 | size = 0; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 382 | } |
| 383 | |
Christian Riesch | c14f281 | 2011-12-09 09:47:38 +0000 | [diff] [blame] | 384 | if (write(ifd, (char *)&size, sizeof(size)) != sizeof(size)) { |
| 385 | fprintf (stderr, "%s: Write error on %s: %s\n", |
| 386 | params.cmdname, params.imagefile, |
| 387 | strerror(errno)); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 388 | exit (EXIT_FAILURE); |
| 389 | } |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 390 | |
Christian Riesch | c14f281 | 2011-12-09 09:47:38 +0000 | [diff] [blame] | 391 | if (!file) { |
| 392 | break; |
| 393 | } |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 394 | |
Christian Riesch | c14f281 | 2011-12-09 09:47:38 +0000 | [diff] [blame] | 395 | if (sep) { |
| 396 | *sep = ':'; |
| 397 | file = sep + 1; |
| 398 | } else { |
| 399 | file = NULL; |
| 400 | } |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 401 | } |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 402 | |
Christian Riesch | c14f281 | 2011-12-09 09:47:38 +0000 | [diff] [blame] | 403 | file = params.datafile; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 404 | |
Christian Riesch | c14f281 | 2011-12-09 09:47:38 +0000 | [diff] [blame] | 405 | for (;;) { |
| 406 | char *sep = strchr(file, ':'); |
| 407 | if (sep) { |
| 408 | *sep = '\0'; |
| 409 | copy_file (ifd, file, 1); |
| 410 | *sep++ = ':'; |
| 411 | file = sep; |
| 412 | } else { |
| 413 | copy_file (ifd, file, 0); |
| 414 | break; |
| 415 | } |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 416 | } |
Shaohui Xie | ea65fd8 | 2012-08-10 02:49:35 +0000 | [diff] [blame] | 417 | } else if (params.type == IH_TYPE_PBLIMAGE) { |
| 418 | /* PBL has special Image format, implements its' own */ |
| 419 | pbl_load_uboot(ifd, ¶ms); |
Christian Riesch | c14f281 | 2011-12-09 09:47:38 +0000 | [diff] [blame] | 420 | } else { |
Stefano Babic | 6531bd9 | 2013-08-19 19:03:19 +0200 | [diff] [blame] | 421 | copy_file(ifd, params.datafile, pad_len); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 422 | } |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | /* We're a bit of paranoid */ |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 426 | #if defined(_POSIX_SYNCHRONIZED_IO) && \ |
| 427 | !defined(__sun__) && \ |
| 428 | !defined(__FreeBSD__) && \ |
Luka Perkov | 98c689b | 2014-08-09 18:17:47 +0200 | [diff] [blame] | 429 | !defined(__OpenBSD__) && \ |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 430 | !defined(__APPLE__) |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 431 | (void) fdatasync (ifd); |
| 432 | #else |
| 433 | (void) fsync (ifd); |
| 434 | #endif |
| 435 | |
| 436 | if (fstat(ifd, &sbuf) < 0) { |
| 437 | fprintf (stderr, "%s: Can't stat %s: %s\n", |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 438 | params.cmdname, params.imagefile, strerror(errno)); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 439 | exit (EXIT_FAILURE); |
| 440 | } |
Simon Glass | 139651f | 2015-06-23 15:39:12 -0600 | [diff] [blame] | 441 | params.file_size = sbuf.st_size; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 442 | |
Mike Frysinger | cd7e1a3 | 2008-05-01 04:13:05 -0400 | [diff] [blame] | 443 | ptr = mmap(0, sbuf.st_size, PROT_READ|PROT_WRITE, MAP_SHARED, ifd, 0); |
| 444 | if (ptr == MAP_FAILED) { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 445 | fprintf (stderr, "%s: Can't map %s: %s\n", |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 446 | params.cmdname, params.imagefile, strerror(errno)); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 447 | exit (EXIT_FAILURE); |
| 448 | } |
| 449 | |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 450 | /* Setup the image header as per input image type*/ |
| 451 | if (tparams->set_header) |
| 452 | tparams->set_header (ptr, &sbuf, ifd, ¶ms); |
| 453 | else { |
| 454 | fprintf (stderr, "%s: Can't set header for %s: %s\n", |
| 455 | params.cmdname, tparams->name, strerror(errno)); |
| 456 | exit (EXIT_FAILURE); |
| 457 | } |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 458 | |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 459 | /* Print the image information by processing image header */ |
| 460 | if (tparams->print_header) |
| 461 | tparams->print_header (ptr); |
| 462 | else { |
| 463 | fprintf (stderr, "%s: Can't print header for %s: %s\n", |
| 464 | params.cmdname, tparams->name, strerror(errno)); |
| 465 | exit (EXIT_FAILURE); |
| 466 | } |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 467 | |
| 468 | (void) munmap((void *)ptr, sbuf.st_size); |
| 469 | |
| 470 | /* We're a bit of paranoid */ |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 471 | #if defined(_POSIX_SYNCHRONIZED_IO) && \ |
| 472 | !defined(__sun__) && \ |
| 473 | !defined(__FreeBSD__) && \ |
Luka Perkov | 98c689b | 2014-08-09 18:17:47 +0200 | [diff] [blame] | 474 | !defined(__OpenBSD__) && \ |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 475 | !defined(__APPLE__) |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 476 | (void) fdatasync (ifd); |
| 477 | #else |
| 478 | (void) fsync (ifd); |
| 479 | #endif |
| 480 | |
| 481 | if (close(ifd)) { |
| 482 | fprintf (stderr, "%s: Write error on %s: %s\n", |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 483 | params.cmdname, params.imagefile, strerror(errno)); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 484 | exit (EXIT_FAILURE); |
| 485 | } |
| 486 | |
| 487 | exit (EXIT_SUCCESS); |
| 488 | } |
| 489 | |
| 490 | static void |
| 491 | copy_file (int ifd, const char *datafile, int pad) |
| 492 | { |
| 493 | int dfd; |
| 494 | struct stat sbuf; |
| 495 | unsigned char *ptr; |
| 496 | int tail; |
| 497 | int zero = 0; |
Stefano Babic | 6531bd9 | 2013-08-19 19:03:19 +0200 | [diff] [blame] | 498 | uint8_t zeros[4096]; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 499 | int offset = 0; |
| 500 | int size; |
Guilherme Maciel Ferreira | 28be1cf | 2015-01-15 02:48:07 -0200 | [diff] [blame] | 501 | struct image_type_params *tparams = imagetool_get_type(params.type); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 502 | |
Stefano Babic | 6531bd9 | 2013-08-19 19:03:19 +0200 | [diff] [blame] | 503 | memset(zeros, 0, sizeof(zeros)); |
| 504 | |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 505 | if (params.vflag) { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 506 | fprintf (stderr, "Adding Image %s\n", datafile); |
| 507 | } |
| 508 | |
wdenk | 1ee550e | 2003-10-08 22:14:02 +0000 | [diff] [blame] | 509 | if ((dfd = open(datafile, O_RDONLY|O_BINARY)) < 0) { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 510 | fprintf (stderr, "%s: Can't open %s: %s\n", |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 511 | params.cmdname, datafile, strerror(errno)); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 512 | exit (EXIT_FAILURE); |
| 513 | } |
| 514 | |
| 515 | if (fstat(dfd, &sbuf) < 0) { |
| 516 | fprintf (stderr, "%s: Can't stat %s: %s\n", |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 517 | params.cmdname, datafile, strerror(errno)); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 518 | exit (EXIT_FAILURE); |
| 519 | } |
| 520 | |
Mike Frysinger | cd7e1a3 | 2008-05-01 04:13:05 -0400 | [diff] [blame] | 521 | ptr = mmap(0, sbuf.st_size, PROT_READ, MAP_SHARED, dfd, 0); |
| 522 | if (ptr == MAP_FAILED) { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 523 | fprintf (stderr, "%s: Can't read %s: %s\n", |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 524 | params.cmdname, datafile, strerror(errno)); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 525 | exit (EXIT_FAILURE); |
| 526 | } |
| 527 | |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 528 | if (params.xflag) { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 529 | unsigned char *p = NULL; |
| 530 | /* |
| 531 | * XIP: do not append the image_header_t at the |
| 532 | * beginning of the file, but consume the space |
| 533 | * reserved for it. |
| 534 | */ |
| 535 | |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 536 | if ((unsigned)sbuf.st_size < tparams->header_size) { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 537 | fprintf (stderr, |
| 538 | "%s: Bad size: \"%s\" is too small for XIP\n", |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 539 | params.cmdname, datafile); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 540 | exit (EXIT_FAILURE); |
| 541 | } |
| 542 | |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 543 | for (p = ptr; p < ptr + tparams->header_size; p++) { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 544 | if ( *p != 0xff ) { |
| 545 | fprintf (stderr, |
| 546 | "%s: Bad file: \"%s\" has invalid buffer for XIP\n", |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 547 | params.cmdname, datafile); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 548 | exit (EXIT_FAILURE); |
| 549 | } |
| 550 | } |
| 551 | |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 552 | offset = tparams->header_size; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 553 | } |
| 554 | |
| 555 | size = sbuf.st_size - offset; |
| 556 | if (write(ifd, ptr + offset, size) != size) { |
| 557 | fprintf (stderr, "%s: Write error on %s: %s\n", |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 558 | params.cmdname, params.imagefile, strerror(errno)); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 559 | exit (EXIT_FAILURE); |
| 560 | } |
| 561 | |
Stefano Babic | 6531bd9 | 2013-08-19 19:03:19 +0200 | [diff] [blame] | 562 | tail = size % 4; |
| 563 | if ((pad == 1) && (tail != 0)) { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 564 | |
| 565 | if (write(ifd, (char *)&zero, 4-tail) != 4-tail) { |
| 566 | fprintf (stderr, "%s: Write error on %s: %s\n", |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 567 | params.cmdname, params.imagefile, |
| 568 | strerror(errno)); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 569 | exit (EXIT_FAILURE); |
| 570 | } |
Stefano Babic | 6531bd9 | 2013-08-19 19:03:19 +0200 | [diff] [blame] | 571 | } else if (pad > 1) { |
Simon Glass | 46409cc | 2015-08-30 16:55:22 -0600 | [diff] [blame] | 572 | while (pad > 0) { |
| 573 | int todo = sizeof(zeros); |
| 574 | |
| 575 | if (todo > pad) |
| 576 | todo = pad; |
| 577 | if (write(ifd, (char *)&zeros, todo) != todo) { |
| 578 | fprintf(stderr, "%s: Write error on %s: %s\n", |
| 579 | params.cmdname, params.imagefile, |
| 580 | strerror(errno)); |
| 581 | exit(EXIT_FAILURE); |
| 582 | } |
| 583 | pad -= todo; |
Stefano Babic | 6531bd9 | 2013-08-19 19:03:19 +0200 | [diff] [blame] | 584 | } |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 585 | } |
| 586 | |
| 587 | (void) munmap((void *)ptr, sbuf.st_size); |
| 588 | (void) close (dfd); |
| 589 | } |
| 590 | |
Guilherme Maciel Ferreira | ff0fa61 | 2013-12-01 12:43:09 -0700 | [diff] [blame] | 591 | static void usage(void) |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 592 | { |
| 593 | fprintf (stderr, "Usage: %s -l image\n" |
Bartlomiej Sieka | d7816fb | 2008-03-11 12:34:47 +0100 | [diff] [blame] | 594 | " -l ==> list image header information\n", |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 595 | params.cmdname); |
Bartlomiej Sieka | d7816fb | 2008-03-11 12:34:47 +0100 | [diff] [blame] | 596 | fprintf (stderr, " %s [-x] -A arch -O os -T type -C comp " |
| 597 | "-a addr -e ep -n name -d data_file[:data_file...] image\n" |
| 598 | " -A ==> set architecture to 'arch'\n" |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 599 | " -O ==> set operating system to 'os'\n" |
| 600 | " -T ==> set image type to 'type'\n" |
| 601 | " -C ==> set compression type 'comp'\n" |
| 602 | " -a ==> set load address to 'addr' (hex)\n" |
| 603 | " -e ==> set entry point to 'ep' (hex)\n" |
| 604 | " -n ==> set image name to 'name'\n" |
| 605 | " -d ==> use image data from 'datafile'\n" |
Bartlomiej Sieka | d7816fb | 2008-03-11 12:34:47 +0100 | [diff] [blame] | 606 | " -x ==> set XIP (execute in place)\n", |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 607 | params.cmdname); |
Simon Glass | ce8c3ca | 2013-06-13 15:10:05 -0700 | [diff] [blame] | 608 | fprintf(stderr, " %s [-D dtc_options] [-f fit-image.its|-F] fit-image\n", |
Prafulla Wadaskar | fabf3cf | 2009-08-19 17:36:46 +0530 | [diff] [blame] | 609 | params.cmdname); |
Tom Rini | e140a46 | 2015-08-26 15:21:23 -0400 | [diff] [blame] | 610 | fprintf(stderr, " -D => set all options for device tree compiler\n" |
Simon Glass | b148974 | 2013-06-13 15:10:03 -0700 | [diff] [blame] | 611 | " -f => input filename for FIT source\n"); |
| 612 | #ifdef CONFIG_FIT_SIGNATURE |
Simon Glass | 817278a | 2013-06-13 15:10:07 -0700 | [diff] [blame] | 613 | fprintf(stderr, "Signing / verified boot options: [-k keydir] [-K dtb] [ -c <comment>] [-r]\n" |
Simon Glass | b4d8b09 | 2013-06-13 15:10:04 -0700 | [diff] [blame] | 614 | " -k => set directory containing private keys\n" |
Simon Glass | ce8c3ca | 2013-06-13 15:10:05 -0700 | [diff] [blame] | 615 | " -K => write public keys to this .dtb file\n" |
Simon Glass | bf27d3d | 2013-06-13 15:10:06 -0700 | [diff] [blame] | 616 | " -c => add comment in signature node\n" |
Simon Glass | 817278a | 2013-06-13 15:10:07 -0700 | [diff] [blame] | 617 | " -F => re-sign existing FIT image\n" |
| 618 | " -r => mark keys used as 'required' in dtb\n"); |
Simon Glass | b148974 | 2013-06-13 15:10:03 -0700 | [diff] [blame] | 619 | #else |
| 620 | fprintf(stderr, "Signing / verified boot not supported (CONFIG_FIT_SIGNATURE undefined)\n"); |
| 621 | #endif |
Wolfgang Denk | e97ab72 | 2011-02-12 10:37:11 +0100 | [diff] [blame] | 622 | fprintf (stderr, " %s -V ==> print version information and exit\n", |
| 623 | params.cmdname); |
Simon Glass | 434a31b | 2015-06-23 15:38:25 -0600 | [diff] [blame] | 624 | fprintf(stderr, "Use -T to see a list of available image types\n"); |
Bartlomiej Sieka | d7816fb | 2008-03-11 12:34:47 +0100 | [diff] [blame] | 625 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 626 | exit (EXIT_FAILURE); |
| 627 | } |