From: Stefano Babic Date: Thu, 15 Sep 2011 23:50:16 +0000 (+0000) Subject: mkimage: Add variable lenght header support X-Git-Tag: v2011.12-rc1~583 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f0662105b674a3874227316abf8536bebc9b5995;p=u-boot mkimage: Add variable lenght header support Some images have not a header of fix lenght. The patch will be used for the generation of AIS images, because this header has a variable lenght. The patch adds also the parameter "-s" (skip) to not copy automatically the passed image file. Signed-off-by: Stefano Babic --- diff --git a/tools/mkimage.c b/tools/mkimage.c index 2f33101754..c307a37615 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -248,6 +248,9 @@ main (int argc, char **argv) usage (); params.imagename = *++argv; goto NXTARG; + case 's': + params.skipcpy = 1; + break; case 'v': params.vflag++; break; @@ -361,11 +364,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(¶ms, tparams); + else + memset(tparams->hdr, 0, tparams->header_size); if (write(ifd, tparams->hdr, tparams->header_size) != tparams->header_size) { @@ -374,7 +381,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; diff --git a/tools/mkimage.h b/tools/mkimage.h index e59a91913e..213baf0037 100644 --- a/tools/mkimage.h +++ b/tools/mkimage.h @@ -60,6 +60,7 @@ struct mkimage_params { int lflag; int vflag; int xflag; + int skipcpy; int os; int arch; int type; @@ -122,6 +123,13 @@ struct image_type_params { int (*check_image_type) (uint8_t); /* This callback function will be executed if fflag is defined */ int (*fflag_handle) (struct mkimage_params *); + /* + * This callback function will be executed for variable size record + * It is expected to build this header in memory and return its length + * and a pointer to it + */ + int (*vrec_header) (struct mkimage_params *, + struct image_type_params *); /* pointer to the next registered entry in linked list */ struct image_type_params *next; };