[PATCH 05/20] scripts: imx-image: Fix writing image with IVT offset = 0

Sascha Hauer s.hauer at pengutronix.de
Tue Jun 23 09:15:51 EDT 2020


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 at pengutronix.de>
---
 scripts/imx/imx-image.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
index bbd7e95bc2..9c40cf7340 100644
--- a/scripts/imx/imx-image.c
+++ b/scripts/imx/imx-image.c
@@ -993,13 +993,12 @@ int main(int argc, char *argv[])
 		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);
 	}
 
 	xwrite(outfd, infile, insize);
-- 
2.27.0




More information about the barebox mailing list