mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: barebox@lists.infradead.org
Cc: sha@pengutronix.de
Subject: [PATCH 04/10] imx-image: introduce HEADER_LEN and replace several 0x1000 and 4096
Date: Wed,  1 Apr 2015 18:14:09 +0200	[thread overview]
Message-ID: <1427904855-32548-5-git-send-email-mkl@pengutronix.de> (raw)
In-Reply-To: <1427904855-32548-1-git-send-email-mkl@pengutronix.de>

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 scripts/imx/imx-image.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
index 45f97504054e..89cb8240e40d 100644
--- a/scripts/imx/imx-image.c
+++ b/scripts/imx/imx-image.c
@@ -32,6 +32,7 @@
 #define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER)
 
 #define MAX_DCD 1024
+#define HEADER_LEN 0x1000	/* length of the blank area + IVT + DCD */
 
 static uint32_t image_load_addr;
 static uint32_t image_dcd_offset;
@@ -185,7 +186,7 @@ static int add_header_v2(void *buf, int offset, uint32_t loadaddr, uint32_t imag
 	hdr->header.length	= htobe16(32);
 	hdr->header.version	= IVT_VERSION;
 
-	hdr->entry		= loadaddr + 0x1000;
+	hdr->entry		= loadaddr + HEADER_LEN;
 	hdr->dcd_ptr		= loadaddr + offset + offsetof(struct imx_flash_header_v2, dcd_header);
 	hdr->boot_data_ptr	= loadaddr + offset + offsetof(struct imx_flash_header_v2, boot_data);
 	hdr->self		= loadaddr + offset;
@@ -706,7 +707,7 @@ int main(int argc, char *argv[])
 	if (ret)
 		exit(1);
 
-	buf = calloc(4096, 1);
+	buf = calloc(1, HEADER_LEN);
 	if (!buf)
 		exit(1);
 
@@ -732,14 +733,14 @@ int main(int argc, char *argv[])
 	}
 
 	/*
-	 * Add 0x1000 to the image size for the DCD.
+	 * Add HEADER_LEN to the image size for the blank aera + 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
 	 */
-	load_size = ((image_size + 0x1000) + 0xfff) & ~0xfff;
+	load_size = ((image_size + HEADER_LEN) + 0xfff) & ~0xfff;
 
 	switch (header_version) {
 	case 1:
@@ -760,14 +761,14 @@ int main(int argc, char *argv[])
 		exit(1);
 	}
 
-	ret = xwrite(outfd, buf, 4096);
+	ret = xwrite(outfd, buf, HEADER_LEN);
 	if (ret < 0) {
 		perror("write");
 		exit(1);
 	}
 
 	if (cpu_type == 35) {
-		ret = xwrite(outfd, buf, 4096);
+		ret = xwrite(outfd, buf, HEADER_LEN);
 		if (ret < 0) {
 			perror("write");
 			exit(1);
-- 
2.1.4


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

  parent reply	other threads:[~2015-04-01 16:14 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-01 16:14 [PATCH 01/10] add habv4 support for i.MX6 Marc Kleine-Budde
2015-04-01 16:14 ` [PATCH 01/10] imx-image: sort included header files Marc Kleine-Budde
2015-04-03  6:32   ` Sascha Hauer
2015-04-01 16:14 ` [PATCH 02/10] imx-image: add_header_v2(): replace hardcoded 0x400 by offset parameter Marc Kleine-Budde
2015-04-01 16:14 ` [PATCH 03/10] imx-image: replace 0x400 by FLASH_HEADER_OFFSET Marc Kleine-Budde
2015-04-01 16:14 ` Marc Kleine-Budde [this message]
2015-04-01 16:14 ` [PATCH 05/10] imx-image: mx35: increase load image size, due to dobule header Marc Kleine-Budde
2015-04-01 16:14 ` [PATCH 06/10] imx-image: main: make use of round_up instead of open coding it Marc Kleine-Budde
2015-04-01 16:14 ` [PATCH 07/10] imx-image: pad generated image to 4k Marc Kleine-Budde
2015-04-01 16:14 ` [PATCH 08/10] imx-image: add option to prepare image for HAB signing Marc Kleine-Budde
2015-04-01 16:14 ` [PATCH 09/10] images: add HABv4 support for i.MX6 Marc Kleine-Budde
2015-04-01 16:17   ` Marc Kleine-Budde
2015-04-01 19:39   ` [PATCH v2] " Marc Kleine-Budde
2015-04-13 10:19     ` Sascha Hauer
2015-04-13 10:22       ` Marc Kleine-Budde
2015-04-01 16:14 ` [PATCH 10/10] habv4: add High Assurance Boot v4 Marc Kleine-Budde
2015-04-13 10:30   ` Sascha Hauer
2015-04-03  6:33 ` [PATCH 01/10] add habv4 support for i.MX6 Sascha Hauer

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=1427904855-32548-5-git-send-email-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=sha@pengutronix.de \
    /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