diff options
Diffstat (limited to 'mkbootimg/mkbootimg.c')
-rw-r--r-- | mkbootimg/mkbootimg.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/mkbootimg/mkbootimg.c b/mkbootimg/mkbootimg.c index b6a2801..ec7c61f 100644 --- a/mkbootimg/mkbootimg.c +++ b/mkbootimg/mkbootimg.c @@ -66,6 +66,10 @@ int usage(void) " [ --board <boardname> ]\n" " [ --base <address> ]\n" " [ --pagesize <pagesize> ]\n" + " [ --dt <filename> ]\n" + " [ --ramdisk_offset <address> ]\n" + " [ --second_offset <address> ]\n" + " [ --tags_offset <address> ]\n" " [ --id ]\n" " -o|--output <filename>\n" ); @@ -74,11 +78,12 @@ int usage(void) -static unsigned char padding[16384] = { 0, }; +static unsigned char padding[131072] = { 0, }; static void print_id(const uint8_t *id, size_t id_len) { printf("0x"); - for (unsigned i = 0; i < id_len; i++) { + unsigned i = 0; + for (i = 0; i < id_len; i++) { printf("%02x", id[i]); } printf("\n"); @@ -115,6 +120,8 @@ int main(int argc, char **argv) char *cmdline = ""; char *bootimg = NULL; char *board = ""; + char *dt_fn = 0; + void *dt_data = 0; uint32_t pagesize = 2048; int fd; SHA_CTX ctx; @@ -167,10 +174,14 @@ int main(int argc, char **argv) } else if(!strcmp(arg,"--pagesize")) { pagesize = strtoul(val, 0, 10); if ((pagesize != 2048) && (pagesize != 4096) - && (pagesize != 8192) && (pagesize != 16384)) { + && (pagesize != 8192) && (pagesize != 16384) + && (pagesize != 32768) && (pagesize != 65536) + && (pagesize != 131072)) { fprintf(stderr,"error: unsupported page size %d\n", pagesize); return -1; } + } else if(!strcmp(arg, "--dt")) { + dt_fn = val; } else { return usage(); } @@ -243,6 +254,14 @@ int main(int argc, char **argv) } } + if(dt_fn) { + dt_data = load_file(dt_fn, &hdr.dt_size); + if (dt_data == 0) { + fprintf(stderr,"error: could not load device tree image '%s'\n", dt_fn); + return 1; + } + } + /* put a hash of the contents in the header so boot images can be * differentiated based on their first 2k. */ @@ -253,6 +272,10 @@ int main(int argc, char **argv) SHA_update(&ctx, &hdr.ramdisk_size, sizeof(hdr.ramdisk_size)); SHA_update(&ctx, second_data, hdr.second_size); SHA_update(&ctx, &hdr.second_size, sizeof(hdr.second_size)); + if(dt_data) { + SHA_update(&ctx, dt_data, hdr.dt_size); + SHA_update(&ctx, &hdr.dt_size, sizeof(hdr.dt_size)); + } sha = SHA_final(&ctx); memcpy(hdr.id, sha, SHA_DIGEST_SIZE > sizeof(hdr.id) ? sizeof(hdr.id) : SHA_DIGEST_SIZE); @@ -281,6 +304,10 @@ int main(int argc, char **argv) print_id((uint8_t *) hdr.id, sizeof(hdr.id)); } + if(dt_data) { + if(write(fd, dt_data, hdr.dt_size) != (ssize_t) hdr.dt_size) goto fail; + if(write_padding(fd, pagesize, hdr.dt_size)) goto fail; + } return 0; fail: |