From 4caab808300ad75575d778bae6e184caa26aeabc Mon Sep 17 00:00:00 2001 From: Keith Maika Date: Fri, 15 Jun 2018 00:39:09 -0400 Subject: [PATCH] ar71xx: add support for TP-Link Archer C59 v2 TP-Link Archer C59v2 is a dual-band AC1350 router based on Qualcomm/Atheros QCA9561+QCA9886 chips. Specification: - 775/650/258 MHz (CPU/DDR/AHB) - 128 MB of RAM (DDR2) - 16 MB of FLASH (SPI NOR) - 3T3R 2.4 GHz - 2T2R 5 GHz - 5x 10/100 Mbps Ethernet - USB 2.0 port - UART header on PCB Flash instruction: - via web UI: 1. Download openwrt-ar71xx-generic-archer-c59-v2-squashfs-factory.bin 2. Login to router and open the Advanced tab 3. Navigate to System Tools -> Firmware Upgrade 4. Upload firmware using the Manual Upgrade form - via TFTP: 1. Set PC to fixed ip address 192.168.0.66 2. Download openwrt-ar71xx-generic-archer-c59-v2-squashfs-factory.bin and rename it to tp_recovery.bin 3. Start a tftp server with the file tp_recovery.bin in its root directory 4. Turn off the router 5. Press and hold Reset button 6. Turn on router with the reset button pressed and wait ~15 seconds 7. Release the reset button and after a short time the firmware should be transferred from the tftp server 8. Wait ~30 second to complete recovery. Signed-off-by: Keith Maika --- .../ar71xx/base-files/etc/board.d/01_leds | 4 +- .../ar71xx/base-files/etc/board.d/02_network | 1 + target/linux/ar71xx/base-files/etc/diag.sh | 1 + .../etc/hotplug.d/firmware/11-ath10k-caldata | 1 + .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 1 + target/linux/ar71xx/base-files/lib/ar71xx.sh | 3 + .../ar71xx/base-files/lib/upgrade/platform.sh | 1 + target/linux/ar71xx/config-4.9 | 1 + .../files/arch/mips/ath79/Kconfig.openwrt | 11 ++++ .../arch/mips/ath79/mach-archer-c59-v1.c | 61 +++++++++++++++++-- .../ar71xx/files/arch/mips/ath79/machtypes.h | 1 + target/linux/ar71xx/image/generic-tp-link.mk | 12 ++++ tools/firmware-utils/src/tplink-safeloader.c | 41 +++++++++++++ 13 files changed, 134 insertions(+), 5 deletions(-) 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 d15cff5111..af480cb001 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/01_leds +++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds @@ -129,6 +129,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" @@ -137,7 +138,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 3967dee94b..75c90a2701 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/02_network +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network @@ -249,6 +249,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/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh index 45b5d2adbb..fafdcce8f7 100644 --- a/target/linux/ar71xx/base-files/etc/diag.sh +++ b/target/linux/ar71xx/base-files/etc/diag.sh @@ -66,6 +66,7 @@ get_status_led() { 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/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 0ed624efc8..e08df23df6 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 @@ -168,6 +168,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 a763938ecd..b58cf9b591 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 27c4bec280..8f31f3ed70 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -492,6 +492,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 5a1f71b431..d469699d3c 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -212,6 +212,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 a1c6360ef5..8d25692ec8 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 a6903d2939..7b82b42e0a 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt +++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt @@ -1575,6 +1575,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 c500c91a1a..6cc40e6a7b 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 8328a6febc..0b959632db 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 89983779e7..3c0a89d2b8 100644 --- a/target/linux/ar71xx/image/generic-tp-link.mk +++ b/target/linux/ar71xx/image/generic-tp-link.mk @@ -45,6 +45,18 @@ define Device/archer-c59-v1 endef TARGET_DEVICES += archer-c59-v1 +define Device/archer-c59-v2 + $(Device/archer-c59-v1) + DEVICE_TITLE := TP-LINK Archer C59 v2 + 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,14400k(firmware),1664k(tplink)ro,64k@0xff0000(art)ro + 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 92d44856e5..15eaa830d6 100644 --- a/tools/firmware-utils/src/tplink-safeloader.c +++ b/tools/firmware-utils/src/tplink-safeloader.c @@ -463,6 +463,46 @@ 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:45550000}\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", + + /** We're using a dynamic kernel/rootfs split here */ + .partitions = { + {"factory-boot", 0x00000, 0x20000}, + {"fs-uboot", 0x20000, 0x10000}, + {"default-mac", 0x30000, 0x00200}, + {"pin", 0x30200, 0x00200}, + {"device-id", 0x30400, 0x00100}, + {"product-info", 0x30500, 0x0fb00}, + {"firmware", 0x40000, 0xe10000}, + {"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", @@ -1550,6 +1590,7 @@ 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-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};