summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDenis Osterland-Heim <denis.osterland@diehl.com>2021-03-22 13:02:22 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2021-03-30 07:42:26 +0200
commit07fa886b52ba7a72355ea78771dde53d1bb0bdf7 (patch)
treeb24644dc13089c957be3e278b2e4e3366b0d0359 /scripts
parentc80eb884b8260e72d6eb50b30bca7a08a478e45e (diff)
downloadbarebox-07fa886b52ba7a72355ea78771dde53d1bb0bdf7.tar.gz
barebox-07fa886b52ba7a72355ea78771dde53d1bb0bdf7.tar.xz
scripts: imx: add support for additional hab Blocks
This allows to specifiy additional signed blocks in the format `offset+size@address` within the imximg. It is needed by the uuu tool, which loads the image different to the imx-usb-loader. It loads the DCD always to 0x910000 in the OCRAM. So this area have to be signed as well. In my case this needs `hab_blocks 0x42c+0x1f0@0x910000`. It supports to remove quotes to support Kconfig variable here. Signed-off-by: Denis Osterland-Heim <denis.osterland@diehl.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/imx/imx.c52
1 files changed, 50 insertions, 2 deletions
diff --git a/scripts/imx/imx.c b/scripts/imx/imx.c
index 6b8dabd047..ce18778f54 100644
--- a/scripts/imx/imx.c
+++ b/scripts/imx/imx.c
@@ -328,6 +328,7 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
{
char *str;
int ret;
+ int i;
uint32_t signed_size = data->load_size;
uint32_t offset = data->image_ivt_offset;
@@ -352,7 +353,7 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
}
if (signed_size > 0) {
- ret = asprintf(&str, "Blocks = 0x%08x 0x%08x 0x%08x \"%s\"\n",
+ ret = asprintf(&str, "Blocks = 0x%08x 0x%08x 0x%08x \"%s\"",
data->image_load_addr + data->image_ivt_offset, offset,
signed_size - data->image_ivt_offset, data->outfile);
} else {
@@ -365,10 +366,57 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
return -ENOMEM;
ret = hab_add_str(data, str);
+ free(str);
if (ret)
return ret;
- return 0;
+ for (i = 1; i < argc; i++) {
+ uint32_t addr;
+ uint32_t off;
+ uint32_t size;
+ char *b;
+ char *e;
+
+ b = argv[i];
+ if (*b == '"') // remove leading qoute
+ b++;
+ if (!*b || *b == '"')
+ continue; // skip if empty
+
+ off = strtoul(b, &e, 0);
+ if (*e != '+') {
+ fprintf(stderr, "failed to find '+' in '%s'\n", b);
+ fprintf(stderr, "format off+size@addr expected, but given: %s\n", argv[i]);
+ return -EINVAL;
+ }
+
+ b = e + 1;
+ size = strtoul(b, &e, 0);
+ if (*e != '@') {
+ fprintf(stderr, "failed to find '@' in '%s'\n", b);
+ fprintf(stderr, "format off+size@addr expected, but given: %s\n", argv[i]);
+ return -EINVAL;
+ }
+
+ b = e + 1;
+ addr = strtoul(b, &e, 0);
+ if (*e && *e != '"') { // ignore trailing qoute
+ fprintf(stderr, "unexpected char at the end: '%c'\n", *e);
+ fprintf(stderr, "format off+size@addr expected, but given: %s\n", argv[i]);
+ return -EINVAL;
+ }
+
+ ret = asprintf(&str, ", 0x%08x 0x%08x 0x%08x \"%s\"", addr, off, size, data->outfile);
+ if (ret < 0)
+ return -ENOMEM;
+
+ ret = hab_add_str(data, str);
+ free(str);
+ if (ret)
+ return ret;
+ }
+
+ return hab_add_str(data, "\n");
}
static int do_hab_encrypt(struct config_data *data, int argc, char *argv[])