char *ptr;
int retval = 0;
struct image_type_params *tparams = NULL;
+ int pad_len = 0;
/* Init Freescale PBL Boot image generation/list support */
init_pbl_image_type();
* allocate memory for the header itself.
*/
if (tparams->vrec_header)
- tparams->vrec_header(¶ms, tparams);
+ pad_len = tparams->vrec_header(¶ms, tparams);
else
memset(tparams->hdr, 0, tparams->header_size);
/* PBL has special Image format, implements its' own */
pbl_load_uboot(ifd, ¶ms);
} else {
- copy_file (ifd, params.datafile, 0);
+ copy_file(ifd, params.datafile, pad_len);
}
}
unsigned char *ptr;
int tail;
int zero = 0;
+ uint8_t zeros[4096];
int offset = 0;
int size;
struct image_type_params *tparams = mkimage_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) {
fprintf (stderr, "Adding Image %s\n", datafile);
}
exit (EXIT_FAILURE);
}
- if (pad && ((tail = size % 4) != 0)) {
+ tail = size % 4;
+ if ((pad == 1) && (tail != 0)) {
if (write(ifd, (char *)&zero, 4-tail) != 4-tail) {
fprintf (stderr, "%s: Write error on %s: %s\n",
strerror(errno));
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);
+ }
}
(void) munmap((void *)ptr, sbuf.st_size);
/*
* This callback function will be executed for variable size record
* It is expected to build this header in memory and return its length
- * and a pointer to it
+ * and a pointer to it by using image_type_params.header_size and
+ * image_type_params.hdr. The return value shall indicate if an
+ * additional padding should be used when copying the data image
+ * by returning the padding length.
*/
int (*vrec_header) (struct mkimage_params *,
struct image_type_params *);