ar71xx: add support for TP-Link TL-WR1043N v5
authorTim Thorpe <tim@tfthorpe.net>
Mon, 25 Sep 2017 09:38:49 +0000 (04:38 -0500)
committerPiotr Dymacz <pepe2k@gmail.com>
Tue, 14 Nov 2017 21:36:46 +0000 (22:36 +0100)
TP-Link TL-WR1043N v5 appears to be identical to the TL-WR1043ND v4,
except that the USB port has been removed and there is no longer a
removable antenna option.

The software is more in line with the Archer series in that it uses a
nested bootloader scheme.

Specifications:

 - QCA9563 at 775 MHz
 - 64 MB RAM
 - 16 MB flash
 - 3 (non-detachable) Antennas / 450 Mbit
 - 1x/4x WAN/LAN Gbps Ethernet (QCA8337)
 - reset and Wi-Fi buttons

Signed-off-by: Tim Thorpe <tim@tfthorpe.net>
Signed-off-by: Ludwig Thomeczek <ledesrc@wxorx.net>
14 files changed:
target/linux/ar71xx/base-files/etc/board.d/01_leds
target/linux/ar71xx/base-files/etc/board.d/02_network
target/linux/ar71xx/base-files/etc/diag.sh
target/linux/ar71xx/base-files/lib/ar71xx.sh
target/linux/ar71xx/base-files/lib/upgrade/platform.sh
target/linux/ar71xx/config-4.4
target/linux/ar71xx/config-4.9
target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr1043nd-v4.c
target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
target/linux/ar71xx/image/tp-link.mk
target/linux/ar71xx/mikrotik/config-default
target/linux/ar71xx/nand/config-default
tools/firmware-utils/src/tplink-safeloader.c

index b670259af8d1ba542b17e28eb5bac7d11fa538a3..e5baa90db896025961080723610a539d65ab6ba5 100755 (executable)
@@ -813,14 +813,20 @@ tl-wr1043nd-v2)
        ucidef_set_led_usbdev "usb" "USB" "tp-link:green:usb" "1-1"
        ucidef_set_led_wlan "wlan" "WLAN" "tp-link:green:wlan" "phy0tpt"
        ;;
+tl-wr1043n-v5|\
 tl-wr1043nd-v4)
-       ucidef_set_led_usbdev "usb" "USB" "tp-link:green:usb" "1-1"
        ucidef_set_led_wlan "wlan" "WLAN" "tp-link:green:wlan" "phy0tpt"
        ucidef_set_led_switch "wan" "WAN" "tp-link:green:wan" "switch0" "0x20"
        ucidef_set_led_switch "lan1" "LAN1" "tp-link:green:lan1" "switch0" "0x10"
        ucidef_set_led_switch "lan2" "LAN2" "tp-link:green:lan2" "switch0" "0x08"
        ucidef_set_led_switch "lan3" "LAN3" "tp-link:green:lan3" "switch0" "0x04"
        ucidef_set_led_switch "lan4" "LAN4" "tp-link:green:lan4" "switch0" "0x02"
+
+       case "$board" in
+       tl-wr1043nd-v4)
+               ucidef_set_led_usbdev "usb" "USB" "tp-link:green:usb" "1-1"
+               ;;
+       esac
        ;;
 tl-wr2543n)
        ucidef_set_led_wlan "wlan2g" "WLAN2G" "tp-link:green:wlan2g" "phy0tpt"
index 876eeaba61c389c5a32fe552ad79f7094c496929..7cf4212ac76d9d66a6d6aa459b5fd00b9f469603 100755 (executable)
@@ -277,7 +277,8 @@ ar71xx_setup_interfaces()
        dir-835-a1|\
        esr900|\
        mynet-n750|\
-       sr3200)
+       sr3200|\
+       tl-wr1043n-v5)
                ucidef_add_switch "switch0" \
                        "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
                ;;
@@ -542,6 +543,7 @@ ar71xx_setup_macs()
        fritz300e)
                lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
                ;;
