diff options
Diffstat (limited to 'tools/firmware-utils')
-rw-r--r-- | tools/firmware-utils/src/csysimg.h | 1 | ||||
-rw-r--r-- | tools/firmware-utils/src/mkcameofw.c | 84 | ||||
-rw-r--r-- | tools/firmware-utils/src/mkcsysimg.c | 1 | ||||
-rw-r--r-- | tools/firmware-utils/src/mkdapimg.c | 39 | ||||
-rw-r--r-- | tools/firmware-utils/src/mkfwimage2.c | 2 | ||||
-rw-r--r-- | tools/firmware-utils/src/mktplinkfw.c | 55 |
6 files changed, 151 insertions, 31 deletions
diff --git a/tools/firmware-utils/src/csysimg.h b/tools/firmware-utils/src/csysimg.h index 19dfbd433..65ab062f3 100644 --- a/tools/firmware-utils/src/csysimg.h +++ b/tools/firmware-utils/src/csysimg.h @@ -49,6 +49,7 @@ #define SIG_BR6114WG SIG_BR6104IPC #define SIG_BR6524K "2-K-" #define SIG_BR6524KP "2-KP" /* FIXME: valid? */ +#define SIG_BR6524N "WNRA" #define SIG_BR6524WG "2-WG" /* FIXME: valid? */ #define SIG_BR6524WP "2-WP" /* FIXME: valid? */ #define SIG_BR6541K "4--K" diff --git a/tools/firmware-utils/src/mkcameofw.c b/tools/firmware-utils/src/mkcameofw.c index a152eb535..e0da4baf3 100644 --- a/tools/firmware-utils/src/mkcameofw.c +++ b/tools/firmware-utils/src/mkcameofw.c @@ -61,6 +61,7 @@ static struct file_info kernel_info; static struct file_info rootfs_info; static uint32_t kernel_size; static uint32_t image_size; +static int combined; /* * Message macros @@ -91,6 +92,7 @@ static void usage(int status) "\n" "Options:\n" " -k <file> read kernel image from the file <file>\n" +" -c use the kernel image as a combined image\n" " -M <model> set model to <model>\n" " -o <file> write output to the file <file>\n" " -r <file> read rootfs image from the file <file>\n" @@ -196,37 +198,55 @@ static int check_options(void) CHKSTRLEN(version, "version"); CHKSTR(ofname, "output file"); CHKSTR(kernel_info.file_name, "kernel image"); - CHKSTR(rootfs_info.file_name, "rootfs image"); ret = get_file_stat(&kernel_info); if (ret) return ret; - ret = get_file_stat(&rootfs_info); - if (ret) - return ret; + if (combined) { + if (!kernel_size) { + ERR("kernel size must be specified for combined images"); + return -1; \ + } - if (kernel_size) { - /* override kernel size */ - kernel_info.write_size = kernel_size; - } + if (!image_size) + image_size = kernel_info.file_size; - if (image_size) { - if (image_size < kernel_info.write_size) - kernel_info.write_size = image_size; + if (kernel_info.file_size > image_size) { + ERR("kernel image is too big"); + return -1; + } - /* override rootfs size */ - rootfs_info.write_size = image_size - kernel_info.write_size; - } + kernel_info.write_size = image_size; + } else { + CHKSTR(rootfs_info.file_name, "rootfs image"); - if (kernel_info.file_size > kernel_info.write_size) { - ERR("kernel image is too big"); - return -1; - } + ret = get_file_stat(&rootfs_info); + if (ret) + return ret; - if (rootfs_info.file_size > rootfs_info.write_size) { - ERR("rootfs image is too big"); - return -1; + if (kernel_size) { + /* override kernel size */ + kernel_info.write_size = kernel_size; + } + + if (image_size) { + if (image_size < kernel_info.write_size) + kernel_info.write_size = image_size; + + /* override rootfs size */ + rootfs_info.write_size = image_size - kernel_info.write_size; + } + + if (kernel_info.file_size > kernel_info.write_size) { + ERR("kernel image is too big"); + return -1; + } + + if (rootfs_info.file_size > rootfs_info.write_size) { + ERR("rootfs image is too big"); + return -1; + } } return 0; @@ -301,12 +321,14 @@ static int build_fw(void) if (ret) goto out_free_buf; - p += kernel_info.write_size; + if (!combined) { + p += kernel_info.write_size; - /* read rootfs data */ - ret = read_to_buf(&rootfs_info, p); - if (ret) - goto out_free_buf; + /* read rootfs data */ + ret = read_to_buf(&rootfs_info, p); + if (ret) + goto out_free_buf; + } csum = get_csum((unsigned char *)(buf + sizeof(struct img_header)), buflen - sizeof(struct img_header)); @@ -316,7 +338,10 @@ static int build_fw(void) hdr->checksum = htonl(csum); hdr->image_size = htonl(buflen - sizeof(struct img_header)); - hdr->kernel_size = htonl(kernel_info.write_size); + if (!combined) + hdr->kernel_size = htonl(kernel_info.write_size); + else + hdr->kernel_size = htonl(kernel_size); hdr->header_len = sizeof(struct img_header); strncpy(hdr->model, model, sizeof(hdr->model)); strncpy(hdr->signature, signature, sizeof(hdr->signature)); @@ -344,7 +369,7 @@ int main(int argc, char *argv[]) while (1) { int c; - c = getopt(argc, argv, "M:S:V:R:k:K:I:r:o:h"); + c = getopt(argc, argv, "M:S:V:R:k:K:I:r:o:hc"); if (c == -1) break; @@ -381,6 +406,9 @@ int main(int argc, char *argv[]) case 'r': rootfs_info.file_name = optarg; break; + case 'c': + combined = 1; + break; case 'o': ofname = optarg; break; diff --git a/tools/firmware-utils/src/mkcsysimg.c b/tools/firmware-utils/src/mkcsysimg.c index 4f2352a60..c00096f87 100644 --- a/tools/firmware-utils/src/mkcsysimg.c +++ b/tools/firmware-utils/src/mkcsysimg.c @@ -160,6 +160,7 @@ static struct board_info boards[] = { BOARD_ADM("BR-6114WG", "Edimax BR-6114WG", 2, SIG_BR6114WG), BOARD_ADM("BR-6524K", "Edimax BR-6524K", 2, SIG_BR6524K), BOARD_ADM("BR-6524KP", "Edimax BR-6524KP", 2, SIG_BR6524KP), + BOARD_ADM("BR-6524N", "Edimax BR-6524N", 2, SIG_BR6524N), BOARD_ADM("BR-6524WG", "Edimax BR-6524WG", 4, SIG_BR6524WG), BOARD_ADM("BR-6524WP", "Edimax BR-6524WP", 4, SIG_BR6524WP), BOARD_ADM("BR-6541K", "Edimax BR-6541K", 2, SIG_BR6541K), diff --git a/tools/firmware-utils/src/mkdapimg.c b/tools/firmware-utils/src/mkdapimg.c index 8b0359f74..ed662d8ec 100644 --- a/tools/firmware-utils/src/mkdapimg.c +++ b/tools/firmware-utils/src/mkdapimg.c @@ -27,6 +27,8 @@ #define MAX_MODEL_NAME_LEN 20 #define MAX_SIG_LEN 30 +#define MAX_REGION_LEN 4 +#define MAX_VERSION_LEN 12 struct img_hdr_struct { uint32_t checksum; @@ -51,7 +53,7 @@ perrexit(int code, char *msg) void usage() { - fprintf(stderr, "usage: %s [-p] [-m model] -s signature -i input -o output\n", progname); + fprintf(stderr, "usage: %s [-p] [-m model] [-r region] [-v version] -s signature -i input -o output\n", progname); exit(1); } @@ -60,8 +62,11 @@ main(int ac, char *av[]) { char model[MAX_MODEL_NAME_LEN+1]; char signature[MAX_SIG_LEN+1]; + char region[MAX_REGION_LEN+1]; + char version[MAX_VERSION_LEN+1]; int patchmode = 0; int fixmode = 0; + int have_regionversion = 0; FILE *ifile, *ofile; int c; @@ -71,11 +76,13 @@ main(int ac, char *av[]) progname = basename(av[0]); memset(model, 0, sizeof(model)); memset(signature, 0, sizeof(signature)); + memset(region, 0, sizeof(region)); + memset(version, 0, sizeof(version)); while ( 1 ) { int c; - c = getopt(ac, av, "pxm:s:i:o:"); + c = getopt(ac, av, "pxm:r:v:s:i:o:"); if (c == -1) break; @@ -94,6 +101,24 @@ main(int ac, char *av[]) } strcpy(model, optarg); break; + case 'r': + if (strlen(optarg) > MAX_REGION_LEN) { + fprintf(stderr, "%s: region exceeds %d chars\n", + progname, MAX_REGION_LEN); + exit(1); + } + have_regionversion = 1; + strcpy(region, optarg); + break; + case 'v': + if (strlen(optarg) > MAX_VERSION_LEN) { + fprintf(stderr, "%s: version exceeds %d chars\n", + progname, MAX_VERSION_LEN); + exit(1); + } + have_regionversion = 1; + strcpy(version, optarg); + break; case 's': if (strlen(optarg) > MAX_SIG_LEN) { fprintf(stderr, "%s: signature exceeds %d chars\n", @@ -150,6 +175,10 @@ main(int ac, char *av[]) imghdr.checksum = htonl(cksum); imghdr.partition = 0 ; // don't care? imghdr.hdr_len = sizeof(imghdr); + if (have_regionversion) { + imghdr.hdr_len += MAX_REGION_LEN; + imghdr.hdr_len += MAX_VERSION_LEN; + } imghdr.flash_byte_cnt = htonl(bcnt); } else { if (ntohl(imghdr.checksum) != cksum) { @@ -176,6 +205,12 @@ main(int ac, char *av[]) if (fwrite(&imghdr, sizeof(imghdr), 1, ofile) < 0) perrexit(2, "fwrite header on output"); + if (have_regionversion) { + if (fwrite(®ion, MAX_REGION_LEN, 1, ofile) < 0) + perrexit(2, "fwrite header on output"); + if (fwrite(&version, MAX_VERSION_LEN, 1, ofile) < 0) + perrexit(2, "fwrite header on output"); + } while ((c = fgetc(ifile)) != EOF) { if (fputc(c, ofile) == EOF) diff --git a/tools/firmware-utils/src/mkfwimage2.c b/tools/firmware-utils/src/mkfwimage2.c index ee09abba1..993c3d44e 100644 --- a/tools/firmware-utils/src/mkfwimage2.c +++ b/tools/firmware-utils/src/mkfwimage2.c @@ -212,7 +212,7 @@ static int image_layout_add_partition(const char *part_desc) } d = &im.parts[im.part_count]; - t = sscanf(part_desc, "%15[a-zA-Z]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%256s", + t = sscanf(part_desc, "%15[0-9a-zA-Z]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%256s", d->partition_name, offset, length, diff --git a/tools/firmware-utils/src/mktplinkfw.c b/tools/firmware-utils/src/mktplinkfw.c index 2be63356d..74a55fd27 100644 --- a/tools/firmware-utils/src/mktplinkfw.c +++ b/tools/firmware-utils/src/mktplinkfw.c @@ -32,17 +32,25 @@ #define HEADER_VERSION_V1 0x01000000 #define HWID_TL_MR3020_V1 0x30200001 #define HWID_TL_MR3220_V1 0x32200001 +#define HWID_TL_MR3220_V2 0x32200002 #define HWID_TL_MR3420_V1 0x34200001 +#define HWID_TL_MR3420_V2 0x34200002 #define HWID_TL_WA701N_V1 0x07010001 #define HWID_TL_WA7510N_V1 0x75100001 +#define HWID_TL_WA801ND_V1 0x08010001 +#define HWID_TL_WA830RE_V1 0x08300010 +#define HWID_TL_WA830RE_V2 0x08300002 #define HWID_TL_WA901ND_V1 0x09010001 #define HWID_TL_WA901ND_V2 0x09010002 +#define HWID_TL_WDR4900_V1 0x49000001 #define HWID_TL_WR703N_V1 0x07030101 +#define HWID_TL_WR720N_V3 0x07200103 #define HWID_TL_WR741ND_V1 0x07410001 #define HWID_TL_WR741ND_V4 0x07410004 #define HWID_TL_WR740N_V1 0x07400001 #define HWID_TL_WR740N_V3 0x07400003 #define HWID_TL_WR743ND_V1 0x07430001 +#define HWID_TL_WR743ND_V2 0x07430002 #define HWID_TL_WR841N_V1_5 0x08410002 #define HWID_TL_WR841ND_V3 0x08410003 #define HWID_TL_WR841ND_V5 0x08410005 @@ -173,6 +181,12 @@ static struct flash_layout layouts[] = { .kernel_ep = 0x80060000, .rootfs_ofs = 0x100000, }, { + .id = "16Mppc", + .fw_max_len = 0xf80000, + .kernel_la = 0x00000000, + .kernel_ep = 0xc0000000, + .rootfs_ofs = 0x2a0000, + }, { /* terminating entry */ } }; @@ -189,11 +203,21 @@ static struct board_info boards[] = { .hw_rev = 1, .layout_id = "4M", }, { + .id = "TL-MR3220v2", + .hw_id = HWID_TL_MR3220_V2, + .hw_rev = 1, + .layout_id = "4Mlzma", + }, { .id = "TL-MR3420v1", .hw_id = HWID_TL_MR3420_V1, .hw_rev = 1, .layout_id = "4M", }, { + .id = "TL-MR3420v2", + .hw_id = HWID_TL_MR3420_V2, + .hw_rev = 1, + .layout_id = "4Mlzma", + }, { .id = "TL-WA701Nv1", .hw_id = HWID_TL_WA701N_V1, .hw_rev = 1, @@ -204,6 +228,21 @@ static struct board_info boards[] = { .hw_rev = 1, .layout_id = "4M", }, { + .id = "TL-WA801NDv1", + .hw_id = HWID_TL_WA801ND_V1, + .hw_rev = 1, + .layout_id = "4M", + }, { + .id = "TL-WA830REv1", + .hw_id = HWID_TL_WA830RE_V1, + .hw_rev = 1, + .layout_id = "4M", + }, { + .id = "TL-WA830REv2", + .hw_id = HWID_TL_WA830RE_V2, + .hw_rev = 1, + .layout_id = "4M", + }, { .id = "TL-WA901NDv1", .hw_id = HWID_TL_WA901ND_V1, .hw_rev = 1, @@ -214,6 +253,11 @@ static struct board_info boards[] = { .hw_rev = 1, .layout_id = "4M", }, { + .id = "TL-WDR4900v1", + .hw_id = HWID_TL_WDR4900_V1, + .hw_rev = 1, + .layout_id = "16Mppc", + }, { .id = "TL-WR741NDv1", .hw_id = HWID_TL_WR741ND_V1, .hw_rev = 1, @@ -239,6 +283,11 @@ static struct board_info boards[] = { .hw_rev = 1, .layout_id = "4M", }, { + .id = "TL-WR743NDv2", + .hw_id = HWID_TL_WR743ND_V2, + .hw_rev = 1, + .layout_id = "4Mlzma", + }, { .id = "TL-WR841Nv1.5", .hw_id = HWID_TL_WR841N_V1_5, .hw_rev = 2, @@ -289,6 +338,11 @@ static struct board_info boards[] = { .hw_rev = 1, .layout_id = "4Mlzma", }, { + .id = "TL-WR720Nv3", + .hw_id = HWID_TL_WR720N_V3, + .hw_rev = 1, + .layout_id = "4Mlzma", + }, { /* terminating entry */ } }; @@ -371,6 +425,7 @@ static void usage(int status) " -E <ep> overwrite kernel entry point with <ep> (hexval prefixed with 0x)\n" " -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" " -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" |