summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/fit_image.c52
-rw-r--r--tools/imagetool.h2
-rw-r--r--tools/mkimage.c15
3 files changed, 66 insertions, 3 deletions
diff --git a/tools/fit_image.c b/tools/fit_image.c
index 331be5ae71d..10849733816 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -173,6 +173,13 @@ static int fit_calc_size(struct image_tool_params *params)
total_size += size;
}
+ if (params->fit_tfa_bl31) {
+ size = imagetool_get_filesize(params, params->fit_tfa_bl31);
+ 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)
@@ -402,6 +409,30 @@ static int fit_write_images(struct image_tool_params *params, char *fdt)
fdt_end_node(fdt);
}
+ /* And a TFA BL31 file if available */
+ if (params->fit_tfa_bl31) {
+ fdt_begin_node(fdt, FIT_TFA_BL31_PROP "-1");
+
+ fdt_property_string(fdt, FIT_TYPE_PROP, FIT_TFA_BL31_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_tfa_bl31);
+ fdt_property_string(fdt, FIT_DESC_PROP, str);
+
+ ret = fdt_property_file(params, fdt, FIT_DATA_PROP,
+ params->fit_tfa_bl31);
+ if (ret)
+ return ret;
+ fdt_property_u32(fdt, FIT_LOAD_PROP, params->fit_tfa_bl31_addr);
+ fdt_property_u32(fdt, FIT_ENTRY_PROP, params->fit_tfa_bl31_addr);
+ fit_add_hash_or_sign(params, fdt, true);
+ if (ret)
+ return ret;
+ fdt_end_node(fdt);
+ }
+
fdt_end_node(fdt);
return 0;
@@ -421,7 +452,7 @@ static void fit_write_configs(struct image_tool_params *params, char *fdt)
struct content_info *cont;
const char *typename;
char str[100];
- int upto;
+ int upto, len;
fdt_begin_node(fdt, "configurations");
fdt_property_string(fdt, FIT_DEFAULT_PROP, "conf-1");
@@ -439,8 +470,16 @@ static void fit_write_configs(struct image_tool_params *params, char *fdt)
typename = genimg_get_type_short_name(params->fit_image_type);
snprintf(str, sizeof(str), "%s-1", typename);
+ len = strlen(str);
fdt_property_string(fdt, typename, str);
- fdt_property_string(fdt, FIT_LOADABLE_PROP, 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;
+ }
+
+ fdt_property(fdt, FIT_LOADABLE_PROP, str, len + 1);
if (params->fit_ramdisk)
fdt_property_string(fdt, FIT_RAMDISK_PROP,
@@ -456,8 +495,17 @@ static void fit_write_configs(struct image_tool_params *params, char *fdt)
fdt_begin_node(fdt, "conf-1");
typename = genimg_get_type_short_name(params->fit_image_type);
snprintf(str, sizeof(str), "%s-1", typename);
+ len = strlen(str);
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;
+ }
+
+ fdt_property(fdt, FIT_LOADABLE_PROP, str, len + 1);
+
if (params->fit_ramdisk)
fdt_property_string(fdt, FIT_RAMDISK_PROP,
FIT_RAMDISK_PROP "-1");
diff --git a/tools/imagetool.h b/tools/imagetool.h
index 57be608210a..866b8834fd7 100644
--- a/tools/imagetool.h
+++ b/tools/imagetool.h
@@ -99,6 +99,8 @@ struct image_tool_params {
const char *engine_id; /* Engine to use for signing */
bool reset_timestamp; /* Reset the timestamp on an existing image */
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 */
};
/*
diff --git a/tools/mkimage.c b/tools/mkimage.c
index 847453970ab..12183270776 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -160,7 +160,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:vVx";
+ "a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:ln:N:o:O:p:qrR:stT:vVxy:Y:";
static const struct option longopts[] = {
{ "load-address", required_argument, NULL, 'a' },
@@ -196,6 +196,8 @@ static const struct option longopts[] = {
{ "verbose", no_argument, NULL, 'v' },
{ "version", no_argument, NULL, 'V' },
{ "xip", no_argument, NULL, 'x' },
+ { "tfa-bl31-file", no_argument, NULL, 'y' },
+ { "tfa-bl31-addr", no_argument, NULL, 'Y' },
{ /* sentinel */ },
};
@@ -367,6 +369,17 @@ static void process_args(int argc, char **argv)
case 'x':
params.xflag++;
break;
+ case 'y':
+ params.fit_tfa_bl31 = optarg;
+ break;
+ case 'Y':
+ params.fit_tfa_bl31_addr = strtoull(optarg, &ptr, 16);
+ if (*ptr) {
+ fprintf(stderr, "%s: invalid TFA BL31 address %s\n",
+ params.cmdname, optarg);
+ exit(EXIT_FAILURE);
+ }
+ break;
default:
usage("Invalid option");
}