summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMarek Vasut <[email protected]>2025-11-25 16:42:57 +0100
committerTom Rini <[email protected]>2025-12-06 11:46:09 -0600
commit22aa122eee021a631e1b92c761ff1a434d46890e (patch)
treed1a018d86a962abbd5fbde8b52ed96908a4c381b /tools
parent23eb6c9ce11b6b781f7902ced7340f2c6c433e4f (diff)
mkimage: Add support for bundling TEE in mkimage -f auto
Introduce two new parameters to be used with mkimage -f auto to bundle TEE image into fitImage, using auto-generated fitImage. Add -z to specify TEE file name and -Z to specify TEE load and entry point address. This is meant to be used with systems which boot all of TEE, Linux and its DT from a single fitImage, all booted by U-Boot. Example invocation: " $ mkimage -E -A arm -C none -e 0xc0008000 -a 0xc0008000 -f auto \ -d arch/arm/boot/zImage \ -b arch/arm/boot/dts/st/stm32mp135f-dhcor-dhsbc.dtb \ -z ../optee_os/out/arm-plat-stm32mp1/core/tee-raw.bin \ -Z 0xde000000 \ /path/to/output/fitImage " Documentation update and test are also included, the test validates both positive and negative test cases, where fitImage does not include TEE and does include TEE blobs. Acked-by: Quentin Schulz <[email protected]> Signed-off-by: Marek Vasut <[email protected]>
Diffstat (limited to 'tools')
-rw-r--r--tools/fit_image.c51
-rw-r--r--tools/imagetool.h2
-rw-r--r--tools/mkimage.c17
3 files changed, 63 insertions, 7 deletions
diff --git a/tools/fit_image.c b/tools/fit_image.c
index 0306333141e..4aa0ce2dbfe 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -180,6 +180,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)
@@ -433,6 +440,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;
@@ -474,9 +505,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);
@@ -499,9 +534,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);
diff --git a/tools/imagetool.h b/tools/imagetool.h
index 866b8834fd7..d0e7d6d56e3 100644
--- a/tools/imagetool.h
+++ b/tools/imagetool.h
@@ -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 */
};
/*
diff --git a/tools/mkimage.c b/tools/mkimage.c
index a800f9507bf..3c43962807d 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -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");
}