From 45f2ce1cb86725ac41ba237867390ef806d5a86d Mon Sep 17 00:00:00 2001 From: Rom Lemarchand Date: Tue, 2 Jun 2015 19:01:25 -0700 Subject: [PATCH] mkbootimg: parse hexadecimal ints Allow passing int arguments as hexadecimal values Change-Id: If5a199007e9868f994dd740ccd15c455eb536327 --- mkbootimg/mkbootimg | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/mkbootimg/mkbootimg b/mkbootimg/mkbootimg index 8c27ff795..1e09f4db0 100755 --- a/mkbootimg/mkbootimg +++ b/mkbootimg/mkbootimg @@ -93,6 +93,10 @@ def write_padded_file(f_out, f_in, padding): pad_file(f_out, padding) +def parse_int(x): + return int(x,0) + + def parse_cmdline(): parser = ArgumentParser() parser.add_argument('--kernel', help='path to the kernel', type=FileType('rb'), @@ -101,15 +105,15 @@ def parse_cmdline(): parser.add_argument('--second', help='path to the 2nd bootloader', type=FileType('rb')) parser.add_argument('--cmdline', help='extra arguments to be passed on the ' 'kernel command line', default='', action=ValidateStrLenAction, maxlen=1536) - parser.add_argument('--base', help='base address', type=int, default=0x10000000) - parser.add_argument('----kernel_offset', help='kernel offset', type=int, default=0x00008000) - parser.add_argument('--ramdisk_offset', help='ramdisk offset', type=int, default=0x01000000) - parser.add_argument('--second_offset', help='2nd bootloader offset', type=int, + parser.add_argument('--base', help='base address', type=parse_int, default=0x10000000) + parser.add_argument('----kernel_offset', help='kernel offset', type=parse_int, default=0x00008000) + parser.add_argument('--ramdisk_offset', help='ramdisk offset', type=parse_int, default=0x01000000) + parser.add_argument('--second_offset', help='2nd bootloader offset', type=parse_int, default=0x00f00000) - parser.add_argument('--tags_offset', help='tags offset', type=int, default=0x00000100) + parser.add_argument('--tags_offset', help='tags offset', type=parse_int, default=0x00000100) parser.add_argument('--board', help='board name', default='', action=ValidateStrLenAction, maxlen=16) - parser.add_argument('--pagesize', help='page size', type=int, + parser.add_argument('--pagesize', help='page size', type=parse_int, choices=[2**i for i in range(11,15)], default=2048) parser.add_argument('--id', help='print the image ID on standard output', action='store_true')