Support for TP-Link Archer C59 v2

I recently purchased a TP-Link Archer C59 hoping I would be able to load up LEDE on it. Unfortunately when it arrived I discovered it's a v2 and the HW list only says v1 is supported. I tried the v1 firmware on the off chance maybe it'd still work but no luck.

I opened up the router and was able to connect to it's UART port and poke around in the console there and log some of the boot diagnostics. I don't really know what I am doing or what to look for to try add support for this thing. I thought maybe if I provide the log someone with more knowledge/experience could figure something out.

I'd be happy to try and get whatever information is needed and try any test builds. Just let me know if I can be of assistance / what to do.

Console log: https://gist.github.com/kicken/ebf3c28973adc3a68c9412ad055496f0

I got the same.

There is a different flash layout:

[    0.660000] 0x000000000000-0x000000020000 : "factory-boot"
[    0.670000] 0x000000020000-0x000000040000 : "u-boot"
[    0.680000] 0x000000040000-0x000000160000 : "uImage"
[    0.680000] 0x000000160000-0x000000e50000 : "rootfs"
[    0.690000] mtd: partition "rootfs" set to be root filesystem
[ 0.700000] 0x000000ff0000-0x000001000000 : "ART"

I have modified generic-tp-link.mk and mach-archer-c59-v1.c

generic-tp-link.mk : There is block for archer-c58-v1
old:  IMAGE_SIZE := 14528k
old:  MTDPARTS := spi0.0:64k(u-boot)ro,64k(mac)ro,1536k(kernel),12992k(rootfs),1664k(tplink)ro,64k(art)ro,14528k@0x20000(firmware)
new:  IMAGE_SIZE := 16064k
new:  MTDPARTS := spi0.0:128k(factory-boot)ro,128k(u-boot)ro,1536k(kernel),12864k(rootfs),1664k(tplink)ro,64k(art)ro,14400k@0x40000(firmware)
mach-archer-c59-v1.c:
old:       u8 *mac = (u8 *) KSEG1ADDR(0x1f010008);
new:       u8 *mac = (u8 *) KSEG1ADDR(0x1f030008);

I was unable to upgrade thru web interface or tftp. (maybe layout in tplink-safeloader.c should be changed.)
What I did:

  1. compile firmware with changed generic-tp-link.mk and mach-archer-c59-v1.c
  2. split firmware to fit into original uImage and rootfs.
  3. upload mtd(program) and two files of firmware to tmp. (I have used wget from router)
  4. kill all unnecessary processes.
  5. "/tmp/mtd write /tmp/1.bin uImage
  6. "/tmp/mtd write /tmp/2.bin rootfs
  7. poweroff router by switch

it works is my case.

I was able to get things working more or less for this router, including being able to flash it via either the OEM interface or TFTP. There are only a couple small issues that I've been unable to figure out a solution for.

  • The LED's don't work initially, but they can be configured through Luci after flashing
  • The wifi radio's are initially offline, but can be brought up after flashing through luci.
diff --git a/target/linux/ar71xx/base-files/etc/board.d/01_leds b/target/linux/ar71xx/base-files/etc/board.d/01_leds
index f436854..4b9faf4 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
@@ -128,6 +128,7 @@ archer-c7)
 	;;
 archer-c58-v1|\
 archer-c59-v1|\
+archer-c59-v2|\
 archer-c60-v1|\
 archer-c60-v2)
 	ucidef_set_led_switch "lan" "LAN" "$board:green:lan" "switch0" "0x1E"
@@ -136,7 +137,8 @@ archer-c60-v2)
 	ucidef_set_led_wlan "wlan5g" "WLAN5G" "$board:green:wlan5g" "phy0tpt"
 
 	case "$board" in
-	archer-c59-v1)
+	archer-c59-v1)|\
+	archer-c59-v2)
 		ucidef_set_led_usbdev "usb" "USB" "$board:green:usb" "1-1"
 		;;
 	esac
diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network b/target/linux/ar71xx/base-files/etc/board.d/02_network
index 47153d9..dd1247c 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/02_network
+++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
@@ -244,6 +244,7 @@ ar71xx_setup_interfaces()
 		;;
 	archer-c58-v1|\
 	archer-c59-v1|\
