mkimage: Allow a FIT to include an image of any type
At present FIT images are set up by providing a device tree source file which is a file with a .its extension. We want to support automatically creating this file based on the image supplied to mkimage. This means that even though the final file type is always IH_TYPE_FLATDT, the image inside may be something else. Signed-off-by: Simon Glass <sjg@chromium.org>utp
parent
e2070a8961
commit
d505a09c1e
|
@ -61,6 +61,7 @@ struct image_tool_params {
|
||||||
int require_keys; /* 1 to mark signing keys as 'required' */
|
int require_keys; /* 1 to mark signing keys as 'required' */
|
||||||
int file_size; /* Total size of output file */
|
int file_size; /* Total size of output file */
|
||||||
int orig_file_size; /* Original size for file before padding */
|
int orig_file_size; /* Original size for file before padding */
|
||||||
|
int fit_image_type; /* Image type to put into the FIT */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -112,10 +112,14 @@ static void usage(const char *msg)
|
||||||
static void process_args(int argc, char **argv)
|
static void process_args(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
int type = IH_TYPE_INVALID;
|
||||||
|
char *datafile = NULL;
|
||||||
|
int expecting;
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
|
expecting = IH_TYPE_COUNT; /* Unknown */
|
||||||
while ((opt = getopt(argc, argv,
|
while ((opt = getopt(argc, argv,
|
||||||
"a:A:cC:d:D:e:f:Fk:K:ln:O:rR:sT:vVx")) != -1) {
|
"-a:A:cC:d:D:e:f:Fk:K:ln:O:rR:sT:vVx")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'a':
|
case 'a':
|
||||||
params.addr = strtoull(optarg, &ptr, 16);
|
params.addr = strtoull(optarg, &ptr, 16);
|
||||||
|
@ -162,6 +166,7 @@ static void process_args(int argc, char **argv)
|
||||||
* The flattened image tree (FIT) format
|
* The flattened image tree (FIT) format
|
||||||
* requires a flattened device tree image type
|
* requires a flattened device tree image type
|
||||||
*/
|
*/
|
||||||
|
params.fit_image_type = params.type;
|
||||||
params.type = IH_TYPE_FLATDT;
|
params.type = IH_TYPE_FLATDT;
|
||||||
params.fflag = 1;
|
params.fflag = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -196,11 +201,12 @@ static void process_args(int argc, char **argv)
|
||||||
params.skipcpy = 1;
|
params.skipcpy = 1;
|
||||||
break;
|
break;
|
||||||
case 'T':
|
case 'T':
|
||||||
params.type = genimg_get_type_id(optarg);
|
type = genimg_get_type_id(optarg);
|
||||||
if (params.type < 0) {
|
if (type < 0) {
|
||||||
show_image_types();
|
show_image_types();
|
||||||
usage("Invalid image type");
|
usage("Invalid image type");
|
||||||
}
|
}
|
||||||
|
expecting = type;
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
params.vflag++;
|
params.vflag++;
|
||||||
|
@ -211,14 +217,31 @@ static void process_args(int argc, char **argv)
|
||||||
case 'x':
|
case 'x':
|
||||||
params.xflag++;
|
params.xflag++;
|
||||||
break;
|
break;
|
||||||
|
case 1:
|
||||||
|
if (expecting == type || optind == argc) {
|
||||||
|
params.imagefile = optarg;
|
||||||
|
expecting = IH_TYPE_INVALID;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage("Invalid option");
|
usage("Invalid option");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind >= argc)
|
/*
|
||||||
|
* For auto-generated FIT images we need to know the image type to put
|
||||||
|
* in the FIT, which is separate from the file's image type (which
|
||||||
|
* will always be IH_TYPE_FLATDT in this case).
|
||||||
|
*/
|
||||||
|
if (params.type == IH_TYPE_FLATDT) {
|
||||||
|
params.fit_image_type = type;
|
||||||
|
params.datafile = datafile;
|
||||||
|
} else if (type != IH_TYPE_INVALID) {
|
||||||
|
params.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!params.imagefile)
|
||||||
usage("Missing output filename");
|
usage("Missing output filename");
|
||||||
params.imagefile = argv[optind];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue