diff options
| author | Tom Rini <[email protected]> | 2025-12-06 11:46:15 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2025-12-06 11:46:15 -0600 |
| commit | 17d1e039e1c41a7bd3ca04756a7dd647744db9eb (patch) | |
| tree | 0d3048754042ae1b4deacb1b48012c6ccfa8e0ee /tools | |
| parent | 7f053fc40ae6e3c96758b4f3a7dbe702fc2bde65 (diff) | |
| parent | 22aa122eee021a631e1b92c761ff1a434d46890e (diff) | |
Merge patch series "test/py: fit: Deduplicate the test"
This series from Marek Vasut <[email protected]> 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/[email protected]
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/fit_image.c | 51 | ||||
| -rw-r--r-- | tools/imagetool.h | 2 | ||||
| -rw-r--r-- | tools/mkimage.c | 17 |
3 files changed, 63 insertions, 7 deletions
diff --git a/tools/fit_image.c b/tools/fit_image.c index 694bb927c7d..e865f65a400 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -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); 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"); } |
