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 <sbabic@denx.de>
This commit is contained in:
parent
163967905f
commit
f0662105b6
|
@ -248,6 +248,9 @@ main (int argc, char **argv)
|
||||||
usage ();
|
usage ();
|
||||||
params.imagename = *++argv;
|
params.imagename = *++argv;
|
||||||
goto NXTARG;
|
goto NXTARG;
|
||||||
|
case 's':
|
||||||
|
params.skipcpy = 1;
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
params.vflag++;
|
params.vflag++;
|
||||||
break;
|
break;
|
||||||
|
@ -361,10 +364,14 @@ NXTARG: ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Must be -w then:
|
* In case there an header with a variable
|
||||||
*
|
* length will be added, the corresponding
|
||||||
* write dummy header, to be fixed later
|
* function is called. This is responsible to
|
||||||
|
* allocate memory for the header itself.
|
||||||
*/
|
*/
|
||||||
|
if (tparams->vrec_header)
|
||||||
|
tparams->vrec_header(¶ms, tparams);
|
||||||
|
else
|
||||||
memset(tparams->hdr, 0, tparams->header_size);
|
memset(tparams->hdr, 0, tparams->header_size);
|
||||||
|
|
||||||
if (write(ifd, tparams->hdr, tparams->header_size)
|
if (write(ifd, tparams->hdr, tparams->header_size)
|
||||||
|
@ -374,7 +381,9 @@ NXTARG: ;
|
||||||
exit (EXIT_FAILURE);
|
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;
|
char *file = params.datafile;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ struct mkimage_params {
|
||||||
int lflag;
|
int lflag;
|
||||||
int vflag;
|
int vflag;
|
||||||
int xflag;
|
int xflag;
|
||||||
|
int skipcpy;
|
||||||
int os;
|
int os;
|
||||||
int arch;
|
int arch;
|
||||||
int type;
|
int type;
|
||||||
|
@ -122,6 +123,13 @@ struct image_type_params {
|
||||||
int (*check_image_type) (uint8_t);
|
int (*check_image_type) (uint8_t);
|
||||||
/* This callback function will be executed if fflag is defined */
|
/* This callback function will be executed if fflag is defined */
|
||||||
int (*fflag_handle) (struct mkimage_params *);
|
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 */
|
/* pointer to the next registered entry in linked list */
|
||||||
struct image_type_params *next;
|
struct image_type_params *next;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue