From 17c7e57f6e0a2401216951717eb9fa48ac3e97fd Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Fri, 19 Jun 2020 14:26:52 +0200 Subject: 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 --- scripts/imx/imx-image.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'scripts') 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 */ -- cgit v1.2.3