From ed95159056caffc869e48509f50433789e75ebb4 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Thu, 2 Aug 2012 14:50:24 -0700 Subject: [PATCH] add command-line arguments to mkbootimg to move kernel, ramdisk, etc. Bug: 6918260 Change-Id: I5d4af6314fded027952941110a520dc9aa234a14 --- mkbootimg/mkbootimg.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/mkbootimg/mkbootimg.c b/mkbootimg/mkbootimg.c index a94cb9c89..2c32ce35b 100644 --- a/mkbootimg/mkbootimg.c +++ b/mkbootimg/mkbootimg.c @@ -109,18 +109,17 @@ int main(int argc, char **argv) int fd; SHA_CTX ctx; uint8_t* sha; + unsigned base = 0x10000000; + unsigned kernel_offset = 0x00008000; + unsigned ramdisk_offset = 0x01000000; + unsigned second_offset = 0x00f00000; + unsigned tags_offset = 0x00000100; argc--; argv++; memset(&hdr, 0, sizeof(hdr)); - /* default load addresses */ - hdr.kernel_addr = 0x10008000; - hdr.ramdisk_addr = 0x11000000; - hdr.second_addr = 0x10F00000; - hdr.tags_addr = 0x10000100; - while(argc > 0){ char *arg = argv[0]; char *val = argv[1]; @@ -140,11 +139,15 @@ int main(int argc, char **argv) } else if(!strcmp(arg, "--cmdline")) { cmdline = val; } else if(!strcmp(arg, "--base")) { - unsigned base = strtoul(val, 0, 16); - hdr.kernel_addr = base + 0x00008000; - hdr.ramdisk_addr = base + 0x01000000; - hdr.second_addr = base + 0x00F00000; - hdr.tags_addr = base + 0x00000100; + base = strtoul(val, 0, 16); + } else if(!strcmp(arg, "--kernel_offset")) { + kernel_offset = strtoul(val, 0, 16); + } else if(!strcmp(arg, "--ramdisk_offset")) { + ramdisk_offset = strtoul(val, 0, 16); + } else if(!strcmp(arg, "--second_offset")) { + second_offset = strtoul(val, 0, 16); + } else if(!strcmp(arg, "--tags_offset")) { + tags_offset = strtoul(val, 0, 16); } else if(!strcmp(arg, "--board")) { board = val; } else if(!strcmp(arg,"--pagesize")) { @@ -159,6 +162,10 @@ int main(int argc, char **argv) } hdr.page_size = pagesize; + hdr.kernel_addr = base + kernel_offset; + hdr.ramdisk_addr = base + ramdisk_offset; + hdr.second_addr = base + second_offset; + hdr.tags_addr = base + tags_offset; if(bootimg == 0) { fprintf(stderr,"error: no output filename specified\n");