ramips: add support for TP-Link Archer C6U v1 (EU)
[project/firmware-utils.git] / src / mktplinkfw.c
index ef19e1052943174489bab55b851e26f90f24ca85..ed785b48e562a02cb09fa6baf6d6bd2c68692a49 100644 (file)
@@ -107,6 +107,7 @@ static uint32_t reserved_space;
 static struct file_info inspect_info;
 static int extract = 0;
 static bool endian_swap = false;
+static bool rootfs_ofs_calc = false;
 
 static const char md5salt_normal[MD5SUM_LEN] = {
        0xdc, 0xd7, 0x3a, 0xa5, 0xc3, 0x95, 0x98, 0xfb,
@@ -143,6 +144,12 @@ static struct flash_layout layouts[] = {
                .kernel_la      = 0x80060000,
                .kernel_ep      = 0x80060000,
                .rootfs_ofs     = 0x100000,
+       }, {
+               .id             = "8Mmtk",
+               .fw_max_len     = 0x7c0000,
+               .kernel_la      = 0x80000000,
+               .kernel_ep      = 0x8000c310,
+               .rootfs_ofs     = 0x100000,
        }, {
                .id             = "16M",
                .fw_max_len     = 0xf80000,
@@ -170,6 +177,7 @@ static const struct fw_region regions[] = {
        /* Default region (universal) uses code 0 as well */
        {"US", 1},
        {"EU", 0},
+       {"BR", 0},
 };
 
 static const struct fw_region * find_region(const char *country) {
@@ -201,6 +209,7 @@ static void usage(int status)
 "  -r <file>       read rootfs image from the file <file>\n"
 "  -a <align>      align the rootfs start on an <align> bytes boundary\n"
 "  -R <offset>     overwrite rootfs offset with <offset> (hexval prefixed with 0x)\n"
+"  -O              calculate rootfs offset for combined images\n"
 "  -o <file>       write output to the file <file>\n"
 "  -s              strip padding from the end of the image\n"
 "  -j              add jffs2 end-of-filesystem markers\n"
@@ -383,6 +392,10 @@ void fill_header(char *buf, int len)
                hdr->rootfs_len = htonl(rootfs_info.file_size);
        }
 
+       if (combined && rootfs_ofs_calc) {
+               hdr->rootfs_ofs = htonl(sizeof(struct fw_header) + kernel_len);
+       }
+
        hdr->ver_hi = htons(fw_ver_hi);
        hdr->ver_mid = htons(fw_ver_mid);
        hdr->ver_lo = htons(fw_ver_lo);
@@ -538,7 +551,7 @@ int main(int argc, char *argv[])
        while ( 1 ) {
                int c;
 
-               c = getopt(argc, argv, "a:H:E:F:L:m:V:N:W:C:ci:k:r:R:o:xX:ehsjv:");
+               c = getopt(argc, argv, "a:H:E:F:L:m:V:N:W:C:ci:k:r:R:o:OxX:ehsjv:");
                if (c == -1)
                        break;
 
@@ -591,6 +604,9 @@ int main(int argc, char *argv[])
                case 'o':
                        ofname = optarg;
                        break;
+               case 'O':
+                       rootfs_ofs_calc = 1;
+                       break;
                case 's':
                        strip_padding = 1;
                        break;