mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Wadim Egorov <w.egorov@phytec.de>
To: barebox@lists.infradead.org
Cc: p-stockmar@ti.com
Subject: [PATCH] scripts/omap_signGP: Fix image size in GP header
Date: Mon, 15 Jun 2015 10:29:33 +0200	[thread overview]
Message-ID: <1434356973-16490-1-git-send-email-w.egorov@phytec.de> (raw)

The size field in the GP header has to include its own size.
This can be easily misread in the TRM.

Sometimes, when the gp_header size is not included, the ROM code
will not copy the complete MLO into the SRAM. This happens when the MLO file
size is 98823 bytes (and the value of GP header size field is 98303 bytes).

Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
---

This patch is the fix for the following reported issue:

  http://lists.infradead.org/pipermail/barebox/2015-March/023022.html

A 98823 bytes big lzo packed MLO will not be copied correctly to the SRAM.
This will cause a failure in the lzo code. The lzo code expects a correct MLO
and is not the real problem here!

We have discussed this problem with TI.

---
 scripts/omap_signGP.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/scripts/omap_signGP.c b/scripts/omap_signGP.c
index 482cfac..ac47fdf 100644
--- a/scripts/omap_signGP.c
+++ b/scripts/omap_signGP.c
@@ -317,8 +317,15 @@ int main(int argc, char *argv[])
 		if (fwrite(&config_header, 1, 512, ofile) <= 0)
 			pdie("fwrite");
 
+	/* The size field in the header needs to include the
+	 * size of the gp_header */
+	len += sizeof(struct gp_header);
+
 	if (fwrite(&len, 1, 4, ofile) <= 0)
 		pdie("fwrite");
+
+	len -= sizeof(struct gp_header);
+
 	if (fwrite(&loadaddr, 1, 4, ofile) <= 0)
 		pdie("fwrite");
 	for (i = 0; i < len; i++) {
-- 
1.9.1


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

             reply	other threads:[~2015-06-15  8:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-15  8:29 Wadim Egorov [this message]
2015-06-17  5:47 ` 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=1434356973-16490-1-git-send-email-w.egorov@phytec.de \
    --to=w.egorov@phytec.de \
    --cc=barebox@lists.infradead.org \
    --cc=p-stockmar@ti.com \
    /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