+	archer-c59-v2|\
 	fritz4020|\
 	rb-450g)
 		ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
index f82026c..1cb1efd 100644
--- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
+++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -163,6 +163,7 @@ case "$FIRMWARE" in
 	case $board in
 	archer-c58-v1|\
 	archer-c59-v1|\
+	archer-c59-v2|\
 	archer-c60-v1|\
 	archer-c60-v2|\
 	cf-e355ac-v2|\
diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ar71xx/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
index a763938..b58cf9b 100644
--- a/target/linux/ar71xx/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
+++ b/target/linux/ar71xx/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
@@ -14,6 +14,7 @@ board=$(board_name)
 case "$board" in
 	archer-c58-v1|\
 	archer-c59-v1|\
+	archer-c59-v2|\
 	archer-c60-v1|\
 	archer-c60-v2)
 		echo $(macaddr_add $(mtd_get_mac_binary mac 8)  $(($PHYNBR - 1)) ) > /sys${DEVPATH}/macaddress
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index c64520d..26ba27e 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -481,6 +481,9 @@ ar71xx_board_detect() {
 		;;
 	*"Archer C59 v1")
 		name="archer-c59-v1"
+        ;;
+	*"Archer C59 v2")
+		name="archer-c59-v2"
 		;;
 	*"Archer C60 v1")
 		name="archer-c60-v1"
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index b3342e3..704a35d 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -209,6 +209,7 @@ platform_check_image() {
 	archer-c25-v1|\
 	archer-c58-v1|\
 	archer-c59-v1|\
+	archer-c59-v2|\
 	archer-c60-v1|\
 	archer-c60-v2|\
 	archer-c7-v4|\
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
index 7400f2c..ee22107 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
@@ -1530,6 +1530,17 @@ config ATH79_MACH_ARCHER_C59_V1
 	select ATH79_DEV_USB
 	select ATH79_DEV_WMAC
 
+config ATH79_MACH_ARCHER_C59_V2
+	bool "TP-LINK Archer C59 v2 support"
+	select SOC_QCA956X
+	select ATH79_DEV_AP9X_PCI if PCI
+	select ATH79_DEV_ETH
+	select ATH79_DEV_GPIO_BUTTONS
+	select ATH79_DEV_LEDS_GPIO
+	select ATH79_DEV_M25P80
+	select ATH79_DEV_USB
+	select ATH79_DEV_WMAC
+
 config ATH79_MACH_ARCHER_C60_V1
 	bool "TP-LINK Archer C60 v1 support"
 	select SOC_QCA956X
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c59-v1.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c59-v1.c
index c500c91..2e6f32f 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c59-v1.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c59-v1.c
@@ -215,9 +215,9 @@ static struct spi_board_info archer_c59_v1_spi_info[] = {
 	},
 };
 
