summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2020-06-19 14:26:52 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-07-14 20:18:38 +0200
commit17c7e57f6e0a2401216951717eb9fa48ac3e97fd (patch)
treebf58ea3f8adf1ae483b7f4d042bf457eb83b744b /scripts
parent03ecd7086f232c21a8a8121db09d5d465e16cda1 (diff)
downloadbarebox-17c7e57f6e0a2401216951717eb9fa48ac3e97fd.tar.gz
barebox-17c7e57f6e0a2401216951717eb9fa48ac3e97fd.tar.xz
scripts: imx-image: Fix writing image with IVT offset = 0
When we have written the barebox header the next thing we do is to lseek forward by the size of the header gap. This means our position is already inside of the rest of the image and we have to skip this offset from the rest of the image. This only works when the rest of the image doesn't have anything needed in the first few bytes. Some newer SoCs have the IVT at offset 0 though, so with the current approach we skip writing the IVT. Instead of doing this we should lseek to the end of the header gap. With this we are at the right position to just write the full image containing the IVT. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/imx/imx-image.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
index bbd7e95bc2..9ab704292f 100644
--- a/scripts/imx/imx-image.c
+++ b/scripts/imx/imx-image.c
@@ -978,10 +978,7 @@ int main(int argc, char *argv[])
}
if (data.cpu_type == IMX_CPU_IMX35) {
- xwrite(outfd, add_barebox_header ? bb_header : buf,
- sizeof_bb_header);
- xwrite(outfd, buf + sizeof_bb_header,
- header_len - sizeof_bb_header);
+ xwrite(outfd, buf, header_len);
xwrite(outfd, buf, header_len);
} else {
if (add_barebox_header &&
@@ -990,18 +987,17 @@ int main(int argc, char *argv[])
exit(1);
}
- xwrite(outfd, add_barebox_header ? bb_header : buf,
- sizeof_bb_header);
-
- if (lseek(outfd, data.header_gap, SEEK_CUR) < 0) {
+ if (lseek(outfd, data.header_gap, SEEK_SET) < 0) {
perror("lseek");
exit(1);
}
- xwrite(outfd, buf + sizeof_bb_header,
- header_len - sizeof_bb_header);
+ xwrite(outfd, buf, header_len);
}
+ if (add_barebox_header)
+ pwrite(outfd, bb_header, sizeof_bb_header, 0);
+
xwrite(outfd, infile, insize);
/* pad until next 4k boundary */