mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-19 05:38:00 +00:00
tools/firmware-utils: add header version 2 support for mktplinkfw
Signed-off-by: Weijie Gao <hackpascal@gmail.com> This patch adds header version 2 option for mktplinkfw. The version 2 header is used for AR/QCA firmwares and is not the same as the header generated by mktplinkfw2. Instead, it is nearly the same as version 1 header except for the header version and the RSA signature. The header version 2 support is used for newer TP-Link routers which have only a 64kb bootloader part, e.g. TL-WDR6500 v2. SVN-Revision: 46661
This commit is contained in:
parent
eba4a143c6
commit
cc3747e9e2
@ -30,6 +30,7 @@
|
|||||||
#define ALIGN(x,a) ({ typeof(a) __a = (a); (((x) + __a - 1) & ~(__a - 1)); })
|
#define ALIGN(x,a) ({ typeof(a) __a = (a); (((x) + __a - 1) & ~(__a - 1)); })
|
||||||
|
|
||||||
#define HEADER_VERSION_V1 0x01000000
|
#define HEADER_VERSION_V1 0x01000000
|
||||||
|
#define HEADER_VERSION_V2 0x02000000
|
||||||
#define HWID_ANTMINER_S1 0x04440001
|
#define HWID_ANTMINER_S1 0x04440001
|
||||||
#define HWID_ANTMINER_S3 0x04440003
|
#define HWID_ANTMINER_S3 0x04440003
|
||||||
#define HWID_GL_INET_V1 0x08000001
|
#define HWID_GL_INET_V1 0x08000001
|
||||||
@ -130,6 +131,7 @@ static char *progname;
|
|||||||
static char *vendor = "TP-LINK Technologies";
|
static char *vendor = "TP-LINK Technologies";
|
||||||
static char *version = "ver. 1.0";
|
static char *version = "ver. 1.0";
|
||||||
static char *fw_ver = "0.0.0";
|
static char *fw_ver = "0.0.0";
|
||||||
|
static uint32_t hdr_ver = HEADER_VERSION_V1;
|
||||||
|
|
||||||
static char *board_id;
|
static char *board_id;
|
||||||
static struct board_info *board;
|
static struct board_info *board;
|
||||||
@ -139,6 +141,7 @@ static char *opt_hw_id;
|
|||||||
static uint32_t hw_id;
|
static uint32_t hw_id;
|
||||||
static char *opt_hw_rev;
|
static char *opt_hw_rev;
|
||||||
static uint32_t hw_rev;
|
static uint32_t hw_rev;
|
||||||
|
static uint32_t opt_hdr_ver = 1;
|
||||||
static int fw_ver_lo;
|
static int fw_ver_lo;
|
||||||
static int fw_ver_mid;
|
static int fw_ver_mid;
|
||||||
static int fw_ver_hi;
|
static int fw_ver_hi;
|
||||||
@ -526,6 +529,7 @@ static void usage(int status)
|
|||||||
" -N <vendor> set image vendor to <vendor>\n"
|
" -N <vendor> set image vendor to <vendor>\n"
|
||||||
" -V <version> set image version to <version>\n"
|
" -V <version> set image version to <version>\n"
|
||||||
" -v <version> set firmware version to <version>\n"
|
" -v <version> set firmware version to <version>\n"
|
||||||
|
" -m <version> set header version to <version>\n"
|
||||||
" -i <file> inspect given firmware file <file>\n"
|
" -i <file> inspect given firmware file <file>\n"
|
||||||
" -x extract kernel and rootfs while inspecting (requires -i)\n"
|
" -x extract kernel and rootfs while inspecting (requires -i)\n"
|
||||||
" -X <size> reserve <size> bytes in the firmware image (hexval prefixed with 0x)\n"
|
" -X <size> reserve <size> bytes in the firmware image (hexval prefixed with 0x)\n"
|
||||||
@ -723,6 +727,15 @@ static int check_options(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opt_hdr_ver == 1) {
|
||||||
|
hdr_ver = HEADER_VERSION_V1;
|
||||||
|
} else if (opt_hdr_ver == 2) {
|
||||||
|
hdr_ver = HEADER_VERSION_V2;
|
||||||
|
} else {
|
||||||
|
ERR("invalid header version '%u'", opt_hdr_ver);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -732,7 +745,7 @@ static void fill_header(char *buf, int len)
|
|||||||
|
|
||||||
memset(hdr, 0, sizeof(struct fw_header));
|
memset(hdr, 0, sizeof(struct fw_header));
|
||||||
|
|
||||||
hdr->version = htonl(HEADER_VERSION_V1);
|
hdr->version = htonl(hdr_ver);
|
||||||
strncpy(hdr->vendor_name, vendor, sizeof(hdr->vendor_name));
|
strncpy(hdr->vendor_name, vendor, sizeof(hdr->vendor_name));
|
||||||
strncpy(hdr->fw_version, version, sizeof(hdr->fw_version));
|
strncpy(hdr->fw_version, version, sizeof(hdr->fw_version));
|
||||||
hdr->hw_id = htonl(hw_id);
|
hdr->hw_id = htonl(hw_id);
|
||||||
@ -972,8 +985,9 @@ static int inspect_fw(void)
|
|||||||
inspect_fw_pstr("File name", inspect_info.file_name);
|
inspect_fw_pstr("File name", inspect_info.file_name);
|
||||||
inspect_fw_phexdec("File size", inspect_info.file_size);
|
inspect_fw_phexdec("File size", inspect_info.file_size);
|
||||||
|
|
||||||
if (ntohl(hdr->version) != HEADER_VERSION_V1) {
|
if ((ntohl(hdr->version) != HEADER_VERSION_V1) &&
|
||||||
ERR("file does not seem to have V1 header!\n");
|
(ntohl(hdr->version) != HEADER_VERSION_V2)) {
|
||||||
|
ERR("file does not seem to have V1/V2 header!\n");
|
||||||
goto out_free_buf;
|
goto out_free_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1108,7 +1122,7 @@ int main(int argc, char *argv[])
|
|||||||
while ( 1 ) {
|
while ( 1 ) {
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
c = getopt(argc, argv, "a:B:H:E:F:L:V:N:W:ci:k:r:R:o:xX:hsSjv:");
|
c = getopt(argc, argv, "a:B:H:E:F:L:m:V:N:W:ci:k:r:R:o:xX:hsSjv:");
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1134,6 +1148,9 @@ int main(int argc, char *argv[])
|
|||||||
case 'L':
|
case 'L':
|
||||||
sscanf(optarg, "0x%x", &kernel_la);
|
sscanf(optarg, "0x%x", &kernel_la);
|
||||||
break;
|
break;
|
||||||
|
case 'm':
|
||||||
|
sscanf(optarg, "%u", &opt_hdr_ver);
|
||||||
|
break;
|
||||||
case 'V':
|
case 'V':
|
||||||
version = optarg;
|
version = optarg;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user