-static void __init archer_c5x_v1_setup(void)
+static void __init archer_c5x_v1_setup(u32 macLocation)
 {
-	u8 *mac = (u8 *) KSEG1ADDR(0x1f010008);
+	u8 *mac = (u8 *) KSEG1ADDR(macLocation);
 	u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
 
 	ath79_register_m25p80(NULL);
@@ -270,7 +270,7 @@ static void __init archer_c5x_v1_setup(void)
 
 static void __init archer_c58_v1_setup(void)
 {
-	archer_c5x_v1_setup();
+	archer_c5x_v1_setup(0x1f010008);
 	ath79_register_leds_gpio(-1, ARRAY_SIZE(archer_c58_v1_leds_gpio),
 				archer_c58_v1_leds_gpio);
 }
@@ -280,10 +280,20 @@ MIPS_MACHINE(ATH79_MACH_ARCHER_C58_V1, "ARCHER-C58-V1",
 
 static void __init archer_c59_v1_setup(void)
 {
-	archer_c5x_v1_setup();
+	archer_c5x_v1_setup(0x1f010008);
 	ath79_register_leds_gpio(-1, ARRAY_SIZE(archer_c59_v1_leds_gpio),
 				archer_c59_v1_leds_gpio);
 }
 
 MIPS_MACHINE(ATH79_MACH_ARCHER_C59_V1, "ARCHER-C59-V1",
 	"TP-LINK Archer C59 v1", archer_c59_v1_setup);
+
+static void __init archer_c59_v2_setup(void)
+{
+	archer_c5x_v1_setup(0x1f030008);
+	ath79_register_leds_gpio(-1, ARRAY_SIZE(archer_c59_v1_leds_gpio),
+				archer_c59_v1_leds_gpio);
+}
+
+MIPS_MACHINE(ATH79_MACH_ARCHER_C59_V2, "ARCHER-C59-V2",
+	"TP-LINK Archer C59 v2", archer_c59_v2_setup);
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
index 1457d8b..0e0298f 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
+++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
@@ -47,6 +47,7 @@ enum ath79_mach_type {
 	ATH79_MACH_ARCHER_C5,			/* TP-LINK Archer C5 board */
 	ATH79_MACH_ARCHER_C58_V1,		/* TP-LINK Archer C58 V1 board */
 	ATH79_MACH_ARCHER_C59_V1,		/* TP-LINK Archer C59 V1 board */
+	ATH79_MACH_ARCHER_C59_V2,		/* TP-LINK Archer C59 V2 board */
 	ATH79_MACH_ARCHER_C60_V1,		/* TP-LINK Archer C60 V1 board */
 	ATH79_MACH_ARCHER_C60_V2,		/* TP-LINK Archer C60 V2 board */
 	ATH79_MACH_ARCHER_C7,			/* TP-LINK Archer C7 board */
diff --git a/target/linux/ar71xx/image/generic-tp-link.mk b/target/linux/ar71xx/image/generic-tp-link.mk
index b3b5fdf..09f25f3 100644
--- a/target/linux/ar71xx/image/generic-tp-link.mk
+++ b/target/linux/ar71xx/image/generic-tp-link.mk
@@ -49,6 +49,19 @@ define Device/archer-c59-v1
 endef
 TARGET_DEVICES += archer-c59-v1
 
+define Device/archer-c59-v2
+  $(Device/archer-cxx)
+  DEVICE_TITLE := TP-LINK Archer C59 v2
+  DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-ledtrig-usbport kmod-ath10k ath10k-firmware-qca9888
+  BOARDNAME := ARCHER-C59-V2
+  TPLINK_BOARD_ID := ARCHER-C59-V2
+  DEVICE_PROFILE := ARCHERC59V2
+  IMAGE_SIZE := 14400k
+  MTDPARTS := spi0.0:128k(factory-boot)ro,64k(u-boot)ro,64k(mac)ro,1536k(kernel),12864k(rootfs),1664k(tplink)ro,64k(art)ro,14400k@0x40000(firmware)
+  SUPPORTED_DEVICES := archer-c59-v2
+endef
+TARGET_DEVICES += archer-c59-v2
+
 define Device/archer-c60-v1
   $(Device/archer-cxx)
   DEVICE_TITLE := TP-LINK Archer C60 v1
diff --git a/tools/firmware-utils/src/tplink-safeloader.c b/tools/firmware-utils/src/tplink-safeloader.c
index 22bbc17..5948b46 100644
--- a/tools/firmware-utils/src/tplink-safeloader.c
+++ b/tools/firmware-utils/src/tplink-safeloader.c
@@ -421,6 +421,45 @@ static struct device_info boards[] = {
 		.last_sysupgrade_partition = "file-system",
 	},
 
+	/** Firmware layout for the C59v2 */
+	{
+		.id	= "ARCHER-C59-V2",
+		.vendor	= "",
+		.support_list =
+			"SupportList:\r\n"
+			"{product_name:Archer C59,product_ver:2.0.0,special_id:00000000}\r\n"
+			"{product_name:Archer C59,product_ver:2.0.0,special_id:55530000}\r\n",
+		.support_trail = '\x00',
+		.soft_ver = "soft_ver:2.0.0 Build 20161206 rel.7303\n",
+
+		.partitions = {
+			{"factory-boot", 0x00000, 0x20000},
+			{"fs-uboot", 0x20000, 0x10000},
+			{"default-mac", 0x30000, 0x00200},
+			{"pin", 0x30200, 0x00200},
+			{"device-id", 0x30400, 0x00100},
+			{"product-info", 0x30500, 0x0fb00},
+			{"os-image", 0x40000, 0x180000},
+			{"file-system", 0x1c0000, 0xc90000},
+			{"partition-table", 0xe50000, 0x10000},
+			{"soft-version", 0xe60000, 0x10000},
+			{"support-list", 0xe70000, 0x10000},
+			{"profile", 0xe80000, 0x10000},
+			{"default-config", 0xe90000, 0x10000},
+			{"user-config", 0xea0000, 0x40000},
+			{"usb-config", 0xee0000, 0x10000},
+			{"certificate", 0xef0000, 0x10000},
+			{"extra-para", 0xf00000, 0x10000},
+			{"qos-db", 0xf10000, 0x30000},
+			{"log", 0xfe0000, 0x10000},
+			{"radio", 0xff0000, 0x10000},
+			{NULL, 0, 0}
+		},
+
+		.first_sysupgrade_partition = "os-image",
+		.last_sysupgrade_partition = "file-system",
+	},
+
 	/** Firmware layout for the C60v1 */
 	{
 		.id	= "ARCHER-C60-V1",
@@ -1385,7 +1424,8 @@ static void build_image(const char *output,
 
 	/* Some devices need the extra-para partition to accept the firmware */
 	if (strcasecmp(info->id, "ARCHER-C25-V1") == 0 ||
-	    strcasecmp(info->id, "ARCHER-C60-V2") == 0 ||
+		strcasecmp(info->id, "ARCHER-C59-V2") == 0 ||
+		strcasecmp(info->id, "ARCHER-C60-V2") == 0 ||
 	    strcasecmp(info->id, "TLWR1043NV5") == 0) {
 		const char mdat[11] = {0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00};
 		parts[5] = put_data("extra-para", mdat, 11);

Hi, kicken.
it Works for me too.

in 01_leds:


"archer-c59-v1)|\"  should be "archer-c59-v1|\"

Thanks supaplex.

I did get the LED configuration problem resolved. In the 01_leds script $board was correctly 'archer-c59-v2' but the LED devices were incorrectly being named as 'archer-c59-v1' still. I updated the mach-archer-c59-v1.c file to provide the proper names.

I may try submitting a pull request in the next few days. In the mean time, here's an updated patch:

diff --git a/target/linux/ar71xx/base-files/etc/board.d/01_leds b/target/linux/ar71xx/base-files/etc/board.d/01_leds
index 8dc1a36..b880d65 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
@@ -128,15 +128,18 @@ archer-c7)
 	;;
 archer-c58-v1|\
 archer-c59-v1|\
+archer-c59-v2|\
 archer-c60-v1|\
 archer-c60-v2)
+	ucidef_set_led_default "power" "POWER" "$board:green:power" "1"
 	ucidef_set_led_switch "lan" "LAN" "$board:green:lan" "switch0" "0x1E"
 	ucidef_set_led_netdev "wan" "WAN" "$board:green:wan" "eth0"
 	ucidef_set_led_wlan "wlan" "WLAN" "$board:green:wlan2g" "phy1tpt"
 	ucidef_set_led_wlan "wlan5g" "WLAN5G" "$board:green:wlan5g" "phy0tpt"
 
 	case "$board" in
-	archer-c59-v1)
+	archer-c59-v1|\
+	archer-c59-v2)
 		ucidef_set_led_usbdev "usb" "USB" "$board:green:usb" "1-1"
 		;;
 	esac
diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network b/target/linux/ar71xx/base-files/etc/board.d/02_network
index 5044e7f..2c66a08 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/02_network
+++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
@@ -245,6 +245,7 @@ ar71xx_setup_interfaces()
 		;;
 	archer-c58-v1|\
 	archer-c59-v1|\
+	archer-c59-v2|\
 	fritz4020|\
 	rb-450g)
 		ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
index c3ae7b6..71327ea 100644
--- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
+++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -167,6 +167,7 @@ case "$FIRMWARE" in
 	case $board in
 	archer-c58-v1|\
 	archer-c59-v1|\
+	archer-c59-v2|\
 	archer-c60-v1|\
 	archer-c60-v2|\
 	cf-e355ac-v2|\
diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ar71xx/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
index a763938..b58cf9b 100644
--- a/target/linux/ar71xx/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
+++ b/target/linux/ar71xx/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
@@ -14,6 +14,7 @@ board=$(board_name)
 case "$board" in
 	archer-c58-v1|\
 	archer-c59-v1|\
+	archer-c59-v2|\
 	archer-c60-v1|\
 	archer-c60-v2)
 		echo $(macaddr_add $(mtd_get_mac_binary mac 8)  $(($PHYNBR - 1)) ) > /sys${DEVPATH}/macaddress
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index ce9225e..9ed0df1 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -481,6 +481,9 @@ ar71xx_board_detect() {
 		;;
 	*"Archer C59 v1")
 		name="archer-c59-v1"
