0042-ar71xx-add-support-for-TP-Link-TL-WR1043N-v5.patch 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. From: Tim Thorpe <tim@tfthorpe.net>
  2. Date: Mon, 25 Sep 2017 04:38:49 -0500
  3. Subject: ar71xx: add support for TP-Link TL-WR1043N v5
  4. TP-Link TL-WR1043N v5 appears to be identical to the TL-WR1043ND v4,
  5. except that the USB port has been removed and there is no longer a
  6. removable antenna option.
  7. The software is more in line with the Archer series in that it uses a
  8. nested bootloader scheme.
  9. Specifications:
  10. - QCA9563 at 775 MHz
  11. - 64 MB RAM
  12. - 16 MB flash
  13. - 3 (non-detachable) Antennas / 450 Mbit
  14. - 1x/4x WAN/LAN Gbps Ethernet (QCA8337)
  15. - reset and Wi-Fi buttons
  16. Signed-off-by: Tim Thorpe <tim@tfthorpe.net>
  17. Signed-off-by: Ludwig Thomeczek <ledesrc@wxorx.net>
  18. diff --git a/target/linux/ar71xx/base-files/etc/board.d/01_leds b/target/linux/ar71xx/base-files/etc/board.d/01_leds
  19. index e1efb561b33da4dcfcb82ee953cd888170476dfb..e67b5e38561e841b88e486341950c52e1d454322 100755
  20. --- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
  21. +++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
  22. @@ -666,14 +666,20 @@ tl-wr1043nd-v2)
  23. ucidef_set_led_usbdev "usb" "USB" "tp-link:green:usb" "1-1"
  24. ucidef_set_led_wlan "wlan" "WLAN" "tp-link:green:wlan" "phy0tpt"
  25. ;;
  26. +tl-wr1043n-v5|\
  27. tl-wr1043nd-v4)
  28. - ucidef_set_led_usbdev "usb" "USB" "tp-link:green:usb" "1-1"
  29. ucidef_set_led_wlan "wlan" "WLAN" "tp-link:green:wlan" "phy0tpt"
  30. ucidef_set_led_switch "wan" "WAN" "tp-link:green:wan" "switch0" "0x20"
  31. ucidef_set_led_switch "lan1" "LAN1" "tp-link:green:lan1" "switch0" "0x10"
  32. ucidef_set_led_switch "lan2" "LAN2" "tp-link:green:lan2" "switch0" "0x08"
  33. ucidef_set_led_switch "lan3" "LAN3" "tp-link:green:lan3" "switch0" "0x04"
  34. ucidef_set_led_switch "lan4" "LAN4" "tp-link:green:lan4" "switch0" "0x02"
  35. +
  36. + case "$board" in
  37. + tl-wr1043nd-v4)
  38. + ucidef_set_led_usbdev "usb" "USB" "tp-link:green:usb" "1-1"
  39. + ;;
  40. + esac
  41. ;;
  42. tl-wr2543n)
  43. ucidef_set_led_usbdev "usb" "USB" "tp-link:green:usb" "1-1"
  44. diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network b/target/linux/ar71xx/base-files/etc/board.d/02_network
  45. index cefb7413eac6ffc50e67f1eaf63def749314428b..454abe6a5005621967dd96e0282e7bce2a0b127e 100755
  46. --- a/target/linux/ar71xx/base-files/etc/board.d/02_network
  47. +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
  48. @@ -243,7 +243,8 @@ ar71xx_setup_interfaces()
  49. mynet-n750|\
  50. sr3200|\
  51. wndr3700v4|\
  52. - wndr4300)
  53. + wndr4300|\
  54. + tl-wr1043n-v5)
  55. ucidef_add_switch "switch0" \
  56. "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
  57. ;;
  58. @@ -487,6 +488,7 @@ ar71xx_setup_macs()
  59. lan_mac=$(mtd_get_mac_binary caldata 0)
  60. wan_mac=$(mtd_get_mac_binary caldata 6)
  61. ;;
  62. + tl-wr1043n-v5|\
  63. tl-wr1043nd-v4)
  64. lan_mac=$(mtd_get_mac_binary product-info 8)
  65. wan_mac=$(macaddr_add "$lan_mac" 1)
  66. diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh
  67. index 38cc5d7853c79f2a7800a387310a95abb3b4de1b..61db387c9ecefd7090c25a5f5d75fdbf65a44d65 100644
  68. --- a/target/linux/ar71xx/base-files/etc/diag.sh
  69. +++ b/target/linux/ar71xx/base-files/etc/diag.sh
  70. @@ -359,6 +359,7 @@ get_status_led() {
  71. tl-wdr3320-v2|\
  72. tl-wdr3500|\
  73. tl-wr1041n-v2|\
  74. + tl-wr1043n-v5|\
  75. tl-wr1043nd|\
  76. tl-wr1043nd-v2|\
  77. tl-wr1043nd-v4|\
  78. diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
  79. index fc7d862c2911e96f76622cbed23e99863814da63..8f8158bac8a28db4f4f15ce5c37f48a21084dc03 100755
  80. --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
  81. +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
  82. @@ -947,6 +947,9 @@ ar71xx_board_detect() {
  83. *"TL-WR1043ND v4")
  84. name="tl-wr1043nd-v4"
  85. ;;
  86. + *"TL-WR1043N v5")
  87. + name="tl-wr1043n-v5"
  88. + ;;
  89. *TL-WR2543N*)
  90. name="tl-wr2543n"
  91. ;;
  92. diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
  93. index 6258713dd0e3325ab109689f0ed3b51e27c41f89..774e3c8964ef724d1efbae56434aeaa9f1c298a4 100755
  94. --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
  95. +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
  96. @@ -269,6 +269,7 @@ platform_check_image() {
  97. tew-712br|\
  98. tew-732br|\
  99. tew-823dru|\
  100. + tl-wr1043n-v5|\
  101. unifi-outdoor|\
  102. unifiac-lite|\
  103. unifiac-pro|\
  104. diff --git a/target/linux/ar71xx/config-4.4 b/target/linux/ar71xx/config-4.4
  105. index c82fcf09228be7063967f2517e0942651234afb8..57b6d2e541d7ef9dea8570ba8de72164d97b9775 100644
  106. --- a/target/linux/ar71xx/config-4.4
  107. +++ b/target/linux/ar71xx/config-4.4
  108. @@ -181,6 +181,7 @@ CONFIG_ATH79_MACH_TL_WR1041N_V2=y
  109. CONFIG_ATH79_MACH_TL_WR1043ND=y
  110. CONFIG_ATH79_MACH_TL_WR1043ND_V2=y
  111. CONFIG_ATH79_MACH_TL_WR1043ND_V4=y
  112. +CONFIG_ATH79_MACH_TL_WR1043N_V5=y
  113. CONFIG_ATH79_MACH_TL_WR2543N=y
  114. CONFIG_ATH79_MACH_TL_WR703N=y
  115. CONFIG_ATH79_MACH_TL_WR720N_V3=y
  116. diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
  117. index fb2afb965c4641df7cdcaf0920f2d56b3717fa9b..7ad5419f51ec9909d8b59f33178221a7d81ec184 100644
  118. --- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
  119. +++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
  120. @@ -1564,6 +1564,15 @@ config ATH79_MACH_TL_WR1041N_V2
  121. select ATH79_DEV_USB
  122. select ATH79_DEV_WMAC
  123. +config ATH79_MACH_TL_WR1043N_V5
  124. + bool "TP-LINK TL-WR1043N v5 support"
  125. + select SOC_QCA956X
  126. + select ATH79_DEV_ETH
  127. + select ATH79_DEV_GPIO_BUTTONS
  128. + select ATH79_DEV_LEDS_GPIO
  129. + select ATH79_DEV_M25P80
  130. + select ATH79_DEV_WMAC
  131. +
  132. config ATH79_MACH_TL_WR1043ND
  133. bool "TP-LINK TL-WR1043ND support"
  134. select SOC_AR913X
  135. diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr1043nd-v4.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr1043nd-v4.c
  136. index b1539c5d71a61806b88c50f1a78f6a27d98d7a2d..450819a9e6baa997dab2dfba4c5a19261aae9664 100644
  137. --- a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr1043nd-v4.c
  138. +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr1043nd-v4.c
  139. @@ -5,6 +5,7 @@
  140. * Copyright (C) 2016 Matthias Schiffer <mschiffer@universe-factory.net>
  141. * Copyright (C) 2016 Andreas Ziegler <github@andreas-ziegler.de>
  142. * Copyright (C) 2016 Ludwig Thomeczek <ledesrc@wxorx.net>
  143. + * Copyright (C) 2017 Tim Thorpe <tim@tfthorpe.net>
  144. *
  145. * Derived from: mach-dir-869-a1.c
  146. *
  147. @@ -62,6 +63,8 @@
  148. #define TL_WR1043_V4_EEPROM_ADDR 0x1fff0000
  149. #define TL_WR1043_V4_WMAC_CALDATA_OFFSET 0x1000
  150. +#define TL_WR1043N_V5_MAC_LOCATION 0x1ff00008
  151. +
  152. static struct gpio_led tl_wr1043nd_v4_leds_gpio[] __initdata = {
  153. {
  154. .name = "tp-link:green:wps",
  155. @@ -188,3 +191,82 @@ static void __init tl_wr1043nd_v4_setup(void)
  156. MIPS_MACHINE(ATH79_MACH_TL_WR1043ND_V4, "TL-WR1043ND-v4",
  157. "TP-LINK TL-WR1043ND v4", tl_wr1043nd_v4_setup);
  158. +
  159. +static struct gpio_led tl_wr1043n_v5_leds_gpio[] __initdata = {
  160. + {
  161. + .name = "tp-link:green:wps",
  162. + .gpio = TL_WR1043_V4_GPIO_LED_WPS,
  163. + .active_low = 1,
  164. + },
  165. + {
  166. + .name = "tp-link:green:system",
  167. + .gpio = TL_WR1043_V4_GPIO_LED_SYSTEM,
  168. + .active_low = 1,
  169. + },
  170. + {
  171. + .name = "tp-link:green:wlan",
  172. + .gpio = TL_WR1043_V4_GPIO_LED_WLAN,
  173. + .active_low = 1,
  174. + },
  175. + {
  176. + .name = "tp-link:green:wan",
  177. + .gpio = TL_WR1043_V4_GPIO_LED_WAN,
  178. + .active_low = 1,
  179. + },
  180. + {
  181. + .name = "tp-link:green:lan1",
  182. + .gpio = TL_WR1043_V4_GPIO_LED_LAN1,
  183. + .active_low = 1,
  184. + },
  185. + {
  186. + .name = "tp-link:green:lan2",
  187. + .gpio = TL_WR1043_V4_GPIO_LED_LAN2,
  188. + .active_low = 1,
  189. + },
  190. + {
  191. + .name = "tp-link:green:lan3",
  192. + .gpio = TL_WR1043_V4_GPIO_LED_LAN3,
  193. + .active_low = 1,
  194. + },
  195. + {
  196. + .name = "tp-link:green:lan4",
  197. + .gpio = TL_WR1043_V4_GPIO_LED_LAN4,
  198. + .active_low = 1,
  199. + },
  200. +};
  201. +
  202. +/* The 1043Nv5 is identical to the 1043NDv4,
  203. + * only missing the usb and small firmware layout changes */
  204. +static void __init tl_wr1043nv5_setup(void)
  205. +{
  206. + u8 *art = (u8 *) KSEG1ADDR(TL_WR1043_V4_EEPROM_ADDR);
  207. + u8 *mac = (u8 *) KSEG1ADDR(TL_WR1043N_V5_MAC_LOCATION);
  208. +
  209. + ath79_register_m25p80(NULL);
  210. +
  211. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr1043n_v5_leds_gpio),
  212. + tl_wr1043n_v5_leds_gpio);
  213. + ath79_register_gpio_keys_polled(-1, TL_WR1043_V4_KEYS_POLL_INTERVAL,
  214. + ARRAY_SIZE(tl_wr1043nd_v4_gpio_keys),
  215. + tl_wr1043nd_v4_gpio_keys);
  216. +
  217. + platform_device_register(&ath79_mdio0_device);
  218. +
  219. + mdiobus_register_board_info(tl_wr1043nd_v4_mdio0_info,
  220. + ARRAY_SIZE(tl_wr1043nd_v4_mdio0_info));
  221. +
  222. + ath79_register_wmac(art + TL_WR1043_V4_WMAC_CALDATA_OFFSET, mac);
  223. +
  224. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  225. +
  226. + /* GMAC0 is connected to an AR8337 switch */
  227. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  228. + ath79_eth0_data.speed = SPEED_1000;
  229. + ath79_eth0_data.duplex = DUPLEX_FULL;
  230. + ath79_eth0_data.phy_mask = BIT(0);
  231. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  232. + ath79_register_eth(0);
  233. +}
  234. +
  235. +MIPS_MACHINE(ATH79_MACH_TL_WR1043N_V5, "TL-WR1043N-v5", "TP-LINK TL-WR1043N v5",
  236. + tl_wr1043nv5_setup);
  237. diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
  238. index 8864e0deda57b926e88dceebd26056a2f8099380..9cb4a7f2e1df641232289721b676a9b0149c76e5 100644
  239. --- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
  240. +++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
  241. @@ -214,6 +214,7 @@ enum ath79_mach_type {
  242. ATH79_MACH_TL_WDR6500_V2, /* TP-LINK TL-WDR6500 v2 */
  243. ATH79_MACH_TL_WPA8630, /* TP-Link TL-WPA8630 */
  244. ATH79_MACH_TL_WR1041N_V2, /* TP-LINK TL-WR1041N v2 */
  245. + ATH79_MACH_TL_WR1043N_V5, /* TP-LINK TL-WR1043N v5 */
  246. ATH79_MACH_TL_WR1043ND, /* TP-LINK TL-WR1043ND */
  247. ATH79_MACH_TL_WR1043ND_V2, /* TP-LINK TL-WR1043ND v2 */
  248. ATH79_MACH_TL_WR1043ND_V4, /* TP-LINK TL-WR1043ND v4 */
  249. diff --git a/target/linux/ar71xx/image/tp-link.mk b/target/linux/ar71xx/image/tp-link.mk
  250. index 6933654e575a1ef2c92e4c656696a479cba4c594..5be7cbfbd4ab7d73d679d52d2581459250e04302 100644
  251. --- a/target/linux/ar71xx/image/tp-link.mk
  252. +++ b/target/linux/ar71xx/image/tp-link.mk
  253. @@ -858,7 +858,22 @@ define Device/tl-wr1043nd-v4
  254. IMAGE/sysupgrade.bin := append-rootfs | tplink-safeloader sysupgrade
  255. IMAGE/factory.bin := append-rootfs | tplink-safeloader factory
  256. endef
  257. -TARGET_DEVICES += tl-wr1043nd-v1 tl-wr1043nd-v2 tl-wr1043nd-v3 tl-wr1043nd-v4
  258. +
  259. +define Device/tl-wr1043n-v5
  260. + DEVICE_TITLE := TP-LINK TL-WR1043N v5
  261. + BOARDNAME := TL-WR1043N-v5
  262. + SUPPORTED_DEVICES := tl-wr1043n-v5
  263. + DEVICE_PROFILE := TLWR1043
  264. + 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
  265. + IMAGE_SIZE := 15104k
  266. + KERNEL := kernel-bin | patch-cmdline | lzma | uImageArcher lzma
  267. + IMAGES := sysupgrade.bin factory.bin
  268. + IMAGE/sysupgrade.bin := append-rootfs | tplink-safeloader sysupgrade | \
  269. + append-metadata | check-size $$$$(IMAGE_SIZE)
  270. + IMAGE/factory.bin := append-rootfs | tplink-safeloader factory
  271. + TPLINK_BOARD_NAME := TLWR1043NV5
  272. +endef
  273. +TARGET_DEVICES += tl-wr1043nd-v1 tl-wr1043nd-v2 tl-wr1043nd-v3 tl-wr1043nd-v4 tl-wr1043n-v5
  274. define Device/tl-wr2543-v1
  275. $(Device/tplink-8mlzma)
  276. diff --git a/target/linux/ar71xx/mikrotik/config-default b/target/linux/ar71xx/mikrotik/config-default
  277. index 376835a703f91532300d0dd7c8ef66704acc6e05..f5af38a726f5ce33391223a4dbeb2fc0a8cac613 100644
  278. --- a/target/linux/ar71xx/mikrotik/config-default
  279. +++ b/target/linux/ar71xx/mikrotik/config-default
  280. @@ -143,6 +143,7 @@ CONFIG_ATH79_MACH_RBSXTLITE=y
  281. # CONFIG_ATH79_MACH_TL_WDR6500_V2 is not set
  282. # CONFIG_ATH79_MACH_TL_WPA8630 is not set
  283. # CONFIG_ATH79_MACH_TL_WR1041N_V2 is not set
  284. +# CONFIG_ATH79_MACH_TL_WR1043N_V5 is not set
  285. # CONFIG_ATH79_MACH_TL_WR1043ND is not set
  286. # CONFIG_ATH79_MACH_TL_WR1043ND_V2 is not set
  287. # CONFIG_ATH79_MACH_TL_WR1043ND_V4 is not set
  288. diff --git a/target/linux/ar71xx/nand/config-default b/target/linux/ar71xx/nand/config-default
  289. index 62be218e33cc6366ea89f363983f36523c419650..5c18f5d594d625f91ff10e21ddc5af2b3b4d768f 100644
  290. --- a/target/linux/ar71xx/nand/config-default
  291. +++ b/target/linux/ar71xx/nand/config-default
  292. @@ -52,6 +52,7 @@
  293. # CONFIG_ATH79_MACH_TL_WDR3500 is not set
  294. # CONFIG_ATH79_MACH_TL_WDR4300 is not set
  295. # CONFIG_ATH79_MACH_TL_WR1041N_V2 is not set
  296. +# CONFIG_ATH79_MACH_TL_WR1043N_V5 is not set
  297. # CONFIG_ATH79_MACH_TL_WR1043ND is not set
  298. # CONFIG_ATH79_MACH_TL_WR1043ND_V4 is not set
  299. # CONFIG_ATH79_MACH_TL_WR2543N is not set
  300. diff --git a/tools/firmware-utils/src/tplink-safeloader.c b/tools/firmware-utils/src/tplink-safeloader.c
  301. index 24684268b1a3fe491c4eb876a5ebefc700f2e56e..478d5d8e9b43bbe37694732c138048c8fe8d807c 100644
  302. --- a/tools/firmware-utils/src/tplink-safeloader.c
  303. +++ b/tools/firmware-utils/src/tplink-safeloader.c
  304. @@ -478,6 +478,42 @@ static struct device_info boards[] = {
  305. .last_sysupgrade_partition = "file-system"
  306. },
  307. + /** Firmware layout for the TL-WR1043 v5 */
  308. + {
  309. + .id = "TLWR1043NV5",
  310. + .vendor = "",
  311. + .support_list =
  312. + "SupportList:\n"
  313. + "{product_name:TL-WR1043N,product_ver:5.0.0,special_id:45550000}\n"
  314. + "{product_name:TL-WR1043N,product_ver:5.0.0,special_id:55530000}\n",
  315. + .support_trail = '\x00',
  316. + .soft_ver = "soft_ver:1.0.0\n",
  317. + .partitions = {
  318. + {"factory-boot", 0x00000, 0x20000},
  319. + {"fs-uboot", 0x20000, 0x20000},
  320. + {"os-image", 0x40000, 0x180000},
  321. + {"file-system", 0x1c0000, 0xd40000},
  322. + {"default-mac", 0xf00000, 0x00200},
  323. + {"pin", 0xf00200, 0x00200},
  324. + {"device-id", 0xf00400, 0x00100},
  325. + {"product-info", 0xf00500, 0x0fb00},
  326. + {"soft-version", 0xf10000, 0x01000},
  327. + {"extra-para", 0xf11000, 0x01000},
  328. + {"support-list", 0xf12000, 0x0a000},
  329. + {"profile", 0xf1c000, 0x04000},
  330. + {"default-config", 0xf20000, 0x10000},
  331. + {"user-config", 0xf30000, 0x40000},
  332. + {"qos-db", 0xf70000, 0x40000},
  333. + {"certificate", 0xfb0000, 0x10000},
  334. + {"partition-table", 0xfc0000, 0x10000},
  335. + {"log", 0xfd0000, 0x20000},
  336. + {"radio", 0xff0000, 0x10000},
  337. + {NULL, 0, 0}
  338. + },
  339. + .first_sysupgrade_partition = "os-image",
  340. + .last_sysupgrade_partition = "file-system"
  341. + },
  342. +
  343. /** Firmware layout for the RE450 */
  344. {
  345. .id = "RE450",
  346. @@ -888,7 +924,9 @@ static void build_image(const char *output,
  347. parts[3] = read_file("os-image", kernel_image, false);
  348. parts[4] = read_file("file-system", rootfs_image, add_jffs2_eof);
  349. - if (strcasecmp(info->id, "ARCHER-C25-V1") == 0) {
  350. + /* Some devices need the extra-para partition to accept the firmware */
  351. + if (strcasecmp(info->id, "ARCHER-C25-V1") == 0 ||
  352. + strcasecmp(info->id, "TLWR1043NV5") == 0) {
  353. const char mdat[11] = {0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00};
  354. parts[5] = put_data("extra-para", mdat, 11);
  355. }