aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/firmware-utils/src/mktplinkfw2.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/tools/firmware-utils/src/mktplinkfw2.c b/tools/firmware-utils/src/mktplinkfw2.c
index 3ab5c52ec2..b6dd670b90 100644
--- a/tools/firmware-utils/src/mktplinkfw2.c
+++ b/tools/firmware-utils/src/mktplinkfw2.c
@@ -43,7 +43,7 @@ struct fw_header {
char fw_version[48]; /* 0x04: fw version string */
uint32_t hw_id; /* 0x34: hardware id */
uint32_t hw_rev; /* 0x38: FIXME: hardware revision? */
- uint32_t unk1; /* 0x3c: 0x00000000 */
+ uint32_t hw_ver_add; /* 0x3c: additional hardware version */
uint8_t md5sum1[MD5SUM_LEN]; /* 0x40 */
uint32_t unk2; /* 0x50: 0x00000000 */
uint8_t md5sum2[MD5SUM_LEN]; /* 0x54 */
@@ -80,6 +80,7 @@ struct board_info {
char *id;
uint32_t hw_id;
uint32_t hw_rev;
+ uint32_t hw_ver_add;
char *layout_id;
uint32_t hdr_ver;
bool endian_swap;
@@ -104,6 +105,8 @@ static char *opt_hw_id;
static uint32_t hw_id;
static char *opt_hw_rev;
static uint32_t hw_rev;
+static char *opt_hw_ver_add;
+static uint32_t hw_ver_add;
static int fw_ver_lo;
static int fw_ver_mid;
static int fw_ver_hi;
@@ -288,6 +291,7 @@ static void usage(int status)
" -L <la> overwrite kernel load address with <la> (hexval prefixed with 0x)\n"
" -H <hwid> use hardware id specified with <hwid>\n"
" -W <hwrev> use hardware revision specified with <hwrev>\n"
+" -w <hwveradd> use additional hardware version specified with <hwveradd>\n"
" -F <id> use flash layout specified with <id>\n"
" -k <file> read kernel image from the file <file>\n"
" -r <file> read rootfs image from the file <file>\n"
@@ -391,6 +395,7 @@ static int check_options(void)
hw_id = board->hw_id;
hw_rev = board->hw_rev;
+ hw_ver_add = board->hw_ver_add;
if (board->hdr_ver)
hdr_ver = board->hdr_ver;
endian_swap = board->endian_swap;
@@ -405,6 +410,11 @@ static int check_options(void)
hw_rev = strtoul(opt_hw_rev, NULL, 0);
else
hw_rev = 1;
+
+ if (opt_hw_ver_add)
+ hw_ver_add = strtoul(opt_hw_rev, NULL, 0);
+ else
+ hw_ver_add = 0;
}
layout = find_layout(layout_id);
@@ -511,6 +521,7 @@ static void fill_header(char *buf, int len)
hdr->hw_id = htonl(hw_id);
hdr->hw_rev = htonl(hw_rev);
+ hdr->hw_ver_add = htonl(hw_ver_add);
if (boot_info.file_size == 0) {
memcpy(hdr->md5sum1, md5salt_normal, sizeof(hdr->md5sum1));
@@ -535,7 +546,6 @@ static void fill_header(char *buf, int len)
hdr->boot_ofs = htonl(0);
hdr->boot_len = htonl(boot_info.file_size);
- hdr->unk1 = htonl(0);
hdr->unk2 = htonl(0);
hdr->unk3 = htonl(0xffffffff);
hdr->unk4 = htons(0x55aa);
@@ -779,9 +789,6 @@ static int inspect_fw(void)
inspect_fw_phexdec("Version 2 Header size", sizeof(struct fw_header));
- if (ntohl(hdr->unk1) != 0)
- inspect_fw_phexdec("Unknown value 1", hdr->unk1);
-
memcpy(md5sum, hdr->md5sum1, sizeof(md5sum));
if (ntohl(hdr->boot_len) == 0)
memcpy(hdr->md5sum1, md5salt_normal, sizeof(md5sum));
@@ -820,11 +827,15 @@ static int inspect_fw(void)
ntohl(hdr->hw_id), board->id);
inspect_fw_phexexp("Hardware Revision",
ntohl(hdr->hw_rev), board->hw_rev);
+ inspect_fw_phexexp("Additional HW Version",
+ ntohl(hdr->hw_ver_add), board->hw_ver_add);
} else {
inspect_fw_phexpost("Hardware ID",
ntohl(hdr->hw_id), "unknown");
inspect_fw_phex("Hardware Revision",
ntohl(hdr->hw_rev));
+ inspect_fw_phex("Additional HW Version",
+ ntohl(hdr->hw_ver_add));
}
printf("%-23s: %d.%d.%d-%d.%d\n", "Software version",
@@ -919,7 +930,7 @@ int main(int argc, char *argv[])
while ( 1 ) {
int c;
- c = getopt(argc, argv, "a:B:H:E:F:L:V:N:W:ci:k:r:R:o:xhsjv:y:T:e");
+ c = getopt(argc, argv, "a:B:H:E:F:L:V:N:W:w:ci:k:r:R:o:xhsjv:y:T:e");
if (c == -1)
break;
@@ -942,6 +953,9 @@ int main(int argc, char *argv[])
case 'W':
opt_hw_rev = optarg;
break;
+ case 'w':
+ opt_hw_ver_add = optarg;
+ break;
case 'L':
sscanf(optarg, "0x%x", &kernel_la);
break;