[PATCH] scripts/omap_signGP: Fix image size in GP header

Wadim Egorov w.egorov at phytec.de
Mon Jun 15 01:29:33 PDT 2015


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 at 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




More information about the barebox mailing list