+        ;;
+	*"Archer C59 v2")
+		name="archer-c59-v2"
 		;;
 	*"Archer C60 v1")
 		name="archer-c60-v1"
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index 192c4a7..28dae1d 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -209,6 +209,7 @@ platform_check_image() {
 	archer-c25-v1|\
 	archer-c58-v1|\
 	archer-c59-v1|\
+	archer-c59-v2|\
 	archer-c60-v1|\
 	archer-c60-v2|\
 	archer-c7-v4|\
diff --git a/target/linux/ar71xx/config-4.9 b/target/linux/ar71xx/config-4.9
index 0c0f8f5..41d0523 100644
--- a/target/linux/ar71xx/config-4.9
+++ b/target/linux/ar71xx/config-4.9
@@ -52,6 +52,7 @@ CONFIG_ATH79=y
 # CONFIG_ATH79_MACH_ARCHER_C25_V1 is not set
 # CONFIG_ATH79_MACH_ARCHER_C58_V1 is not set
 # CONFIG_ATH79_MACH_ARCHER_C59_V1 is not set
+# CONFIG_ATH79_MACH_ARCHER_C59_V2 is not set
 # CONFIG_ATH79_MACH_ARCHER_C60_V1 is not set
 # CONFIG_ATH79_MACH_ARCHER_C60_V2 is not set
 # CONFIG_ATH79_MACH_ARCHER_C7 is not set
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
index 72b3fe0..6d07f67 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
@@ -1540,6 +1540,17 @@ config ATH79_MACH_ARCHER_C59_V1
 	select ATH79_DEV_USB
 	select ATH79_DEV_WMAC
 
+config ATH79_MACH_ARCHER_C59_V2
+	bool "TP-LINK Archer C59 v2 support"
+	select SOC_QCA956X
+	select ATH79_DEV_AP9X_PCI if PCI
+	select ATH79_DEV_ETH
+	select ATH79_DEV_GPIO_BUTTONS
+	select ATH79_DEV_LEDS_GPIO
+	select ATH79_DEV_M25P80
+	select ATH79_DEV_USB
+	select ATH79_DEV_WMAC
+
 config ATH79_MACH_ARCHER_C60_V1
 	bool "TP-LINK Archer C60 v1 support"
 	select SOC_QCA956X
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c59-v1.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c59-v1.c
index c500c91..6cc40e6 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c59-v1.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c59-v1.c
@@ -146,6 +146,49 @@ static struct gpio_led archer_c59_v1_leds_gpio[] __initdata = {
 	},
 };
 
