<div dir="ltr"><div>From: Josh Bendavid <<a href="mailto:joshbendavid@gmail.com">joshbendavid@gmail.com</a>><br></div><div><br></div><div>Add support for Archer C2600 to tplink-safeloader by adding needed partition table, and vendor information plus support list strings.  Additional string C2600 is enabled for the -B option.</div><div><br></div><div>Signed-off-by: Josh Bendavid <<a href="mailto:joshbendavid@gmail.com">joshbendavid@gmail.com</a>><br></div><div>---</div><div><br></div><div>diff --git a/tools/firmware-utils/src/tplink-safeloader.c b/tools/firmware-utils/src/tplink-safeloader.c</div><div>index 77a894b..9bc2bcb 100644</div><div>--- a/tools/firmware-utils/src/tplink-safeloader.c</div><div>+++ b/tools/firmware-utils/src/tplink-safeloader.c</div><div>@@ -105,6 +105,8 @@ static const uint8_t md5_salt[16] = {</div><div> /** Vendor information for CPE210/220/510/520 */</div><div> static const char cpe510_vendor[] = "CPE510(TP-LINK|UN|N300-5):1.0\r\n";</div><div> </div><div>+/** Vendor information for C2600 */</div><div>+static const char c2600_vendor[] = "";</div><div> </div><div> /**</div><div>     The flash partition table for CPE210/220/510/520;</div><div>@@ -128,6 +130,39 @@ static const struct flash_partition_entry cpe510_partitions[] = {</div><div> };</div><div> </div><div> /**</div><div>+    The flash partition table for C2600;</div><div>+    it is the same as the one used by the stock images.</div><div>+*/</div><div>+static const struct flash_partition_entry c2600_partitions[] = {</div><div>+        {"SBL1", 0x00000, 0x20000},</div><div>+        {"MIBIB", 0x20000, 0x20000},</div><div>+        {"SBL2", 0x40000, 0x20000},</div><div>+        {"SBL3", 0x60000, 0x30000},</div><div>+        {"DDRCONFIG", 0x90000, 0x10000},</div><div>+        {"SSD", 0xa0000, 0x10000},</div><div>+        {"TZ", 0xb0000, 0x30000},</div><div>+        {"RPM", 0xe0000, 0x20000},</div><div>+        {"fs-uboot", 0x100000, 0x70000},</div><div>+        {"uboot-env", 0x170000, 0x40000},</div><div>+        {"radio", 0x1b0000, 0x40000},</div><div>+        {"os-image", 0x1f0000, 0x200000},</div><div>+        {"file-system", 0x3f0000, 0x1b00000},</div><div>+        {"default-mac", 0x1ef0000, 0x00200},</div><div>+        {"pin", 0x1ef0200, 0x00200},</div><div>+        {"product-info", 0x1ef0400, 0x0fc00},</div><div>+        {"partition-table", 0x1f00000, 0x10000},</div><div>+        {"soft-version", 0x1f10000, 0x10000},</div><div>+        {"support-list", 0x1f20000, 0x10000},</div><div>+        {"profile", 0x1f30000, 0x10000},</div><div>+        {"default-config", 0x1f40000, 0x10000},</div><div>+        {"user-config", 0x1f50000, 0x40000},</div><div>+        {"qos-db", 0x1f90000, 0x40000},</div><div>+        {"usb-config", 0x1fd0000, 0x10000},</div><div>+        {"log", 0x1fe0000, 0x20000},</div><div>+<span class="" style="white-space:pre">        </span>{NULL, 0, 0}</div><div>+};</div><div>+</div><div>+/**</div><div>    The support list for CPE210/220/510/520</div><div> */</div><div> static const char cpe510_support_list[] =</div><div>@@ -141,6 +176,13 @@ static const char cpe510_support_list[] =</div><div> <span class="" style="white-space:pre">  </span>"CPE220(TP-LINK|UN|N300-2):1.0\r\n"</div><div> <span class="" style="white-space:pre">    </span>"CPE220(TP-LINK|UN|N300-2):1.1\r\n";</div><div> </div><div>+/**</div><div>+   The support list for C2600</div><div>+*/</div><div>+static const char c2600_support_list[] =</div><div>+<span class="" style="white-space:pre">        </span>"SupportList:\r\n"</div><div>+<span class="" style="white-space:pre">      </span>"{product_name:Archer C2600,product_ver:1.0.0,special_id:00000000}\r\n";</div><div>+        </div><div> #define error(_ret, _errno, _str, ...)<span class="" style="white-space:pre">                             </span>\</div><div> <span class="" style="white-space:pre">        </span>do {<span class="" style="white-space:pre">                                                      </span>\</div><div> <span class="" style="white-space:pre">                </span>fprintf(stderr, _str ": %s\n", ## __VA_ARGS__,<span class="" style="white-space:pre">  </span>\</div><div>@@ -470,6 +512,39 @@ static void do_cpe510(const char *output, const char *kernel_image, const char *</div><div> <span class="" style="white-space:pre">            </span>free_image_partition(parts[i]);</div><div> }</div><div> </div><div>+/** Generates an image for C2600 and writes it to a file */</div><div>+static void do_c2600(const char *output, const char *kernel_image, const char *rootfs_image, uint32_t rev, bool add_jffs2_eof, bool sysupgrade) {</div><div>+<span class="" style="white-space:pre">    </span>struct image_partition_entry parts[6] = {};</div><div>+</div><div>+<span class="" style="white-space:pre">       </span>parts[0] = make_partition_table(c2600_partitions);</div><div>+<span class="" style="white-space:pre">        </span>parts[1] = make_soft_version(rev);</div><div>+<span class="" style="white-space:pre">        </span>parts[2] = make_support_list(c2600_support_list);</div><div>+<span class="" style="white-space:pre"> </span>parts[3] = read_file("os-image", kernel_image, false);</div><div>+<span class="" style="white-space:pre">  </span>parts[4] = read_file("file-system", rootfs_image, add_jffs2_eof);</div><div>+</div><div>+<span class="" style="white-space:pre">       </span>size_t len;</div><div>+<span class="" style="white-space:pre">       </span>void *image;</div><div>+<span class="" style="white-space:pre">      </span>if (sysupgrade)</div><div>+<span class="" style="white-space:pre">           </span>image = generate_sysupgrade_image(c2600_partitions, parts, &len);</div><div>+<span class="" style="white-space:pre">     </span>else</div><div>+<span class="" style="white-space:pre">              </span>image = generate_factory_image(c2600_vendor, parts, &len);</div><div>+</div><div>+<span class="" style="white-space:pre">    </span>FILE *file = fopen(output, "wb");</div><div>+<span class="" style="white-space:pre">       </span>if (!file)</div><div>+<span class="" style="white-space:pre">                </span>error(1, errno, "unable to open output file");</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>if (fwrite(image, len, 1, file) != 1)</div><div>+<span class="" style="white-space:pre">             </span>error(1, 0, "unable to write output file");</div><div>+</div><div>+<span class="" style="white-space:pre">     </span>fclose(file);</div><div>+</div><div>+<span class="" style="white-space:pre">     </span>free(image);</div><div>+</div><div>+<span class="" style="white-space:pre">      </span>size_t i;</div><div>+<span class="" style="white-space:pre"> </span>for (i = 0; parts[i].name; i++)</div><div>+<span class="" style="white-space:pre">           </span>free_image_partition(parts[i]);</div><div>+}</div><div>+</div><div> </div><div> /** Usage output */</div><div> static void usage(const char *argv0) {</div><div>@@ -552,6 +627,8 @@ int main(int argc, char *argv[]) {</div><div> </div><div> <span class="" style="white-space:pre">       </span>if (strcmp(board, "CPE510") == 0)</div><div> <span class="" style="white-space:pre">              </span>do_cpe510(output, kernel_image, rootfs_image, rev, add_jffs2_eof, sysupgrade);</div><div>+<span class="" style="white-space:pre">    </span>else if (strcmp(board, "C2600") == 0)</div><div>+<span class="" style="white-space:pre">           </span>do_c2600(output, kernel_image, rootfs_image, rev, add_jffs2_eof, sysupgrade);</div><div> <span class="" style="white-space:pre">    </span>else</div><div> <span class="" style="white-space:pre">             </span>error(1, 0, "unsupported board %s", board);</div><div> </div><div><br></div></div>