Loading mkbootimg/bootimg.h +4 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ struct boot_img_hdr uint32_t tags_addr; /* physical addr for kernel tags */ uint32_t page_size; /* flash page size we assume */ uint32_t dt_size; /* device tree in bytes */ uint32_t unused[2]; /* future expansion: should be 0 */ uint8_t name[BOOT_NAME_SIZE]; /* asciiz product name */ Loading @@ -66,10 +67,13 @@ struct boot_img_hdr ** +-----------------+ ** | second stage | o pages ** +-----------------+ ** | device tree | p pages ** +-----------------+ ** ** n = (kernel_size + page_size - 1) / page_size ** m = (ramdisk_size + page_size - 1) / page_size ** o = (second_size + page_size - 1) / page_size ** p = (dt_size + page_size - 1) / page_size ** ** 0. all entities are page_size aligned in flash ** 1. kernel and ramdisk are required (size != 0) Loading mkbootimg/mkbootimg.c +21 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ int usage(void) " [ --board <boardname> ]\n" " [ --base <address> ]\n" " [ --pagesize <pagesize> ]\n" " [ --dt <filename> ]\n" " [ --id ]\n" " -o|--output <filename>\n" ); Loading Loading @@ -115,6 +116,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; Loading Loading @@ -171,6 +174,8 @@ int main(int argc, char **argv) fprintf(stderr,"error: unsupported page size %d\n", pagesize); return -1; } } else if(!strcmp(arg, "--dt")) { dt_fn = val; } else { return usage(); } Loading Loading @@ -243,6 +248,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. */ Loading @@ -253,6 +266,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); Loading Loading @@ -281,6 +298,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) != hdr.dt_size) goto fail; if(write_padding(fd, pagesize, hdr.dt_size)) goto fail; } return 0; fail: Loading Loading
mkbootimg/bootimg.h +4 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ struct boot_img_hdr uint32_t tags_addr; /* physical addr for kernel tags */ uint32_t page_size; /* flash page size we assume */ uint32_t dt_size; /* device tree in bytes */ uint32_t unused[2]; /* future expansion: should be 0 */ uint8_t name[BOOT_NAME_SIZE]; /* asciiz product name */ Loading @@ -66,10 +67,13 @@ struct boot_img_hdr ** +-----------------+ ** | second stage | o pages ** +-----------------+ ** | device tree | p pages ** +-----------------+ ** ** n = (kernel_size + page_size - 1) / page_size ** m = (ramdisk_size + page_size - 1) / page_size ** o = (second_size + page_size - 1) / page_size ** p = (dt_size + page_size - 1) / page_size ** ** 0. all entities are page_size aligned in flash ** 1. kernel and ramdisk are required (size != 0) Loading
mkbootimg/mkbootimg.c +21 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ int usage(void) " [ --board <boardname> ]\n" " [ --base <address> ]\n" " [ --pagesize <pagesize> ]\n" " [ --dt <filename> ]\n" " [ --id ]\n" " -o|--output <filename>\n" ); Loading Loading @@ -115,6 +116,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; Loading Loading @@ -171,6 +174,8 @@ int main(int argc, char **argv) fprintf(stderr,"error: unsupported page size %d\n", pagesize); return -1; } } else if(!strcmp(arg, "--dt")) { dt_fn = val; } else { return usage(); } Loading Loading @@ -243,6 +248,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. */ Loading @@ -253,6 +266,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); Loading Loading @@ -281,6 +298,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) != hdr.dt_size) goto fail; if(write_padding(fd, pagesize, hdr.dt_size)) goto fail; } return 0; fail: Loading