summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2015-05-06 12:32:06 -0700
committerSascha Hauer <s.hauer@pengutronix.de>2015-05-07 09:49:41 +0200
commit6f1d94b8892ffa995b2e0ca716d82fd7efaeea18 (patch)
tree470b1aa8d5ddc4fca639d766d360a847d5f610b4 /scripts
parent903c9477a08c5655161779ef4144886928ecc7d1 (diff)
downloadbarebox-6f1d94b8892ffa995b2e0ca716d82fd7efaeea18.tar.gz
barebox-6f1d94b8892ffa995b2e0ca716d82fd7efaeea18.tar.xz
imx-image: Correctly fill image size in prepended header
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> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/imx/Makefile2
-rw-r--r--scripts/imx/imx-image.c11
2 files changed, 12 insertions, 1 deletions
diff --git a/scripts/imx/Makefile b/scripts/imx/Makefile
index be0b490108..ee0acc1514 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 25ea4d8d1b..e765c1d3d6 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))
@@ -91,9 +93,12 @@ 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);
+ uint32_t *psize = buf + ARM_HEAD_SIZE_OFFSET;
- if (add_barebox_header)
+ if (add_barebox_header) {
memcpy(buf, bb_header, sizeof(bb_header));
+ *psize = imagesize;
+ }
buf += offset;
hdr = buf;
@@ -177,6 +182,7 @@ 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);
+ uint32_t *psize = buf + ARM_HEAD_SIZE_OFFSET;
if (add_barebox_header)
memcpy(buf, bb_header, sizeof(bb_header));
@@ -201,6 +207,9 @@ static int add_header_v2(void *buf, int offset, uint32_t loadaddr, uint32_t imag
hdr->boot_data.size += CSF_LEN;
}
+ if (add_barebox_header)
+ *psize = hdr->boot_data.size;
+
hdr->dcd_header.tag = TAG_DCD_HEADER;
hdr->dcd_header.length = htobe16(sizeof(uint32_t) + dcdsize);
hdr->dcd_header.version = DCD_VERSION;