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