b6dd670b9075b93ec12b0500861fa27d8778d0c9
2 * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
4 * This tool was based on:
5 * TP-Link WR941 V2 firmware checksum fixing tool.
6 * Copyright (C) 2008,2009 Wang Jian <lark@linux.net.cn>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
18 #include <unistd.h> /* for unlink() */
20 #include <getopt.h> /* for getopt() */
27 #include <arpa/inet.h>
28 #include <netinet/in.h>
32 #define ALIGN(x,a) ({ typeof(a) __a = (a); (((x) + __a - 1) & ~(__a - 1)); })
37 char *file_name
; /* name of the file */
38 uint32_t file_size
; /* length of the file */
42 uint32_t version
; /* 0x00: header version */
43 char fw_version
[48]; /* 0x04: fw version string */
44 uint32_t hw_id
; /* 0x34: hardware id */
45 uint32_t hw_rev
; /* 0x38: FIXME: hardware revision? */
46 uint32_t hw_ver_add
; /* 0x3c: additional hardware version */
47 uint8_t md5sum1
[MD5SUM_LEN
]; /* 0x40 */
48 uint32_t unk2
; /* 0x50: 0x00000000 */
49 uint8_t md5sum2
[MD5SUM_LEN
]; /* 0x54 */
50 uint32_t unk3
; /* 0x64: 0xffffffff */
52 uint32_t kernel_la
; /* 0x68: kernel load address */
53 uint32_t kernel_ep
; /* 0x6c: kernel entry point */
54 uint32_t fw_length
; /* 0x70: total length of the image */
55 uint32_t kernel_ofs
; /* 0x74: kernel data offset */
56 uint32_t kernel_len
; /* 0x78: kernel data length */
57 uint32_t rootfs_ofs
; /* 0x7c: rootfs data offset */
58 uint32_t rootfs_len
; /* 0x80: rootfs data length */
59 uint32_t boot_ofs
; /* 0x84: FIXME: seems to be unused */
60 uint32_t boot_len
; /* 0x88: FIXME: seems to be unused */
61 uint16_t unk4
; /* 0x8c: 0x55aa */
62 uint8_t sver_hi
; /* 0x8e */
63 uint8_t sver_lo
; /* 0x8f */
64 uint8_t unk5
; /* 0x90: magic: 0xa5 */
65 uint8_t ver_hi
; /* 0x91 */
66 uint8_t ver_mid
; /* 0x92 */
67 uint8_t ver_lo
; /* 0x93 */
69 } __attribute__ ((packed
));
93 static char *progname
;
94 static char *vendor
= "TP-LINK Technologies";
95 static char *version
= "ver. 1.0";
96 static char *fw_ver
= "0.0.0";
97 static char *sver
= "1.0";
98 static uint32_t hdr_ver
= 2;
100 static char *board_id
;
101 static struct board_info
*board
;
102 static char *layout_id
;
103 static struct flash_layout
*layout
;
104 static char *opt_hw_id
;
105 static uint32_t hw_id
;
106 static char *opt_hw_rev
;
107 static uint32_t hw_rev
;
108 static char *opt_hw_ver_add
;
109 static uint32_t hw_ver_add
;
110 static int fw_ver_lo
;
111 static int fw_ver_mid
;
112 static int fw_ver_hi
;
115 static struct file_info kernel_info
;
116 static uint32_t kernel_la
= 0;
117 static uint32_t kernel_ep
= 0;
118 static uint32_t kernel_len
= 0;
119 static struct file_info rootfs_info
;
120 static uint32_t rootfs_ofs
= 0;
121 static uint32_t rootfs_align
;
122 static struct file_info boot_info
;
124 static int strip_padding
;
125 static int add_jffs2_eof
;
126 static unsigned char jffs2_eof_mark
[4] = {0xde, 0xad, 0xc0, 0xde};
128 static struct file_info inspect_info
;
129 static int extract
= 0;
130 static bool endian_swap
= false;
132 char md5salt_normal
[MD5SUM_LEN
] = {
133 0xdc, 0xd7, 0x3a, 0xa5, 0xc3, 0x95, 0x98, 0xfb,
134 0xdc, 0xf9, 0xe7, 0xf4, 0x0e, 0xae, 0x47, 0x37,
137 char md5salt_boot
[MD5SUM_LEN
] = {
138 0x8c, 0xef, 0x33, 0x5b, 0xd5, 0xc5, 0xce, 0xfa,
139 0xa7, 0x9c, 0x28, 0xda, 0xb2, 0xe9, 0x0f, 0x42,
142 static struct flash_layout layouts
[] = {
145 .fw_max_len
= 0x7a0000,
146 .kernel_la
= 0x80002000,
147 .kernel_ep
= 0x80002000,
148 .rootfs_ofs
= 0x140000,
151 .fw_max_len
= 0xf90000,
152 .kernel_la
= 0x80002000,
153 .kernel_ep
= 0x800061b0,
154 .rootfs_ofs
= 0x140000,
157 .fw_max_len
= 0x7a0000,
158 .kernel_la
= 0x80000000,
159 .kernel_ep
= 0x80000000,
160 .rootfs_ofs
= 0x140000,
163 .fw_max_len
= 0x7b0000,
164 .kernel_la
= 0x80000000,
165 .kernel_ep
= 0x80000000,
166 .rootfs_ofs
= 0x140000,
168 /* terminating entry */
172 static struct board_info boards
[] = {
177 .layout_id
= "8Mltq",
182 .layout_id
= "8Mltq",
187 .layout_id
= "8Mmtk",
191 .id
= "ArcherVR200V",
194 .layout_id
= "16Mltq",
200 .layout_id
= "8Mmtk",
207 .layout_id
= "8MLmtk",
211 /* terminating entry */
218 #define ERR(fmt, ...) do { \
220 fprintf(stderr, "[%s] *** error: " fmt "\n", \
221 progname, ## __VA_ARGS__ ); \
224 #define ERRS(fmt, ...) do { \
227 fprintf(stderr, "[%s] *** error: " fmt ": %s\n", \
228 progname, ## __VA_ARGS__, strerror(save)); \
231 #define DBG(fmt, ...) do { \
232 fprintf(stderr, "[%s] " fmt "\n", progname, ## __VA_ARGS__ ); \
235 static struct board_info
*find_board(char *id
)
237 struct board_info
*ret
;
238 struct board_info
*board
;
241 for (board
= boards
; board
->id
!= NULL
; board
++){
242 if (strcasecmp(id
, board
->id
) == 0) {
251 static struct board_info
*find_board_by_hwid(uint32_t hw_id
)
253 struct board_info
*board
;
255 for (board
= boards
; board
->id
!= NULL
; board
++) {
256 if (hw_id
== board
->hw_id
)
263 static struct flash_layout
*find_layout(char *id
)
265 struct flash_layout
*ret
;
266 struct flash_layout
*l
;
269 for (l
= layouts
; l
->id
!= NULL
; l
++){
270 if (strcasecmp(id
, l
->id
) == 0) {
279 static void usage(int status
)
281 FILE *stream
= (status
!= EXIT_SUCCESS
) ? stderr
: stdout
;
282 struct board_info
*board
;
284 fprintf(stream
, "Usage: %s [OPTIONS...]\n", progname
);
288 " -B <board> create image for the board specified with <board>\n"
289 " -c use combined kernel image\n"
290 " -E <ep> overwrite kernel entry point with <ep> (hexval prefixed with 0x)\n"
291 " -L <la> overwrite kernel load address with <la> (hexval prefixed with 0x)\n"
292 " -H <hwid> use hardware id specified with <hwid>\n"
293 " -W <hwrev> use hardware revision specified with <hwrev>\n"
294 " -w <hwveradd> use additional hardware version specified with <hwveradd>\n"
295 " -F <id> use flash layout specified with <id>\n"
296 " -k <file> read kernel image from the file <file>\n"
297 " -r <file> read rootfs image from the file <file>\n"
298 " -a <align> align the rootfs start on an <align> bytes boundary\n"
299 " -R <offset> overwrite rootfs offset with <offset> (hexval prefixed with 0x)\n"
300 " -o <file> write output to the file <file>\n"
301 " -s strip padding from the end of the image\n"
302 " -j add jffs2 end-of-filesystem markers\n"
303 " -V <version> set image version to <version>\n"
304 " -v <version> set firmware version to <version>\n"
305 " -y <version> set secondary version to <version>\n"
306 " -i <file> inspect given firmware file <file>\n"
307 " -x extract kernel and rootfs while inspecting (requires -i)\n"
308 " -h show this screen\n"
314 static int get_md5(char *data
, int size
, char *md5
)
319 MD5_Update(&ctx
, data
, size
);
320 MD5_Final(md5
, &ctx
);
323 static int get_file_stat(struct file_info
*fdata
)
328 if (fdata
->file_name
== NULL
)
331 res
= stat(fdata
->file_name
, &st
);
333 ERRS("stat failed on %s", fdata
->file_name
);
337 fdata
->file_size
= st
.st_size
;
341 static int read_to_buf(struct file_info
*fdata
, char *buf
)
344 int ret
= EXIT_FAILURE
;
346 f
= fopen(fdata
->file_name
, "r");
348 ERRS("could not open \"%s\" for reading", fdata
->file_name
);
353 fread(buf
, fdata
->file_size
, 1, f
);
355 ERRS("unable to read from file \"%s\"", fdata
->file_name
);
367 static int check_options(void)
371 if (inspect_info
.file_name
) {
372 ret
= get_file_stat(&inspect_info
);
377 } else if (extract
) {
378 ERR("no firmware for inspection specified");
382 if (board_id
== NULL
&& opt_hw_id
== NULL
) {
383 ERR("either board or hardware id must be specified");
388 board
= find_board(board_id
);
390 ERR("unknown/unsupported board id \"%s\"", board_id
);
393 if (layout_id
== NULL
)
394 layout_id
= board
->layout_id
;
396 hw_id
= board
->hw_id
;
397 hw_rev
= board
->hw_rev
;
398 hw_ver_add
= board
->hw_ver_add
;
400 hdr_ver
= board
->hdr_ver
;
401 endian_swap
= board
->endian_swap
;
403 if (layout_id
== NULL
) {
404 ERR("flash layout is not specified");
407 hw_id
= strtoul(opt_hw_id
, NULL
, 0);
410 hw_rev
= strtoul(opt_hw_rev
, NULL
, 0);
415 hw_ver_add
= strtoul(opt_hw_rev
, NULL
, 0);
420 layout
= find_layout(layout_id
);
421 if (layout
== NULL
) {
422 ERR("unknown flash layout \"%s\"", layout_id
);
427 kernel_la
= layout
->kernel_la
;
429 kernel_ep
= layout
->kernel_ep
;
431 rootfs_ofs
= layout
->rootfs_ofs
;
433 if (kernel_info
.file_name
== NULL
) {
434 ERR("no kernel image specified");
438 ret
= get_file_stat(&kernel_info
);
442 kernel_len
= kernel_info
.file_size
;
445 if (kernel_info
.file_size
>
446 layout
->fw_max_len
- sizeof(struct fw_header
)) {
447 ERR("kernel image is too big");
451 if (rootfs_info
.file_name
== NULL
) {
452 ERR("no rootfs image specified");
456 ret
= get_file_stat(&rootfs_info
);
461 kernel_len
+= sizeof(struct fw_header
);
462 kernel_len
= ALIGN(kernel_len
, rootfs_align
);
463 kernel_len
-= sizeof(struct fw_header
);
465 DBG("kernel length aligned to %u", kernel_len
);
467 if (kernel_len
+ rootfs_info
.file_size
>
468 layout
->fw_max_len
- sizeof(struct fw_header
)) {
469 ERR("images are too big");
473 if (kernel_info
.file_size
>
474 rootfs_ofs
- sizeof(struct fw_header
)) {
475 ERR("kernel image is too big");
479 if (rootfs_info
.file_size
>
480 (layout
->fw_max_len
- rootfs_ofs
)) {
481 ERR("rootfs image is too big");
487 if (ofname
== NULL
) {
488 ERR("no output file specified");
492 ret
= sscanf(fw_ver
, "%d.%d.%d", &fw_ver_hi
, &fw_ver_mid
, &fw_ver_lo
);
494 ERR("invalid firmware version '%s'", fw_ver
);
498 ret
= sscanf(sver
, "%d.%d", &sver_hi
, &sver_lo
);
500 ERR("invalid secondary version '%s'", sver
);
507 static void fill_header(char *buf
, int len
)
509 struct fw_header
*hdr
= (struct fw_header
*)buf
;
512 memset(hdr
, '\xff', sizeof(struct fw_header
));
514 hdr
->version
= htonl(bswap_32(hdr_ver
));
515 ver_len
= strlen(version
);
516 if (ver_len
> (sizeof(hdr
->fw_version
) - 1))
517 ver_len
= sizeof(hdr
->fw_version
) - 1;
519 memcpy(hdr
->fw_version
, version
, ver_len
);
520 hdr
->fw_version
[ver_len
] = 0;
522 hdr
->hw_id
= htonl(hw_id
);
523 hdr
->hw_rev
= htonl(hw_rev
);
524 hdr
->hw_ver_add
= htonl(hw_ver_add
);
526 if (boot_info
.file_size
== 0) {
527 memcpy(hdr
->md5sum1
, md5salt_normal
, sizeof(hdr
->md5sum1
));
528 hdr
->boot_ofs
= htonl(0);
529 hdr
->boot_len
= htonl(0);
531 memcpy(hdr
->md5sum1
, md5salt_boot
, sizeof(hdr
->md5sum1
));
532 hdr
->boot_ofs
= htonl(rootfs_ofs
+ rootfs_info
.file_size
);
533 hdr
->boot_len
= htonl(rootfs_info
.file_size
);
536 hdr
->kernel_la
= htonl(kernel_la
);
537 hdr
->kernel_ep
= htonl(kernel_ep
);
538 hdr
->fw_length
= htonl(layout
->fw_max_len
);
539 hdr
->kernel_ofs
= htonl(sizeof(struct fw_header
));
540 hdr
->kernel_len
= htonl(kernel_len
);
542 hdr
->rootfs_ofs
= htonl(rootfs_ofs
);
543 hdr
->rootfs_len
= htonl(rootfs_info
.file_size
);
546 hdr
->boot_ofs
= htonl(0);
547 hdr
->boot_len
= htonl(boot_info
.file_size
);
549 hdr
->unk2
= htonl(0);
550 hdr
->unk3
= htonl(0xffffffff);
551 hdr
->unk4
= htons(0x55aa);
554 hdr
->sver_hi
= sver_hi
;
555 hdr
->sver_lo
= sver_lo
;
557 hdr
->ver_hi
= fw_ver_hi
;
558 hdr
->ver_mid
= fw_ver_mid
;
559 hdr
->ver_lo
= fw_ver_lo
;
562 hdr
->kernel_la
= bswap_32(hdr
->kernel_la
);
563 hdr
->kernel_ep
= bswap_32(hdr
->kernel_ep
);
566 get_md5(buf
, len
, hdr
->md5sum1
);
569 static int pad_jffs2(char *buf
, int currlen
)
575 pad_mask
= (64 * 1024);
576 while ((len
< layout
->fw_max_len
) && (pad_mask
!= 0)) {
580 for (i
= 10; i
< 32; i
++) {
586 len
= ALIGN(len
, mask
);
588 for (i
= 10; i
< 32; i
++) {
590 if ((len
& (mask
- 1)) == 0)
594 for (i
= 0; i
< sizeof(jffs2_eof_mark
); i
++)
595 buf
[len
+ i
] = jffs2_eof_mark
[i
];
597 len
+= sizeof(jffs2_eof_mark
);
603 static int write_fw(char *data
, int len
)
606 int ret
= EXIT_FAILURE
;
608 f
= fopen(ofname
, "w");
610 ERRS("could not open \"%s\" for writing", ofname
);
615 fwrite(data
, len
, 1, f
);
617 ERRS("unable to write output file");
621 DBG("firmware file \"%s\" completed", ofname
);
628 if (ret
!= EXIT_SUCCESS
) {
635 static int build_fw(void)
640 int ret
= EXIT_FAILURE
;
643 buflen
= layout
->fw_max_len
;
645 buf
= malloc(buflen
);
647 ERR("no memory for buffer\n");
651 memset(buf
, 0xff, buflen
);
652 p
= buf
+ sizeof(struct fw_header
);
653 ret
= read_to_buf(&kernel_info
, p
);
657 writelen
= sizeof(struct fw_header
) + kernel_len
;
663 p
= buf
+ rootfs_ofs
;
665 ret
= read_to_buf(&rootfs_info
, p
);
670 writelen
+= rootfs_info
.file_size
;
672 writelen
= rootfs_ofs
+ rootfs_info
.file_size
;
675 writelen
= pad_jffs2(buf
, writelen
);
681 fill_header(buf
, writelen
);
682 ret
= write_fw(buf
, writelen
);
694 /* Helper functions to inspect_fw() representing different output formats */
695 static inline void inspect_fw_pstr(char *label
, char *str
)
697 printf("%-23s: %s\n", label
, str
);
700 static inline void inspect_fw_phex(char *label
, uint32_t val
)
702 printf("%-23s: 0x%08x\n", label
, val
);
705 static inline void inspect_fw_phexpost(char *label
,
706 uint32_t val
, char *post
)
708 printf("%-23s: 0x%08x (%s)\n", label
, val
, post
);
711 static inline void inspect_fw_phexdef(char *label
,
712 uint32_t val
, uint32_t defval
)
714 printf("%-23s: 0x%08x ", label
, val
);
717 printf("(== OpenWrt default)\n");
719 printf("(OpenWrt default: 0x%08x)\n", defval
);
722 static inline void inspect_fw_phexexp(char *label
,
723 uint32_t val
, uint32_t expval
)
725 printf("%-23s: 0x%08x ", label
, val
);
730 printf("(expected: 0x%08x)\n", expval
);
733 static inline void inspect_fw_phexdec(char *label
, uint32_t val
)
735 printf("%-23s: 0x%08x / %8u bytes\n", label
, val
, val
);
738 static inline void inspect_fw_phexdecdef(char *label
,
739 uint32_t val
, uint32_t defval
)
741 printf("%-23s: 0x%08x / %8u bytes ", label
, val
, val
);
744 printf("(== OpenWrt default)\n");
746 printf("(OpenWrt default: 0x%08x)\n", defval
);
749 static inline void inspect_fw_pmd5sum(char *label
, uint8_t *val
, char *text
)
753 printf("%-23s:", label
);
754 for (i
=0; i
<MD5SUM_LEN
; i
++)
755 printf(" %02x", val
[i
]);
756 printf(" %s\n", text
);
759 static int inspect_fw(void)
762 struct fw_header
*hdr
;
763 uint8_t md5sum
[MD5SUM_LEN
];
764 struct board_info
*board
;
765 int ret
= EXIT_FAILURE
;
767 buf
= malloc(inspect_info
.file_size
);
769 ERR("no memory for buffer!\n");
773 ret
= read_to_buf(&inspect_info
, buf
);
776 hdr
= (struct fw_header
*)buf
;
778 inspect_fw_pstr("File name", inspect_info
.file_name
);
779 inspect_fw_phexdec("File size", inspect_info
.file_size
);
781 switch(bswap_32(ntohl(hdr
->version
))) {
786 ERR("file does not seem to have V2/V3 header!\n");
790 inspect_fw_phexdec("Version 2 Header size", sizeof(struct fw_header
));
792 memcpy(md5sum
, hdr
->md5sum1
, sizeof(md5sum
));
793 if (ntohl(hdr
->boot_len
) == 0)
794 memcpy(hdr
->md5sum1
, md5salt_normal
, sizeof(md5sum
));
796 memcpy(hdr
->md5sum1
, md5salt_boot
, sizeof(md5sum
));
797 get_md5(buf
, inspect_info
.file_size
, hdr
->md5sum1
);
799 if (memcmp(md5sum
, hdr
->md5sum1
, sizeof(md5sum
))) {
800 inspect_fw_pmd5sum("Header MD5Sum1", md5sum
, "(*ERROR*)");
801 inspect_fw_pmd5sum(" --> expected", hdr
->md5sum1
, "");
803 inspect_fw_pmd5sum("Header MD5Sum1", md5sum
, "(ok)");
805 if (ntohl(hdr
->unk2
) != 0)
806 inspect_fw_phexdec("Unknown value 2", hdr
->unk2
);
807 inspect_fw_pmd5sum("Header MD5Sum2", hdr
->md5sum2
,
808 "(purpose yet unknown, unchecked here)");
810 if (ntohl(hdr
->unk3
) != 0xffffffff)
811 inspect_fw_phexdec("Unknown value 3", hdr
->unk3
);
813 if (ntohs(hdr
->unk4
) != 0x55aa)
814 inspect_fw_phexdec("Unknown value 4", hdr
->unk4
);
816 if (hdr
->unk5
!= 0xa5)
817 inspect_fw_phexdec("Unknown value 5", hdr
->unk5
);
821 inspect_fw_pstr("Firmware version", hdr
->fw_version
);
823 board
= find_board_by_hwid(ntohl(hdr
->hw_id
));
825 layout
= find_layout(board
->layout_id
);
826 inspect_fw_phexpost("Hardware ID",
827 ntohl(hdr
->hw_id
), board
->id
);
828 inspect_fw_phexexp("Hardware Revision",
829 ntohl(hdr
->hw_rev
), board
->hw_rev
);
830 inspect_fw_phexexp("Additional HW Version",
831 ntohl(hdr
->hw_ver_add
), board
->hw_ver_add
);
833 inspect_fw_phexpost("Hardware ID",
834 ntohl(hdr
->hw_id
), "unknown");
835 inspect_fw_phex("Hardware Revision",
837 inspect_fw_phex("Additional HW Version",
838 ntohl(hdr
->hw_ver_add
));
841 printf("%-23s: %d.%d.%d-%d.%d\n", "Software version",
842 hdr
->ver_hi
, hdr
->ver_mid
, hdr
->ver_lo
,
843 hdr
->sver_hi
, hdr
->sver_lo
);
847 inspect_fw_phexdec("Kernel data offset",
848 ntohl(hdr
->kernel_ofs
));
849 inspect_fw_phexdec("Kernel data length",
850 ntohl(hdr
->kernel_len
));
852 inspect_fw_phexdef("Kernel load address",
853 ntohl(hdr
->kernel_la
),
854 layout
? layout
->kernel_la
: 0xffffffff);
855 inspect_fw_phexdef("Kernel entry point",
856 ntohl(hdr
->kernel_ep
),
857 layout
? layout
->kernel_ep
: 0xffffffff);
858 inspect_fw_phexdecdef("Rootfs data offset",
859 ntohl(hdr
->rootfs_ofs
),
860 layout
? layout
->rootfs_ofs
: 0xffffffff);
862 inspect_fw_phex("Kernel load address",
863 ntohl(hdr
->kernel_la
));
864 inspect_fw_phex("Kernel entry point",
865 ntohl(hdr
->kernel_ep
));
866 inspect_fw_phexdec("Rootfs data offset",
867 ntohl(hdr
->rootfs_ofs
));
869 inspect_fw_phexdec("Rootfs data length",
870 ntohl(hdr
->rootfs_len
));
871 inspect_fw_phexdec("Boot loader data offset",
872 ntohl(hdr
->boot_ofs
));
873 inspect_fw_phexdec("Boot loader data length",
874 ntohl(hdr
->boot_len
));
875 inspect_fw_phexdec("Total firmware length",
876 ntohl(hdr
->fw_length
));
884 filename
= malloc(strlen(inspect_info
.file_name
) + 8);
885 sprintf(filename
, "%s-kernel", inspect_info
.file_name
);
886 printf("Extracting kernel to \"%s\"...\n", filename
);
887 fp
= fopen(filename
, "w");
889 if (!fwrite(buf
+ ntohl(hdr
->kernel_ofs
),
890 ntohl(hdr
->kernel_len
), 1, fp
)) {
891 ERR("error in fwrite(): %s", strerror(errno
));
895 ERR("error in fopen(): %s", strerror(errno
));
899 filename
= malloc(strlen(inspect_info
.file_name
) + 8);
900 sprintf(filename
, "%s-rootfs", inspect_info
.file_name
);
901 printf("Extracting rootfs to \"%s\"...\n", filename
);
902 fp
= fopen(filename
, "w");
904 if (!fwrite(buf
+ ntohl(hdr
->rootfs_ofs
),
905 ntohl(hdr
->rootfs_len
), 1, fp
)) {
906 ERR("error in fwrite(): %s", strerror(errno
));
910 ERR("error in fopen(): %s", strerror(errno
));
921 int main(int argc
, char *argv
[])
923 int ret
= EXIT_FAILURE
;
928 progname
= basename(argv
[0]);
933 c
= getopt(argc
, argv
, "a:B:H:E:F:L:V:N:W:w:ci:k:r:R:o:xhsjv:y:T:e");
939 sscanf(optarg
, "0x%x", &rootfs_align
);
948 sscanf(optarg
, "0x%x", &kernel_ep
);
957 opt_hw_ver_add
= optarg
;
960 sscanf(optarg
, "0x%x", &kernel_la
);
978 kernel_info
.file_name
= optarg
;
981 rootfs_info
.file_name
= optarg
;
984 sscanf(optarg
, "0x%x", &rootfs_ofs
);
993 inspect_info
.file_name
= optarg
;
1002 hdr_ver
= atoi(optarg
);
1008 usage(EXIT_SUCCESS
);
1011 usage(EXIT_FAILURE
);
1016 ret
= check_options();
1020 if (!inspect_info
.file_name
)