mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 1/8] imx-image: Correctly fill image size in prepended header
@ 2015-05-03 21:55 Andrey Smirnov
  2015-05-03 21:55 ` [PATCH v2 3/8] bootstrap_read_devfs(): Check for errors from devfs_add_partition() Andrey Smirnov
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Andrey Smirnov @ 2015-05-03 21:55 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

If called with '-b' option 'imx-image' tool prepends barebox header to
the image, but the tool does not fill the data at image size offset
correctly. Fix that.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---

This patch supercedes the one sent earlier titled:
 "[PATCH 1/8] Makefile.lib: Fix i.MX image size after generation"

 scripts/imx/Makefile    |  2 ++
 scripts/imx/imx-image.c | 12 ++++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/scripts/imx/Makefile b/scripts/imx/Makefile
index be0b490..ee0acc1 100644
--- a/scripts/imx/Makefile
+++ b/scripts/imx/Makefile
@@ -6,5 +6,7 @@ always          := $(hostprogs-y)
 HOSTCFLAGS_imx-usb-loader.o = `pkg-config --cflags libusb-1.0`
 HOSTLOADLIBES_imx-usb-loader  = `pkg-config --libs libusb-1.0`

+HOSTCFLAGS_imx-image.o = -I$(srctree)
+
 imx-usb-loader-objs := imx-usb-loader.o
 imx-image-objs := imx-image.o
diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
index 25ea4d8..c0181df 100644
--- a/scripts/imx/imx-image.c
+++ b/scripts/imx/imx-image.c
@@ -27,6 +27,8 @@
 #include <fcntl.h>
 #include <endian.h>

+#include <include/filetype.h>
+
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 #define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER)
 #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
@@ -92,8 +94,11 @@ static int add_header_v1(void *buf, int offset, uint32_t loadaddr, uint32_t imag
 	struct imx_flash_header *hdr;
 	int dcdsize = curdcd * sizeof(uint32_t);

-	if (add_barebox_header)
+	if (add_barebox_header) {
+		uint32_t *psize = buf + ARM_HEAD_SIZE_OFFSET;
 		memcpy(buf, bb_header, sizeof(bb_header));
+		*psize = imagesize;
+	}

 	buf += offset;
 	hdr = buf;
@@ -178,8 +183,11 @@ static int add_header_v2(void *buf, int offset, uint32_t loadaddr, uint32_t imag
 	struct imx_flash_header_v2 *hdr;
 	int dcdsize = curdcd * sizeof(uint32_t);

-	if (add_barebox_header)
+	if (add_barebox_header) {
+		uint32_t *psize = buf + ARM_HEAD_SIZE_OFFSET;
 		memcpy(buf, bb_header, sizeof(bb_header));
+		*psize = imagesize;
+	}

 	buf += offset;
 	hdr = buf;
--
2.1.4

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

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

end of thread, other threads:[~2015-05-04  7:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-03 21:55 [PATCH v2 1/8] imx-image: Correctly fill image size in prepended header Andrey Smirnov
2015-05-03 21:55 ` [PATCH v2 3/8] bootstrap_read_devfs(): Check for errors from devfs_add_partition() Andrey Smirnov
2015-05-03 21:55 ` [PATCH v2 5/8] bootstrap_read_devfs(): Fix potential memory leak Andrey Smirnov
2015-05-03 21:55 ` [PATCH v2 7/8] bootstrap_read_devfs(): Remove all partitions upon function completion Andrey Smirnov
2015-05-03 22:05 ` [PATCH v2 1/8] imx-image: Correctly fill image size in prepended header Marc Kleine-Budde
     [not found]   ` <CAHQ1cqEoL1PD4Cg7G52YvosXmsmcg1jckGL9-65_J-=qHc3XvA@mail.gmail.com>
2015-05-03 22:34     ` Marc Kleine-Budde
2015-05-04  7:41 ` Sascha Hauer

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