summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2018-12-07 08:12:39 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2018-12-07 08:12:39 +0100
commit1d8bb9be35508b62a6f6d0d792fa29568710a2a9 (patch)
treef77f02aea8e21522c6b0865916d2bfab4cdf19f5 /scripts
parent3d565eac1c01ed9c50951bd0c097c32e2e650a45 (diff)
parent113677818502a071aeaddffd0b64dce3dcab220d (diff)
downloadbarebox-1d8bb9be35508b62a6f6d0d792fa29568710a2a9.tar.gz
barebox-1d8bb9be35508b62a6f6d0d792fa29568710a2a9.tar.xz
Merge branch 'for-next/imx'
Diffstat (limited to 'scripts')
-rw-r--r--scripts/imx/imx-image.c22
-rw-r--r--scripts/imx/imx.c13
2 files changed, 32 insertions, 3 deletions
diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
index fa93e47917..34a072039d 100644
--- a/scripts/imx/imx-image.c
+++ b/scripts/imx/imx-image.c
@@ -132,6 +132,14 @@ void RSA_get0_key(const RSA *r, const BIGNUM **n,
if (d != NULL)
*d = r->d;
}
+
+RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey)
+{
+ if (pkey->type != EVP_PKEY_RSA)
+ return NULL;
+
+ return pkey->pkey.rsa;
+}
#endif
static int extract_key(const char *certfile, uint8_t **modulus, int *modulus_len,
@@ -324,7 +332,10 @@ static size_t add_header_v2(const struct config_data *data, void *buf)
hdr->self = loadaddr + offset;
hdr->boot_data.start = loadaddr;
- hdr->boot_data.size = imagesize;
+ if (data->max_load_size && imagesize > data->max_load_size)
+ hdr->boot_data.size = data->max_load_size;
+ else
+ hdr->boot_data.size = imagesize;
if (data->csf) {
hdr->csf = loadaddr + imagesize;
@@ -797,12 +808,12 @@ int main(int argc, char *argv[])
}
/*
- * Add HEADER_LEN to the image size for the blank aera + IVT + DCD.
+ * Add HEADER_LEN to the image size for the blank area + IVT + DCD.
* Align up to a 4k boundary, because:
* - at least i.MX5 NAND boot only reads full NAND pages and misses the
* last partial NAND page.
* - i.MX6 SPI NOR boot corrupts the last few bytes of an image loaded
- * in ver funy ways when the image size is not 4 byte aligned
+ * in very funny ways when the image size is not 4 byte aligned
*/
data.load_size = roundup(data.image_size + header_len, 0x1000);
@@ -810,6 +821,11 @@ int main(int argc, char *argv[])
if (ret)
exit(1);
+ if (data.max_load_size && (sign_image || data.encrypt_image)) {
+ fprintf(stderr, "Specifying max_load_size is incompatible with HAB signing/encrypting\n");
+ exit(1);
+ }
+
if (!sign_image)
data.csf = NULL;
diff --git a/scripts/imx/imx.c b/scripts/imx/imx.c
index 43f67da288..f37f151acb 100644
--- a/scripts/imx/imx.c
+++ b/scripts/imx/imx.c
@@ -279,6 +279,16 @@ static int do_soc(struct config_data *data, int argc, char *argv[])
return -EINVAL;
}
+static int do_max_load_size(struct config_data *data, int argc, char *argv[])
+{
+ if (argc < 2)
+ return -EINVAL;
+
+ data->max_load_size = strtoul(argv[1], NULL, 0);
+
+ return 0;
+}
+
static int hab_add_str(struct config_data *data, const char *str)
{
int len = strlen(str);
@@ -590,6 +600,9 @@ struct command cmds[] = {
}, {
.name = "soc",
.parse = do_soc,
+ }, {
+ .name = "max_load_size",
+ .parse = do_max_load_size,
}, {
.name = "hab",
.parse = do_hab,