mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] scripts/omap_signGP: Fix image size in GP header
@ 2015-06-15  8:29 Wadim Egorov
  2015-06-17  5:47 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Wadim Egorov @ 2015-06-15  8:29 UTC (permalink / raw)
  To: barebox; +Cc: p-stockmar

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] scripts/omap_signGP: Fix image size in GP header
  2015-06-15  8:29 [PATCH] scripts/omap_signGP: Fix image size in GP header Wadim Egorov
@ 2015-06-17  5:47 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2015-06-17  5:47 UTC (permalink / raw)
  To: Wadim Egorov; +Cc: barebox, p-stockmar

On Mon, Jun 15, 2015 at 10:29:33AM +0200, Wadim Egorov wrote:
> 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>
> ---

Applied, thanks

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-17  5:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-15  8:29 [PATCH] scripts/omap_signGP: Fix image size in GP header Wadim Egorov
2015-06-17  5:47 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox