diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-08-15 14:43:53 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-08-15 14:53:17 +0200 |
commit | d3924e4fe5c8a1445ca677065fa1376b51d3db7e (patch) | |
tree | 3aa9d85e8a925cee1398ee0370d29d72cdb3cb25 | |
parent | ba3b39d5f0f5523b6895308d35874726009647fa (diff) | |
download | barebox-d3924e4fe5c8a1445ca677065fa1376b51d3db7e.tar.gz barebox-d3924e4fe5c8a1445ca677065fa1376b51d3db7e.tar.xz |
imx-image: Align image size
Several boot modes on i.MX can't cope with partial pages or
non word aligned image lengths, so align the size to 4k.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | scripts/imx/imx-image.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c index 09fdc5f1c0..ec571ebf3e 100644 --- a/scripts/imx/imx-image.c +++ b/scripts/imx/imx-image.c @@ -632,7 +632,7 @@ int main(int argc, char *argv[]) char *imagename = NULL; char *outfile = NULL; void *buf; - size_t image_size = 0; + size_t image_size = 0, load_size; struct stat s; int infd, outfd; int dcd_only = 0; @@ -714,12 +714,22 @@ int main(int argc, char *argv[]) exit (0); } + /* + * Add 0x1000 to the image size for the DCD. + * Align up to a 4k boundary, because: + * - at least i.MX5 NAND boot only reads full NAND pages and misses the + * last partial NAND page. + * - i.MX6 SPI NOR boot corrupts the last few bytes of an image loaded + * in ver funy ways when the image size is not 4 byte aligned + */ + load_size = ((image_size + 0x1000) + 0xfff) & ~0xfff; + switch (header_version) { case 1: - add_header_v1(buf, image_dcd_offset, image_load_addr, image_size + 0x1000); + add_header_v1(buf, image_dcd_offset, image_load_addr, load_size); break; case 2: - add_header_v2(buf, image_dcd_offset, image_load_addr, image_size + 0x1000); + add_header_v2(buf, image_dcd_offset, image_load_addr, load_size); break; default: fprintf(stderr, "Congratulations! You're welcome to implement header version %d\n", |