Merge patch series "test/py: fit: Deduplicate the test"
This series from Marek Vasut <marek.vasut@mailbox.org> cleans up some of the FIT pytests we have and then extends mkimage to support including the TEE in FIT images when using "-f auto" to create the resulting FIT. Link: https://lore.kernel.org/r/20251125154324.51940-1-marek.vasut@mailbox.org
This commit is contained in:
@@ -181,6 +181,13 @@ static int fit_calc_size(struct image_tool_params *params)
|
||||
total_size += size;
|
||||
}
|
||||
|
||||
if (params->fit_tee) {
|
||||
size = imagetool_get_filesize(params, params->fit_tee);
|
||||
if (size < 0)
|
||||
return -1;
|
||||
total_size += size;
|
||||
}
|
||||
|
||||
for (cont = params->content_head; cont; cont = cont->next) {
|
||||
size = imagetool_get_filesize(params, cont->fname);
|
||||
if (size < 0)
|
||||
@@ -434,6 +441,30 @@ static int fit_write_images(struct image_tool_params *params, char *fdt)
|
||||
fdt_end_node(fdt);
|
||||
}
|
||||
|
||||
/* And a TEE file if available */
|
||||
if (params->fit_tee) {
|
||||
fdt_begin_node(fdt, FIT_TEE_PROP "-1");
|
||||
|
||||
fdt_property_string(fdt, FIT_TYPE_PROP, FIT_TEE_PROP);
|
||||
fdt_property_string(fdt, FIT_OS_PROP,
|
||||
genimg_get_os_short_name(params->os));
|
||||
fdt_property_string(fdt, FIT_ARCH_PROP,
|
||||
genimg_get_arch_short_name(params->arch));
|
||||
get_basename(str, sizeof(str), params->fit_tee);
|
||||
fdt_property_string(fdt, FIT_DESC_PROP, str);
|
||||
|
||||
ret = fdt_property_file(params, fdt, FIT_DATA_PROP,
|
||||
params->fit_tee);
|
||||
if (ret)
|
||||
return ret;
|
||||
fdt_property_u32(fdt, FIT_LOAD_PROP, params->fit_tee_addr);
|
||||
fdt_property_u32(fdt, FIT_ENTRY_PROP, params->fit_tee_addr);
|
||||
fit_add_hash_or_sign(params, fdt, true);
|
||||
if (ret)
|
||||
return ret;
|
||||
fdt_end_node(fdt);
|
||||
}
|
||||
|
||||
fdt_end_node(fdt);
|
||||
|
||||
return 0;
|
||||
@@ -475,9 +506,13 @@ static void fit_write_configs(struct image_tool_params *params, char *fdt)
|
||||
fdt_property_string(fdt, typename, str);
|
||||
|
||||
if (params->fit_tfa_bl31) {
|
||||
snprintf(str, sizeof(str), "%s-1." FIT_TFA_BL31_PROP "-1", typename);
|
||||
str[len] = 0;
|
||||
len += strlen(FIT_TFA_BL31_PROP "-1") + 1;
|
||||
snprintf(&str[len + 1], sizeof(str) - (len + 1), FIT_TFA_BL31_PROP "-1");
|
||||
len += strlen(&str[len + 1]) + 1;
|
||||
}
|
||||
|
||||
if (params->fit_tee) {
|
||||
snprintf(&str[len + 1], sizeof(str) - (len + 1), FIT_TEE_PROP "-1");
|
||||
len += strlen(&str[len + 1]) + 1;
|
||||
}
|
||||
|
||||
fdt_property(fdt, FIT_LOADABLE_PROP, str, len + 1);
|
||||
@@ -500,9 +535,13 @@ static void fit_write_configs(struct image_tool_params *params, char *fdt)
|
||||
fdt_property_string(fdt, typename, str);
|
||||
|
||||
if (params->fit_tfa_bl31) {
|
||||
snprintf(str, sizeof(str), "%s-1." FIT_TFA_BL31_PROP "-1", typename);
|
||||
str[len] = 0;
|
||||
len += strlen(FIT_TFA_BL31_PROP "-1") + 1;
|
||||
snprintf(&str[len + 1], sizeof(str) - (len + 1), FIT_TFA_BL31_PROP "-1");
|
||||
len += strlen(&str[len + 1]) + 1;
|
||||
}
|
||||
|
||||
if (params->fit_tee) {
|
||||
snprintf(&str[len + 1], sizeof(str) - (len + 1), FIT_TEE_PROP "-1");
|
||||
len += strlen(&str[len + 1]) + 1;
|
||||
}
|
||||
|
||||
fdt_property(fdt, FIT_LOADABLE_PROP, str, len + 1);
|
||||
|
||||
@@ -101,6 +101,8 @@ struct image_tool_params {
|
||||
struct image_summary summary; /* results of signing process */
|
||||
char *fit_tfa_bl31; /* TFA BL31 file to include */
|
||||
unsigned int fit_tfa_bl31_addr; /* TFA BL31 load and entry point address */
|
||||
char *fit_tee; /* TEE file to include */
|
||||
unsigned int fit_tee_addr; /* TEE load and entry point address */
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -103,6 +103,8 @@ static void usage(const char *msg)
|
||||
" -s ==> create an image with no data\n"
|
||||
" -y ==> append TFA BL31 file to the image\n"
|
||||
" -Y ==> set TFA BL31 file load and entry point address\n"
|
||||
" -z ==> append raw TEE file to the image\n"
|
||||
" -Z ==> set raw TEE file load and entry point address\n"
|
||||
" -v ==> verbose\n",
|
||||
params.cmdname);
|
||||
fprintf(stderr,
|
||||
@@ -162,7 +164,7 @@ static int add_content(int type, const char *fname)
|
||||
}
|
||||
|
||||
static const char optstring[] =
|
||||
"a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:ln:N:o:O:p:qrR:stT:vVxy:Y:";
|
||||
"a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:ln:N:o:O:p:qrR:stT:vVxy:Y:z:Z:";
|
||||
|
||||
static const struct option longopts[] = {
|
||||
{ "load-address", required_argument, NULL, 'a' },
|
||||
@@ -200,6 +202,8 @@ static const struct option longopts[] = {
|
||||
{ "xip", no_argument, NULL, 'x' },
|
||||
{ "tfa-bl31-file", no_argument, NULL, 'y' },
|
||||
{ "tfa-bl31-addr", no_argument, NULL, 'Y' },
|
||||
{ "tee-file", no_argument, NULL, 'z' },
|
||||
{ "tee-addr", no_argument, NULL, 'Z' },
|
||||
{ /* sentinel */ },
|
||||
};
|
||||
|
||||
@@ -382,6 +386,17 @@ static void process_args(int argc, char **argv)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
case 'z':
|
||||
params.fit_tee = optarg;
|
||||
break;
|
||||
case 'Z':
|
||||
params.fit_tee_addr = strtoull(optarg, &ptr, 16);
|
||||
if (*ptr) {
|
||||
fprintf(stderr, "%s: invalid TEE address %s\n",
|
||||
params.cmdname, optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
usage("Invalid option");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user