summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorStefan Roese <sr@denx.de>2015-10-28 07:53:58 +0100
committerLuka Perkov <luka.perkov@sartura.hr>2015-11-17 23:41:41 +0100
commitea8b6877a84c6e219bc3c7fe3ef08f7124cf4305 (patch)
treec3d8618cb0c5741bbd292d17b0ed232015b7d621 /tools
parent490753ace38c436f05b02a827bfe9b0ace44990a (diff)
downloadu-boot-imx-ea8b6877a84c6e219bc3c7fe3ef08f7124cf4305.zip
u-boot-imx-ea8b6877a84c6e219bc3c7fe3ef08f7124cf4305.tar.gz
u-boot-imx-ea8b6877a84c6e219bc3c7fe3ef08f7124cf4305.tar.bz2
tools/kwbimage.c: Fix generation of binary header
The binary header ends with one lword, defining if another header follows this one. This additions 4 bytes need to be taken into account in the generation of the header size. And the complete 4 bytes at the end of this binary header need to get cleared. Signed-off-by: Stefan Roese <sr@denx.de> Cc: Luka Perkov <luka.perkov@sartura.hr> Cc: Kevin Smith <kevin.smith@elecsyscorp.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/kwbimage.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index d33f1b6..5f6d91c 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -417,7 +417,13 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,
binhdrsz = sizeof(struct opt_hdr_v1) +
(binarye->binary.nargs + 1) * sizeof(unsigned int) +
s.st_size;
- binhdrsz = ALIGN_SUP(binhdrsz, 32);
+
+ /*
+ * The size includes the binary image size, rounded
+ * up to a 4-byte boundary. Plus 4 bytes for the
+ * next-header byte and 3-byte alignment at the end.
+ */
+ binhdrsz = ALIGN_SUP(binhdrsz, 4) + 4;
hdr->headersz_lsb = binhdrsz & 0xFFFF;
hdr->headersz_msb = (binhdrsz & 0xFFFF0000) >> 16;
@@ -441,7 +447,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,
fclose(bin);
- cur += s.st_size;
+ cur += ALIGN_SUP(s.st_size, 4);
/*
* For now, we don't support more than one binary
@@ -449,7 +455,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,
* supported. So, the binary header is necessarily the
* last one
*/
- *((unsigned char *)cur) = 0;
+ *((uint32_t *)cur) = 0x00000000;
cur += sizeof(uint32_t);
}