[U-Boot] [PATCH v5 11/41] mkimage: Allow padding to any length

Simon Glass sjg at chromium.org
Mon Aug 31 00:55:22 CEST 2015


At present there is an arbitrary limit of 4KB for padding. Rockchip needs
more than that, so remove this restriction.

Signed-off-by: Simon Glass <sjg at chromium.org>
Reviewed-by: Joe Hershberger <joe.hershberger at ni.com>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 tools/mkimage.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/tools/mkimage.c b/tools/mkimage.c
index e81d455..c50af05 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -488,12 +488,6 @@ copy_file (int ifd, const char *datafile, int pad)
 	int size;
 	struct image_type_params *tparams = imagetool_get_type(params.type);
 
-	if (pad >= sizeof(zeros)) {
-		fprintf(stderr, "%s: Can't pad to %d\n",
-			params.cmdname, pad);
-		exit(EXIT_FAILURE);
-	}
-
 	memset(zeros, 0, sizeof(zeros));
 
 	if (params.vflag) {
@@ -563,11 +557,18 @@ copy_file (int ifd, const char *datafile, int pad)
 			exit (EXIT_FAILURE);
 		}
 	} else if (pad > 1) {
-		if (write(ifd, (char *)&zeros, pad) != pad) {
-			fprintf(stderr, "%s: Write error on %s: %s\n",
-				params.cmdname, params.imagefile,
-				strerror(errno));
-			exit(EXIT_FAILURE);
+		while (pad > 0) {
+			int todo = sizeof(zeros);
+
+			if (todo > pad)
+				todo = pad;
+			if (write(ifd, (char *)&zeros, todo) != todo) {
+				fprintf(stderr, "%s: Write error on %s: %s\n",
+					params.cmdname, params.imagefile,
+					strerror(errno));
+				exit(EXIT_FAILURE);
+			}
+			pad -= todo;
 		}
 	}
 
-- 
2.5.0.457.gab17608



More information about the U-Boot mailing list