Signed-off-by: Marc Kleine-Budde <[email protected]>
---
 scripts/imx/imx-image.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
index ec2e8deb015b..1c032a3cb142 100644
--- a/scripts/imx/imx-image.c
+++ b/scripts/imx/imx-image.c
@@ -654,6 +654,7 @@ int main(int argc, char *argv[])
        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) {
@@ -786,7 +787,7 @@ int main(int argc, char *argv[])
        }
 
        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) {
@@ -803,6 +804,18 @@ int main(int argc, char *argv[])
                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");
-- 
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to