summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2018-11-16 16:38:22 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2018-11-30 08:31:10 +0100
commit38a995509863505b1b13995d9ba318fc1224929e (patch)
treead6ee0b5c225dd5e551ee426d372590beaf2e565 /scripts
parent363ffc7f48073a16df82e02703141fe95235c7e9 (diff)
downloadbarebox-38a995509863505b1b13995d9ba318fc1224929e.tar.gz
barebox-38a995509863505b1b13995d9ba318fc1224929e.tar.xz
scripts: imx-image: Add support for max_load_size option
When an image is loaded to SRAM we can normally only load a part of the full image, limited by the available space in SRAM. We currently load the pblb image which is the executable part of the PBL without the compressed barebox payload. We are going to link the compressed barebox image into the pbl image though, so we can't see the desired load size from outside the image anymore. This adds a max_load_size option to set this size explicitly. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/imx/imx-image.c10
-rw-r--r--scripts/imx/imx.c13
2 files changed, 22 insertions, 1 deletions
diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
index 9c173cd23b..5fd34065ec 100644
--- a/scripts/imx/imx-image.c
+++ b/scripts/imx/imx-image.c
@@ -324,7 +324,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;
@@ -810,6 +813,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,