tools: mkimage: support pack empty file for multi image

Muilt image bootflow requires ramdisk as a mandory component,
so that we have to pack a empty ramdisk into multi image at
some time.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I551ae832fbc68514ead0a3337148593e3113394f
This commit is contained in:
Joseph Chen 2020-03-27 18:02:55 +08:00
parent a86a723e2e
commit 40d08d0f10
3 changed files with 9 additions and 2 deletions

View File

@ -239,7 +239,7 @@ ulong image_multi_count(const image_header_t *hdr)
size = (uint32_t *)image_get_data(hdr);
/* count non empty slots */
for (i = 0; size[i]; ++i)
for (i = 0; size[i] != IMAGE_PARAM_INVAL; ++i)
count++;
return count;

View File

@ -709,6 +709,8 @@ int boot_get_kbd(struct lmb *lmb, bd_t **kbd);
/*******************************************************************/
/* Legacy format specific code (prefixed with image_) */
/*******************************************************************/
#define IMAGE_PARAM_INVAL 0xffffffff
static inline uint32_t image_get_header_size(void)
{
return (sizeof(image_header_t));

View File

@ -479,7 +479,7 @@ int main(int argc, char **argv)
}
size = cpu_to_uimage (sbuf.st_size);
} else {
size = 0;
size = IMAGE_PARAM_INVAL;
}
if (write(ifd, (char *)&size, sizeof(size)) != sizeof(size)) {
@ -650,6 +650,11 @@ copy_file (int ifd, const char *datafile, int pad)
exit (EXIT_FAILURE);
}
if (sbuf.st_size == 0) {
(void) close (dfd);
return;
}
ptr = mmap(0, sbuf.st_size, PROT_READ, MAP_SHARED, dfd, 0);
if (ptr == MAP_FAILED) {
fprintf (stderr, "%s: Can't read %s: %s\n",