diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c index 1abbde2..cff1997 100644 --- a/scripts/imx/imx-image.c +++ b/scripts/imx/imx-image.c @@ -653,6 +653,7 @@ struct stat s; int infd, outfd; int dcd_only = 0; + int now = 0; while ((opt = getopt(argc, argv, "c:hf:o:bd")) != -1) { switch (opt) { @@ -785,7 +786,7 @@ } while (image_size) { - int now = image_size < 4096 ? image_size : 4096; + now = image_size < 4096 ? image_size : 4096; ret = xread(infd, buf, now); if (ret) { @@ -802,6 +803,18 @@ image_size -= now; } + /* pad until next 4k boundary */ + now = 4096 - now; + if (now) { + memset(buf, 0x5a, now); + + ret = xwrite(outfd, buf, now); + if (ret) { + perror("write"); + exit(1); + } + } + ret = close(outfd); if (ret) { perror("close");