mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 1/3] scripts: imx-image: Add support for max_load_size option
Date: Tue, 20 Nov 2018 09:40:58 +0100	[thread overview]
Message-ID: <20181120084100.8737-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20181120084100.8737-1-s.hauer@pengutronix.de>

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>
---
 arch/arm/mach-imx/include/mach/imx-header.h |  1 +
 scripts/imx/imx-image.c                     | 10 +++++++++-
 scripts/imx/imx.c                           | 13 +++++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/include/mach/imx-header.h b/arch/arm/mach-imx/include/mach/imx-header.h
index 05f1669318..50584bb24b 100644
--- a/arch/arm/mach-imx/include/mach/imx-header.h
+++ b/arch/arm/mach-imx/include/mach/imx-header.h
@@ -96,6 +96,7 @@ struct config_data {
 	uint32_t image_load_addr;
 	uint32_t image_dcd_offset;
 	uint32_t image_size;
+	uint32_t max_load_size;
 	uint32_t load_size;
 	char *outfile;
 	char *srkfile;
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,
-- 
2.19.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2018-11-20  8:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-20  8:40 [PATCH 0/3] ARM: images: Use piggydata Sascha Hauer
2018-11-20  8:40 ` Sascha Hauer [this message]
2018-11-20  8:40 ` [PATCH 2/3] ARM: i.MX: Add max_load_size option to boards that will need it Sascha Hauer
2018-11-30  6:11   ` Andrey Smirnov
2018-11-30  7:35     ` Sascha Hauer
2018-12-01  0:34       ` Andrey Smirnov
2018-11-20  8:41 ` [PATCH 3/3] ARM: images: use piggydata Sascha Hauer
2019-01-14 16:34 ` [PATCH 0/3] ARM: images: Use piggydata Roland Hieber
2019-01-14 17:22   ` Sam Ravnborg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181120084100.8737-2-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox