]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - tools/mkimage.c
Merge branch 'master' of git://git.denx.de/u-boot-arm
[karo-tx-uboot.git] / tools / mkimage.c
index c43b20772694e9d78c880001c4187d2e32d8aaca..f5859d77642152a78751d4b7ce79255c485e6e5b 100644 (file)
@@ -37,6 +37,7 @@ struct mkimage_params params = {
        .type = IH_TYPE_KERNEL,
        .comp = IH_COMP_GZIP,
        .dtc = MKIMAGE_DEFAULT_DTC_OPTIONS,
+       .imagename = "",
 };
 
 /*
@@ -144,10 +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 */
@@ -196,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",
@@ -214,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",
@@ -227,6 +230,11 @@ 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;
                                goto NXTARG;
@@ -274,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(&params);
 
-               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
                 */
@@ -343,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(&params);
-
                exit (retval);
        }