+static struct gpio_led archer_c59_v2_leds_gpio[] __initdata = {
+	{
+		.name		= "archer-c59-v2:green:power",
+		.gpio		= ARCHER_C59_74HC_GPIO_LED_POWER,
+		.active_low	= 1,
+	},
+	{
+		.name		= "archer-c59-v2:green:wlan2g",
+		.gpio		= ARCHER_C59_74HC_GPIO_LED_WLAN2,
+		.active_low	= 1,
+	},
+	{
+		.name		= "archer-c59-v2:green:wlan5g",
+		.gpio		= ARCHER_C59_74HC_GPIO_LED_WLAN5,
+		.active_low	= 1,
+	},
+	{
+		.name		= "archer-c59-v2:green:lan",
+		.gpio		= ARCHER_C59_74HC_GPIO_LED_LAN,
+		.active_low	= 1,
+	},
+	{
+		.name		= "archer-c59-v2:green:wan",
+		.gpio		= ARCHER_C59_74HC_GPIO_LED_WAN_GREEN,
+		.active_low	= 1,
+	},
+	{
+		.name		= "archer-c59-v2:amber:wan",
+		.gpio		= ARCHER_C59_74HC_GPIO_LED_WAN_AMBER,
+		.active_low	= 1,
+	},
+	{
+		.name		= "archer-c59-v2:green:wps",
+		.gpio		= ARCHER_C59_74HC_GPIO_LED_WPS,
+		.active_low	= 1,
+	},
+	{
+		.name		= "archer-c59-v2:green:usb",
+		.gpio		= ARCHER_C59_74HC_GPIO_LED_USB,
+		.active_low	= 1,
+	},
+};
+
 static struct gpio_keys_button archer_c59_v1_gpio_keys[] __initdata = {
 	{
 		.desc			= "Reset button",
@@ -215,9 +258,9 @@ static struct spi_board_info archer_c59_v1_spi_info[] = {
 	},
 };
 
-static void __init archer_c5x_v1_setup(void)
+static void __init archer_c5x_v1_setup(u32 macLocation)
 {
-	u8 *mac = (u8 *) KSEG1ADDR(0x1f010008);
+	u8 *mac = (u8 *) KSEG1ADDR(macLocation);
 	u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
 
 	ath79_register_m25p80(NULL);
@@ -270,7 +313,7 @@ static void __init archer_c5x_v1_setup(void)
 
 static void __init archer_c58_v1_setup(void)
 {
-	archer_c5x_v1_setup();
+	archer_c5x_v1_setup(0x1f010008);
 	ath79_register_leds_gpio(-1, ARRAY_SIZE(archer_c58_v1_leds_gpio),
 				archer_c58_v1_leds_gpio);
 }
@@ -280,10 +323,20 @@ MIPS_MACHINE(ATH79_MACH_ARCHER_C58_V1, "ARCHER-C58-V1",
 
 static void __init archer_c59_v1_setup(void)
 {
-	archer_c5x_v1_setup();
+	archer_c5x_v1_setup(0x1f010008);
 	ath79_register_leds_gpio(-1, ARRAY_SIZE(archer_c59_v1_leds_gpio),
 				archer_c59_v1_leds_gpio);
 }
 
 MIPS_MACHINE(ATH79_MACH_ARCHER_C59_V1, "ARCHER-C59-V1",
 	"TP-LINK Archer C59 v1", archer_c59_v1_setup);
+
+static void __init archer_c59_v2_setup(void)
+{
+	archer_c5x_v1_setup(0x1f030008);
+	ath79_register_leds_gpio(-1, ARRAY_SIZE(archer_c59_v2_leds_gpio),
+				archer_c59_v2_leds_gpio);
+}
+
+MIPS_MACHINE(ATH79_MACH_ARCHER_C59_V2, "ARCHER-C59-V2",
+	"TP-LINK Archer C59 v2", archer_c59_v2_setup);
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
index 3a1f66c..dbcc811 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
+++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
@@ -47,6 +47,7 @@ enum ath79_mach_type {
 	ATH79_MACH_ARCHER_C5,			/* TP-LINK Archer C5 board */
 	ATH79_MACH_ARCHER_C58_V1,		/* TP-LINK Archer C58 V1 board */
 	ATH79_MACH_ARCHER_C59_V1,		/* TP-LINK Archer C59 V1 board */
+	ATH79_MACH_ARCHER_C59_V2,		/* TP-LINK Archer C59 V2 board */
 	ATH79_MACH_ARCHER_C60_V1,		/* TP-LINK Archer C60 V1 board */
 	ATH79_MACH_ARCHER_C60_V2,		/* TP-LINK Archer C60 V2 board */
 	ATH79_MACH_ARCHER_C7,			/* TP-LINK Archer C7 board */
diff --git a/target/linux/ar71xx/image/generic-tp-link.mk b/target/linux/ar71xx/image/generic-tp-link.mk
index 429540a..9de2471 100644
--- a/target/linux/ar71xx/image/generic-tp-link.mk
+++ b/target/linux/ar71xx/image/generic-tp-link.mk
@@ -49,6 +49,19 @@ define Device/archer-c59-v1
 endef
 TARGET_DEVICES += archer-c59-v1
 
+define Device/archer-c59-v2
+  $(Device/archer-cxx)
+  DEVICE_TITLE := TP-LINK Archer C59 v2
+  DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-ledtrig-usbport kmod-ath10k ath10k-firmware-qca9888
+  BOARDNAME := ARCHER-C59-V2
+  TPLINK_BOARD_ID := ARCHER-C59-V2
+  DEVICE_PROFILE := ARCHERC59V2
+  IMAGE_SIZE := 14400k
+  MTDPARTS := spi0.0:128k(factory-boot)ro,64k(u-boot)ro,64k(mac)ro,1536k(kernel),12864k(rootfs),1664k(tplink)ro,64k(art)ro,14400k@0x40000(firmware)
+  SUPPORTED_DEVICES := archer-c59-v2
+endef
+TARGET_DEVICES += archer-c59-v2
+
 define Device/archer-c60-v1
   $(Device/archer-cxx)
   DEVICE_TITLE := TP-LINK Archer C60 v1
diff --git a/tools/firmware-utils/src/tplink-safeloader.c b/tools/firmware-utils/src/tplink-safeloader.c
index 22bbc17..dc164d4 100644
--- a/tools/firmware-utils/src/tplink-safeloader.c
+++ b/tools/firmware-utils/src/tplink-safeloader.c
@@ -421,6 +421,45 @@ static struct device_info boards[] = {
 		.last_sysupgrade_partition = "file-system",
 	},
 
+	/** Firmware layout for the C59v2 */
+	{
+		.id	= "ARCHER-C59-V2",
+		.vendor	= "",
+		.support_list =
+			"SupportList:\r\n"
+			"{product_name:Archer C59,product_ver:2.0.0,special_id:00000000}\r\n"
+			"{product_name:Archer C59,product_ver:2.0.0,special_id:55530000}\r\n",
+		.support_trail = '\x00',
+		.soft_ver = "soft_ver:2.0.0 Build 20161206 rel.7303\n",
+
+		.partitions = {
+			{"factory-boot", 0x00000, 0x20000},
+			{"fs-uboot", 0x20000, 0x10000},
+			{"default-mac", 0x30000, 0x00200},
+			{"pin", 0x30200, 0x00200},
+			{"device-id", 0x30400, 0x00100},
+			{"product-info", 0x30500, 0x0fb00},
+			{"os-image", 0x40000, 0x180000},
+			{"file-system", 0x1c0000, 0xc90000},
+			{"partition-table", 0xe50000, 0x10000},
+			{"soft-version", 0xe60000, 0x10000},
+			{"support-list", 0xe70000, 0x10000},
+			{"profile", 0xe80000, 0x10000},
+			{"default-config", 0xe90000, 0x10000},
+			{"user-config", 0xea0000, 0x40000},
+			{"usb-config", 0xee0000, 0x10000},
+			{"certificate", 0xef0000, 0x10000},
+			{"extra-para", 0xf00000, 0x10000},
+			{"qos-db", 0xf10000, 0x30000},
+			{"log", 0xfe0000, 0x10000},
+			{"radio", 0xff0000, 0x10000},
+			{NULL, 0, 0}
+		},
+
+		.first_sysupgrade_partition = "os-image",
+		.last_sysupgrade_partition = "file-system",
+	},
+
 	/** Firmware layout for the C60v1 */
 	{
 		.id	= "ARCHER-C60-V1",
@@ -1385,8 +1424,9 @@ static void build_image(const char *output,
 
 	/* Some devices need the extra-para partition to accept the firmware */
 	if (strcasecmp(info->id, "ARCHER-C25-V1") == 0 ||
-	    strcasecmp(info->id, "ARCHER-C60-V2") == 0 ||
-	    strcasecmp(info->id, "TLWR1043NV5") == 0) {
+			strcasecmp(info->id, "ARCHER-C59-V2") == 0 ||
+			strcasecmp(info->id, "ARCHER-C60-V2") == 0 ||
+			strcasecmp(info->id, "TLWR1043NV5") == 0) {
 		const char mdat[11] = {0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00};
 		parts[5] = put_data("extra-para", mdat, 11);
 	} else if (strcasecmp(info->id, "ARCHER-C7-V4") == 0) {

Hi,

I patched everything accordingly, but my firmware is still rejected by my C59v2 - does not matter if I try to use the webinterface or tftp to upload.
Mine is the US Version 2 - which one is yours, where its working? I read there is a v2 for Russia as well - maybe they are different as well...

Cheers

P.S.: maybe you could send me the binary you build and worked for your router so I can test it on the US version?

Mine is US v2.
Web interface accepts openwrt-ar71xx-generic-archer-c59-v2-squashfs-factory.bin.
I can compile one for you. Let me know if you still need it.

Mine is a US version 2.0 also. Below are some links to my latest build of the firmware, you're welcome to give them a try.

openwrt-ar71xx-generic-archer-c59-v2-squashfs-factory.bin
openwrt-ar71xx-generic-archer-c59-v2-squashfs-sysupgrade.bin

2 Likes

I'd just like to chime in (and send my thanks for making this happen) that I've been running the bin kicken compiled for about six hours of heavy use with 10-12 devices all connected over both wireless radios and have not had a single hiccup. Thanks a lot for posting the pre-compiled bin!

Quite fortunate timing for me, too, as I just bought the router two days ago as an emergency after one of my switches decided to croak after 10 years of heavy use

Thanks a lot! My Version is running as well now... did a little type somewhere v1 / v2 related....

Good work!

BTW: I am tempted to flash your version over mine, because I forgot to include luci... and "my" next version will be ready in a couple of hours..... anyone tried sysupgrade or am I first? :slight_smile:

Any updates on this?

I’d like to update my Archer C59 V2.0 to this if it is stable.
Thank you guys for the hard work!

I have a pull request open to get the changes merged, but can't say when/if that will get done.

In the mean time, you could use the builds I linked above. I can't speak too much toward how stables/performant my build is as I don't use it day-to-day, just on a test router. I haven't had any issues with it there though, and plan to put it on my parent's router next month when I visit. The builds are minimal, but downloading and installing extra software after flashing appears to work ok.

You could also create your own build by downloading the git repository and merging the pull request.

Just to close the loop: Support for Archer C59 v2 has been added with https://git.openwrt.org/?p=openwrt/openwrt.git;a=commit;h=4caab808300ad75575d778bae6e184caa26aeabc

Snapshot images are available at http://downloads.openwrt.org/snapshots/targets/ar71xx/generic/

I have the snapshot from this thread running on my C59 v2, but I can't seem to figure out how to install anything other than luci (get a bunch of kernel version errors).

Is there any plan for an official release build? Or a way I can build one myself? I don't see it in the 18.06.2 images here: https://downloads.openwrt.org/releases/18.06.2/targets/ar71xx/generic/

That is expected with a snapshot image, see https://openwrt.org/releases/snapshot

Great, thanks for that info! That makes sense.

I had assumed based on this thread that it would be included in the next release, but it seems the support for the C59 v2 may not be mature enough to be considered for stable?

I'll start having a look around the site to see if I can get involved to help get it there.

18.06.2 is a maintenance release (more or less important bugfixes only, no new features or device additions), not a feature release, you'll have to wait for 19.0x.0 for that.

Gotcha, that also makes sense! Thanks so much

Annnnd it's gone, although the snapshot that was up works thankfully

I've put together an attempt at porting this router to ath79. I'm letting it run for a while to test before submitting a pull request. If anyone would like to try it in the mean time the you can build it using my github branch or try the build I created.

openwrt-ath79-generic-tplink_archer-c59-v2-squashfs-factory.bin
openwrt-ath79-generic-tplink_archer-c59-v2-squashfs-sysupgrade.bin