X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=tools%2Fmkimage.c;h=f5859d77642152a78751d4b7ce79255c485e6e5b;hb=570d7d50b0915514556dda0875544c42de9b4d56;hp=8a20594f316e558a63d9511316fadc38f946846d;hpb=21c76b56a4221d054aaa6ae983c965ceb7894b7c;p=u-boot diff --git a/tools/mkimage.c b/tools/mkimage.c index 8a20594f31..f5859d7764 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -37,6 +37,7 @@ struct mkimage_params params = { .type = IH_TYPE_KERNEL, .comp = IH_COMP_GZIP, .dtc = MKIMAGE_DEFAULT_DTC_OPTIONS, + .imagename = "", }; /* @@ -144,12 +145,14 @@ main (int argc, char **argv) { int ifd = -1; struct stat sbuf; - unsigned char *ptr; + char *ptr; int retval = 0; struct image_type_params *tparams = NULL; /* Init Kirkwood Boot image generation/list support */ init_kwb_image_type (); + /* Init Freescale imx Boot image generation/list support */ + init_imx_image_type (); /* Init FIT image generation/list support */ init_fit_image_type (); /* Init Default image generation/list support */ @@ -198,8 +201,7 @@ main (int argc, char **argv) case 'a': if (--argc <= 0) usage (); - params.addr = strtoul (*++argv, - (char **)&ptr, 16); + params.addr = strtoul (*++argv, &ptr, 16); if (*ptr) { fprintf (stderr, "%s: invalid load address %s\n", @@ -216,8 +218,7 @@ main (int argc, char **argv) case 'e': if (--argc <= 0) usage (); - params.ep = strtoul (*++argv, - (char **)&ptr, 16); + params.ep = strtoul (*++argv, &ptr, 16); if (*ptr) { fprintf (stderr, "%s: invalid entry point %s\n", @@ -229,6 +230,10 @@ main (int argc, char **argv) case 'f': if (--argc <= 0) usage (); + /* + * The flattened image tree (FIT) format + * requires a flattened device tree image type + */ params.type = IH_TYPE_FLATDT; params.datafile = *++argv; params.fflag = 1; @@ -277,39 +282,37 @@ NXTARG: ; params.ep += tparams->header_size; } - /* - * If XIP, ensure the entry point is equal to the load address plus - * the size of the U-Boot header. - */ - if (params.xflag) { - if (params.ep != params.addr + tparams->header_size) { - fprintf (stderr, - "%s: For XIP, the entry point must be the load addr + %lu\n", - params.cmdname, - (unsigned long)tparams->header_size); - exit (EXIT_FAILURE); - } - } - params.imagefile = *argv; - if (!params.fflag){ - if (params.lflag) { - ifd = open (params.imagefile, O_RDONLY|O_BINARY); - } else { - ifd = open (params.imagefile, - O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0666); - } + if (params.fflag){ + if (tparams->fflag_handle) + /* + * in some cases, some additional processing needs + * to be done if fflag is defined + * + * For ex. fit_handle_file for Fit file support + */ + retval = tparams->fflag_handle(¶ms); - if (ifd < 0) { - fprintf (stderr, "%s: Can't open %s: %s\n", - params.cmdname, params.imagefile, - strerror(errno)); - exit (EXIT_FAILURE); - } + if (retval != EXIT_SUCCESS) + exit (retval); + } + + if (params.lflag || params.fflag) { + ifd = open (params.imagefile, O_RDONLY|O_BINARY); + } else { + ifd = open (params.imagefile, + O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0666); + } + + if (ifd < 0) { + fprintf (stderr, "%s: Can't open %s: %s\n", + params.cmdname, params.imagefile, + strerror(errno)); + exit (EXIT_FAILURE); } - if (params.lflag) { + if (params.lflag || params.fflag) { /* * list header information of existing image */ @@ -346,17 +349,6 @@ NXTARG: ; (void) munmap((void *)ptr, sbuf.st_size); (void) close (ifd); - exit (retval); - } else if (params.fflag) { - if (tparams->fflag_handle) - /* - * in some cases, some additional processing needs - * to be done if fflag is defined - * - * For ex. fit_handle_file for Fit file support - */ - retval = tparams->fflag_handle(¶ms); - exit (retval); }