tools: mkimage: support set FIT image version
Command: "./mkimage ... -v [version]". Signed-off-by: Joseph Chen <chenjh@rock-chips.com> Change-Id: I84dd5c3d7380150f428cdd0c2055929343bf2138
This commit is contained in:
parent
15d854a192
commit
ad07c38f68
|
@ -1131,6 +1131,19 @@ int fit_set_totalsize(void *fit, int noffset, int totalsize)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int fit_set_version(void *fit, int noffset, int version)
|
||||
{
|
||||
uint32_t v;
|
||||
int ret;
|
||||
|
||||
v = cpu_to_uimage(version);
|
||||
ret = fdt_setprop(fit, noffset, FIT_VERSION_PROP, &v, sizeof(uint32_t));
|
||||
if (ret)
|
||||
return ret == -FDT_ERR_NOSPACE ? -ENOSPC : -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fit_calculate_hash(const void *data, int data_len,
|
||||
const char *algo, uint8_t *value,
|
||||
int *value_len)
|
||||
|
|
|
@ -920,6 +920,7 @@ int bootz_setup(ulong image, ulong *start, ulong *end);
|
|||
#define FIT_DATA_SIZE_PROP "data-size"
|
||||
#define FIT_TIMESTAMP_PROP "timestamp"
|
||||
#define FIT_TOTALSIZE_PROP "totalsize"
|
||||
#define FIT_VERSION_PROP "version"
|
||||
#define FIT_DESC_PROP "description"
|
||||
#define FIT_ARCH_PROP "arch"
|
||||
#define FIT_TYPE_PROP "type"
|
||||
|
@ -1028,6 +1029,7 @@ int fit_image_check_hash(const void *fit, int noffset, const void *data,
|
|||
|
||||
int fit_set_timestamp(void *fit, int noffset, time_t timestamp);
|
||||
int fit_set_totalsize(void *fit, int noffset, int totalsize);
|
||||
int fit_set_version(void *fit, int noffset, int version);
|
||||
|
||||
/**
|
||||
* fit_add_verification_data() - add verification data to FIT image nodes
|
||||
|
|
|
@ -101,6 +101,10 @@ static int fit_add_file_data(struct image_tool_params *params, size_t size_inc,
|
|||
time_t time = imagetool_get_source_date(params, sbuf.st_mtime);
|
||||
ret = fit_set_timestamp(ptr, 0, time);
|
||||
ret |= fit_set_totalsize(ptr, 0, sbuf.st_size);
|
||||
if (params->vflag > 0)
|
||||
ret |= fit_set_version(ptr, 0, params->vflag);
|
||||
else
|
||||
ret |= fit_set_version(ptr, 0, 0);
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
|
|
|
@ -95,7 +95,9 @@ static void usage(const char *msg)
|
|||
fprintf(stderr,
|
||||
" -D => set all options for device tree compiler\n"
|
||||
" -f => input filename for FIT source\n"
|
||||
" -i => input filename for ramdisk file\n");
|
||||
" -i => input filename for ramdisk file\n"
|
||||
" -v => set FIT image version in decimal\n");
|
||||
|
||||
#ifdef CONFIG_FIT_SIGNATURE
|
||||
fprintf(stderr,
|
||||
"Signing / verified boot options: [-E] [-k keydir] [-K dtb] [ -c <comment>] [-p addr] [-r] [-N engine]\n"
|
||||
|
@ -144,7 +146,7 @@ static void process_args(int argc, char **argv)
|
|||
int opt;
|
||||
|
||||
while ((opt = getopt(argc, argv,
|
||||
"a:A:b:c:C:d:D:e:Ef:Fk:i:K:ln:N:p:O:rR:qsT:vVxX:")) != -1) {
|
||||
"a:A:b:c:C:d:D:e:Ef:Fk:i:K:ln:N:p:O:rR:qsT:v:VxX:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'a':
|
||||
params.addr = strtoull(optarg, &ptr, 16);
|
||||
|
@ -271,7 +273,12 @@ static void process_args(int argc, char **argv)
|
|||
}
|
||||
break;
|
||||
case 'v':
|
||||
params.vflag++;
|
||||
params.vflag = strtoull(optarg, &ptr, 10);
|
||||
if (*ptr) {
|
||||
fprintf(stderr, "%s: invalid version length %s\n",
|
||||
params.cmdname, optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
case 'V':
|
||||
printf("mkimage version %s\n", PLAIN_VERSION);
|
||||
|
|
Loading…
Reference in New Issue