+       tl-wr1043n-v5|\
        tl-wr1043nd-v4)
                lan_mac=$(mtd_get_mac_binary product-info 8)
                wan_mac=$(macaddr_add "$lan_mac" 1)
index 1f588fce5245faf56d50607cd8bea284ac81eb02..6cbb3576d8f4675041ba4de70f9e5c787a6b93d6 100644 (file)
@@ -395,6 +395,7 @@ get_status_led() {
        tl-wdr3320-v2|\
        tl-wdr3500|\
        tl-wr1041n-v2|\
+       tl-wr1043n-v5|\
        tl-wr1043nd|\
        tl-wr1043nd-v2|\
        tl-wr1043nd-v4|\
index 385214fc5472d886e2df3dff859f025c05b0b28f..285fa68357c76330d78bedf88448cff099fcd68a 100755 (executable)
@@ -1130,6 +1130,9 @@ ar71xx_board_detect() {
        *"TL-WR1041N v2")
                name="tl-wr1041n-v2"
                ;;
+       *"TL-WR1043N v5")
+               name="tl-wr1043n-v5"
+               ;;
        *"TL-WR1043ND")
                name="tl-wr1043nd"
                ;;
index 43c7ea7749c0db5c337105dfd219f5749fef1471..172a58ba67ff53adebf6125d0e1d94b8b6a5067f 100755 (executable)
@@ -278,6 +278,7 @@ platform_check_image() {
        tew-712br|\
        tew-732br|\
        tew-823dru|\
+       tl-wr1043n-v5|\
        tl-wr942n-v1|\
        unifi|\
        unifi-outdoor|\
index 3ce80f2d84cf70d373ee3820a5c2b9da4f43acc0..3ba3853720753fef45d6abaf6ee990f1f72ed12d 100644 (file)
@@ -199,6 +199,7 @@ CONFIG_ATH79_MACH_TL_WDR4300=y
 CONFIG_ATH79_MACH_TL_WDR6500_V2=y
 CONFIG_ATH79_MACH_TL_WPA8630=y
 CONFIG_ATH79_MACH_TL_WR1041N_V2=y
+CONFIG_ATH79_MACH_TL_WR1043N_V5=y
 CONFIG_ATH79_MACH_TL_WR1043ND=y
 CONFIG_ATH79_MACH_TL_WR1043ND_V2=y
 CONFIG_ATH79_MACH_TL_WR1043ND_V4=y
index 88d2c6eebe0dee73a474336e263578fd8375ff08..1d47246bf36b15487b1575a44e8f2d7ff3a95406 100644 (file)
@@ -197,6 +197,7 @@ CONFIG_ATH79_MACH_TL_WDR4300=y
 CONFIG_ATH79_MACH_TL_WDR6500_V2=y
 CONFIG_ATH79_MACH_TL_WPA8630=y
 CONFIG_ATH79_MACH_TL_WR1041N_V2=y
+CONFIG_ATH79_MACH_TL_WR1043N_V5=y
 CONFIG_ATH79_MACH_TL_WR1043ND=y
 CONFIG_ATH79_MACH_TL_WR1043ND_V2=y
 CONFIG_ATH79_MACH_TL_WR1043ND_V4=y
index aa2905231691d6d81af52935c0fd2f73a2c9c06c..1198fcb74bd15b630f01b5573bc3c50e81fa60e5 100644 (file)
@@ -1810,6 +1810,15 @@ config ATH79_MACH_TL_WR1041N_V2
        select ATH79_DEV_USB
        select ATH79_DEV_WMAC
 
+config ATH79_MACH_TL_WR1043N_V5
+       bool "TP-LINK TL-WR1043N v5 support"
+       select SOC_QCA956X
+       select ATH79_DEV_ETH
+       select ATH79_DEV_GPIO_BUTTONS
+       select ATH79_DEV_LEDS_GPIO
+       select ATH79_DEV_M25P80
+       select ATH79_DEV_WMAC
+
 config ATH79_MACH_TL_WR1043ND
        bool "TP-LINK TL-WR1043ND support"
        select SOC_AR913X
index b1539c5d71a61806b88c50f1a78f6a27d98d7a2d..450819a9e6baa997dab2dfba4c5a19261aae9664 100644 (file)
@@ -5,6 +5,7 @@
  *  Copyright (C) 2016 Matthias Schiffer <mschiffer@universe-factory.net>
  *  Copyright (C) 2016 Andreas Ziegler <github@andreas-ziegler.de>
  *  Copyright (C) 2016 Ludwig Thomeczek <ledesrc@wxorx.net>
+ *  Copyright (C) 2017 Tim Thorpe <tim@tfthorpe.net>
  *
  *  Derived from: mach-dir-869-a1.c
  *
@@ -62,6 +63,8 @@
 #define TL_WR1043_V4_EEPROM_ADDR               0x1fff0000
 #define TL_WR1043_V4_WMAC_CALDATA_OFFSET       0x1000
 
+#define TL_WR1043N_V5_MAC_LOCATION             0x1ff00008
+
 static struct gpio_led tl_wr1043nd_v4_leds_gpio[] __initdata = {
        {
                .name           = "tp-link:green:wps",
@@ -188,3 +191,82 @@ static void __init tl_wr1043nd_v4_setup(void)
 
 MIPS_MACHINE(ATH79_MACH_TL_WR1043ND_V4, "TL-WR1043ND-v4",
             "TP-LINK TL-WR1043ND v4", tl_wr1043nd_v4_setup);
+
+static struct gpio_led tl_wr1043n_v5_leds_gpio[] __initdata = {
+       {
+               .name           = "tp-link:green:wps",
+               .gpio           = TL_WR1043_V4_GPIO_LED_WPS,
+               .active_low     = 1,
+       },
+       {
+               .name           = "tp-link:green:system",
+               .gpio           = TL_WR1043_V4_GPIO_LED_SYSTEM,
+               .active_low     = 1,
+       },
+       {
+               .name           = "tp-link:green:wlan",
+               .gpio           = TL_WR1043_V4_GPIO_LED_WLAN,
+               .active_low     = 1,
+       },
+       {
+               .name           = "tp-link:green:wan",
+               .gpio           = TL_WR1043_V4_GPIO_LED_WAN,
+               .active_low     = 1,
+       },
+       {
+               .name           = "tp-link:green:lan1",
+               .gpio           = TL_WR1043_V4_GPIO_LED_LAN1,
+               .active_low     = 1,
+       },
+       {
+               .name           = "tp-link:green:lan2",
+               .gpio           = TL_WR1043_V4_GPIO_LED_LAN2,
+               .active_low     = 1,
+       },
+       {
+               .name           = "tp-link:green:lan3",
+               .gpio           = TL_WR1043_V4_GPIO_LED_LAN3,
+               .active_low     = 1,
+       },
+       {
+               .name           = "tp-link:green:lan4",
+               .gpio           = TL_WR1043_V4_GPIO_LED_LAN4,
+               .active_low     = 1,
+       },
+};
+
+/* The 1043Nv5 is identical to the 1043NDv4,
+ *  only missing the usb and small firmware layout changes  */
+static void __init tl_wr1043nv5_setup(void)
+{
+       u8 *art = (u8 *) KSEG1ADDR(TL_WR1043_V4_EEPROM_ADDR);
+       u8 *mac = (u8 *) KSEG1ADDR(TL_WR1043N_V5_MAC_LOCATION);
+
+       ath79_register_m25p80(NULL);
+
+       ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr1043n_v5_leds_gpio),
+                                tl_wr1043n_v5_leds_gpio);
+       ath79_register_gpio_keys_polled(-1, TL_WR1043_V4_KEYS_POLL_INTERVAL,
+                                       ARRAY_SIZE(tl_wr1043nd_v4_gpio_keys),
+                                       tl_wr1043nd_v4_gpio_keys);
+
+       platform_device_register(&ath79_mdio0_device);
+
+       mdiobus_register_board_info(tl_wr1043nd_v4_mdio0_info,
+                                   ARRAY_SIZE(tl_wr1043nd_v4_mdio0_info));
+
+       ath79_register_wmac(art + TL_WR1043_V4_WMAC_CALDATA_OFFSET, mac);
+
+       ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
+
+       /* GMAC0 is connected to an AR8337 switch */
+       ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
+       ath79_eth0_data.speed = SPEED_1000;
+       ath79_eth0_data.duplex = DUPLEX_FULL;
+       ath79_eth0_data.phy_mask = BIT(0);
+       ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
+       ath79_register_eth(0);
+}
+
+MIPS_MACHINE(ATH79_MACH_TL_WR1043N_V5, "TL-WR1043N-v5", "TP-LINK TL-WR1043N v5",
+            tl_wr1043nv5_setup);
index 146a79d04878e14a295eff279ce7cc96bc97761d..0f536f0ec5848e38e30891c0b9757991c910ebb0 100644 (file)
@@ -247,6 +247,7 @@ enum ath79_mach_type {
        ATH79_MACH_TL_WDR6500_V2,               /* TP-LINK TL-WDR6500 v2 */
        ATH79_MACH_TL_WPA8630,                  /* TP-Link TL-WPA8630 */
        ATH79_MACH_TL_WR1041N_V2,               /* TP-LINK TL-WR1041N v2 */
+       ATH79_MACH_TL_WR1043N_V5,               /* TP-LINK TL-WR1043N v5 */
        ATH79_MACH_TL_WR1043ND,                 /* TP-LINK TL-WR1043ND */
        ATH79_MACH_TL_WR1043ND_V2,              /* TP-LINK TL-WR1043ND v2 */
        ATH79_MACH_TL_WR1043ND_V4,              /* TP-LINK TL-WR1043ND v4 */
index c3cfdb9f47b14fd3ef8dc952d8e3a720bf954de3..8dd42d23d0637c8a69d103839c54201500c6558f 100644 (file)
@@ -676,6 +676,17 @@ define Device/tl-wr1041n-v2
 endef
 TARGET_DEVICES += tl-wr1041n-v2
 
+define Device/tl-wr1043n-v5
+  $(Device/archer-cxx)
+  DEVICE_TITLE := TP-LINK TL-WR1043N v5
+  BOARDNAME := TL-WR1043N-v5
+  SUPPORTED_DEVICES := tl-wr1043n-v5
+  DEVICE_PROFILE := TLWR1043
+  MTDPARTS := spi0.0:128k(factory-uboot)ro,128k(u-boot)ro,15104k(firmware),128k(product-info)ro,640k(config)ro,64k(partition-table)ro,128k(logs)ro,64k(art)ro
+  IMAGE_SIZE := 15104k
+  TPLINK_BOARD_ID := TLWR1043NV5
+endef
+
 define Device/tl-wr1043nd-v1
   $(Device/tplink-8m)
   DEVICE_TITLE := TP-LINK TL-WR1043N/ND v1
@@ -726,7 +737,7 @@ define Device/tl-wr2543-v1
   IMAGE/sysupgrade.bin := append-rootfs | mktplinkfw sysupgrade -v 3.13.99
   IMAGE/factory.bin := append-rootfs | mktplinkfw factory -v 3.13.99
 endef
-TARGET_DEVICES += tl-wr1043nd-v1 tl-wr1043nd-v2 tl-wr1043nd-v3 tl-wr1043nd-v4 tl-wr2543-v1
+TARGET_DEVICES += tl-wr1043nd-v1 tl-wr1043nd-v2 tl-wr1043nd-v3 tl-wr1043nd-v4 tl-wr1043n-v5 tl-wr2543-v1
 
 define Device/tl-wr703n-v1
   $(Device/tplink-4mlzma)
index 942f625469e85f1d9d85090ddbbf49cf37dce134..b67fca1f145c13f2a93f4801593c047878d6c61c 100644 (file)
@@ -159,6 +159,7 @@ CONFIG_ATH79_MACH_RBSXTLITE=y
 # CONFIG_ATH79_MACH_TL_WDR6500_V2 is not set
 # CONFIG_ATH79_MACH_TL_WPA8630 is not set
 # CONFIG_ATH79_MACH_TL_WR1041N_V2 is not set
+# CONFIG_ATH79_MACH_TL_WR1043N_V5 is not set
 # CONFIG_ATH79_MACH_TL_WR1043ND is not set
 # CONFIG_ATH79_MACH_TL_WR1043ND_V2 is not set
 # CONFIG_ATH79_MACH_TL_WR1043ND_V4 is not set
index c1dd3dcbe5a7510a0e8259e22146b8046d8cf2d3..f7c54e7d3cb8352ca82816edd5807b9c29d06d06 100644 (file)
@@ -155,6 +155,7 @@ CONFIG_ATH79_MACH_RAMBUTAN=y
 # CONFIG_ATH79_MACH_TL_WDR6500_V2 is not set
 # CONFIG_ATH79_MACH_TL_WPA8630 is not set
 # CONFIG_ATH79_MACH_TL_WR1041N_V2 is not set
+# CONFIG_ATH79_MACH_TL_WR1043N_V5 is not set
 # CONFIG_ATH79_MACH_TL_WR1043ND is not set
 # CONFIG_ATH79_MACH_TL_WR1043ND_V2 is not set
 # CONFIG_ATH79_MACH_TL_WR1043ND_V4 is not set
index c1f7c7d16ed8228f940245dda04a0a1a5c71bbfb..88e2e88bdf3072f4e3c7a9c6b058fe8579d5a802 100644 (file)
@@ -683,6 +683,42 @@ static struct device_info boards[] = {
                .last_sysupgrade_partition = "file-system"
        },
 
+       /** Firmware layout for the TL-WR1043 v5 */
+       {
+               .id     = "TLWR1043NV5",
+               .vendor = "",
+               .support_list =
+                       "SupportList:\n"
+                       "{product_name:TL-WR1043N,product_ver:5.0.0,special_id:45550000}\n"
+                       "{product_name:TL-WR1043N,product_ver:5.0.0,special_id:55530000}\n",
+               .support_trail = '\x00',
+               .soft_ver = "soft_ver:1.0.0\n",
+               .partitions = {
+                       {"factory-boot", 0x00000, 0x20000},
+                       {"fs-uboot", 0x20000, 0x20000},
+                       {"os-image", 0x40000, 0x180000},
+                       {"file-system", 0x1c0000, 0xd40000},
+                       {"default-mac", 0xf00000, 0x00200},
+                       {"pin", 0xf00200, 0x00200},
+                       {"device-id", 0xf00400, 0x00100},
+                       {"product-info", 0xf00500, 0x0fb00},
+                       {"soft-version", 0xf10000, 0x01000},
+                       {"extra-para", 0xf11000, 0x01000},
+                       {"support-list", 0xf12000, 0x0a000},
+                       {"profile", 0xf1c000, 0x04000},
+                       {"default-config", 0xf20000, 0x10000},
+                       {"user-config", 0xf30000, 0x40000},
+                       {"qos-db", 0xf70000, 0x40000},
+                       {"certificate", 0xfb0000, 0x10000},
+                       {"partition-table", 0xfc0000, 0x10000},
+                       {"log", 0xfd0000, 0x20000},
+                       {"radio", 0xff0000, 0x10000},
+                       {NULL, 0, 0}
+               },
+               .first_sysupgrade_partition = "os-image",
+               .last_sysupgrade_partition = "file-system"
+       },
+
        /** Firmware layout for the TL-WR1043 v4 */
        {
                .id     = "TLWR1043NDV4",
@@ -1261,7 +1297,9 @@ static void build_image(const char *output,
        parts[3] = read_file("os-image", kernel_image, false);
        parts[4] = read_file("file-system", rootfs_image, add_jffs2_eof);
 
-       if (strcasecmp(info->id, "ARCHER-C25-V1") == 0) {
+       /* Some devices need the extra-para partition to accept the firmware */
+       if (strcasecmp(info->id, "ARCHER-C25-V1") == 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) {