[kernel] kmod-usb-core is buildin on etrax target
[openwrt.git] / tools / firmware-utils / src / mktplinkfw.c
index cb6a59b..8e0f53e 100644 (file)
 #endif
 
 #define HEADER_VERSION_V1      0x01000000
+#define HWID_TL_WA901ND_V1     0x09010001
 #define HWID_TL_WR741ND_V1     0x07410001
+#define HWID_TL_WR841N_V1_5    0x08410002
 #define HWID_TL_WR841ND_V3     0x08410003
 #define HWID_TL_WR841ND_V5     0x08410005
 #define HWID_TL_WR941ND_V2     0x09410002
+#define HWID_TL_WR941ND_V4     0x09410004
+#define HWID_TL_WR1043ND_V1    0x10430001
 
 #define MD5SUM_LEN     16
 
@@ -92,6 +96,7 @@ static struct file_info kernel_info;
 static struct file_info rootfs_info;
 static struct file_info boot_info;
 static int combined;
+static int strip_padding;
 
 char md5salt_normal[MD5SUM_LEN] = {
        0xdc, 0xd7, 0x3a, 0xa5, 0xc3, 0x95, 0x98, 0xfb,
@@ -105,6 +110,14 @@ char md5salt_boot[MD5SUM_LEN] = {
 
 static struct board_info boards[] = {
        {
+               .id             = "TL-WA901NDv1",
+               .hw_id          = HWID_TL_WA901ND_V1,
+               .hw_rev         = 1,
+               .fw_max_len     = 0x3c0000,
+               .kernel_la      = 0x80060000,
+               .kernel_ep      = 0x80060000,
+               .rootfs_ofs     = 0x140000,
+       }, {
                .id             = "TL-WR741NDv1",
                .hw_id          = HWID_TL_WR741ND_V1,
                .hw_rev         = 1,
@@ -112,6 +125,14 @@ static struct board_info boards[] = {
                .kernel_la      = 0x80060000,
                .kernel_ep      = 0x80060000,
                .rootfs_ofs     = 0x140000,
+       }, {
+               .id             = "TL-WR841Nv1.5",
+               .hw_id          = HWID_TL_WR841N_V1_5,
+               .hw_rev         = 2,
+               .fw_max_len     = 0x3c0000,
+               .kernel_la      = 0x80060000,
+               .kernel_ep      = 0x80060000,
+               .rootfs_ofs     = 0x140000,
        }, {
                .id             = "TL-WR841NDv3",
                .hw_id          = HWID_TL_WR841ND_V3,
@@ -136,6 +157,22 @@ static struct board_info boards[] = {
                .kernel_la      = 0x80060000,
                .kernel_ep      = 0x80060000,
                .rootfs_ofs     = 0x140000,
+       }, {
+               .id             = "TL-WR941NDv4",
+               .hw_id          = HWID_TL_WR941ND_V4,
+               .hw_rev         = 1,
+               .fw_max_len     = 0x3c0000,
+               .kernel_la      = 0x80060000,
+               .kernel_ep      = 0x80060000,
+               .rootfs_ofs     = 0x140000,
+       }, {
+               .id             = "TL-WR1043NDv1",
+               .hw_id          = HWID_TL_WR1043ND_V1,
+               .hw_rev         = 1,
+               .fw_max_len     = 0x7c0000,
+               .kernel_la      = 0x80060000,
+               .kernel_ep      = 0x80060000,
+               .rootfs_ofs     = 0x140000,
        }, {
                /* terminating entry */
        }
@@ -191,7 +228,9 @@ static void usage(int status)
 "  -k <file>       read kernel image from the file <file>\n"
 "  -r <file>       read rootfs image from the file <file>\n"
 "  -o <file>       write output to the file <file>\n"
-"  -v <version>    set image version to <version>\n"
+"  -s              strip padding from the end of the image\n"
+"  -N <vendor>     set image vendor to <vendor>\n"
+"  -V <version>    set image version to <version>\n"
 "  -h              show this screen\n"
        );
 
@@ -379,6 +418,7 @@ static int build_fw(void)
        char *buf;
        char *p;
        int ret = EXIT_FAILURE;
+       int writelen = 0;
 
        buflen = board->fw_max_len;
 
@@ -394,16 +434,22 @@ static int build_fw(void)
        if (ret)
                goto out_free_buf;
 
+       writelen = kernel_info.file_size;
+
        if (!combined) {
                p = buf + board->rootfs_ofs;
                ret = read_to_buf(&rootfs_info, p);
                if (ret)
                        goto out_free_buf;
+
+               writelen = board->rootfs_ofs + rootfs_info.file_size;
        }
 
-       fill_header(buf, buflen);
+       if (!strip_padding)
+               writelen = buflen;
 
-       ret = write_fw(buf, buflen);
+       fill_header(buf, writelen);
+       ret = write_fw(buf, writelen);
        if (ret)
                goto out_free_buf;
 
@@ -427,7 +473,7 @@ int main(int argc, char *argv[])
        while ( 1 ) {
                int c;
 
-               c = getopt(argc, argv, "B:V:N:ck:r:o:v:h:");
+               c = getopt(argc, argv, "B:V:N:ck:r:o:hs");
                if (c == -1)
                        break;
 
@@ -453,8 +499,8 @@ int main(int argc, char *argv[])
                case 'o':
                        ofname = optarg;
                        break;
-               case 'v':
-                       version = optarg;
+               case 's':
+                       strip_padding = 1;
                        break;
                case 'h':
                        usage(EXIT_SUCCESS);
This page took 0.030621 seconds and 4 git commands to generate.