]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - tools/mkimage.c
arm, davinci: add support for new spl framework
[karo-tx-uboot.git] / tools / mkimage.c
index 1bed93360e8645dd6c2ea22bd6d3b8ce322686c7..36e28ec923492ddc1495a66021e5e4b2e2f258ea 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "mkimage.h"
 #include <image.h>
+#include <version.h>
 
 static void copy_file(int, const char *, int);
 static void usage(void);
@@ -37,6 +38,7 @@ struct mkimage_params params = {
        .type = IH_TYPE_KERNEL,
        .comp = IH_COMP_GZIP,
        .dtc = MKIMAGE_DEFAULT_DTC_OPTIONS,
+       .imagename = "",
 };
 
 /*
@@ -144,16 +146,24 @@ 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 TI OMAP Boot image generation/list support */
+       init_omap_image_type();
        /* Init Default image generation/list support */
        init_default_image_type ();
+       /* Init Davinci UBL support */
+       init_ubl_image_type();
+       /* Init Davinci AIS support */
+       init_ais_image_type();
 
        params.cmdname = *argv;
        params.addr = params.ep = 0;
@@ -198,8 +208,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 +225,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",
@@ -242,9 +250,15 @@ main (int argc, char **argv)
                                        usage ();
                                params.imagename = *++argv;
                                goto NXTARG;
+                       case 's':
+                               params.skipcpy = 1;
+                               break;
                        case 'v':
                                params.vflag++;
                                break;
+                       case 'V':
+                               printf("mkimage version %s\n", PLAIN_VERSION);
+                               exit(EXIT_SUCCESS);
                        case 'x':
                                params.xflag++;
                                break;
@@ -281,20 +295,6 @@ 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){
@@ -366,11 +366,15 @@ NXTARG:           ;
        }
 
        /*
-        * Must be -w then:
-        *
-        * write dummy header, to be fixed later
+        * In case there an header with a variable
+        * length will be added, the corresponding
+        * function is called. This is responsible to
+        * allocate memory for the header itself.
         */
-       memset (tparams->hdr, 0, tparams->header_size);
+       if (tparams->vrec_header)
+               tparams->vrec_header(&params, tparams);
+       else
+               memset(tparams->hdr, 0, tparams->header_size);
 
        if (write(ifd, tparams->hdr, tparams->header_size)
                                        != tparams->header_size) {
@@ -379,7 +383,9 @@ NXTARG:             ;
                exit (EXIT_FAILURE);
        }
 
-       if (params.type == IH_TYPE_MULTI || params.type == IH_TYPE_SCRIPT) {
+       if (!params.skipcpy &&
+               (params.type == IH_TYPE_MULTI ||
+                       params.type == IH_TYPE_SCRIPT)) {
                char *file = params.datafile;
                uint32_t size;
 
@@ -603,6 +609,8 @@ usage ()
                params.cmdname);
        fprintf (stderr, "       %s [-D dtc_options] -f fit-image.its fit-image\n",
                params.cmdname);
+       fprintf (stderr, "       %s -V ==> print version information and exit\n",
+               params.cmdname);
 
        exit (EXIT_FAILURE);
 }