From c3b5adfcf3c3c03d3c8e3e383b31a04271dbecca Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Wed, 29 Jan 2014 22:35:14 +0100 Subject: [PATCH] Support for TP-Link TL-WDR3500 --- Makefile | 10 ++++++ README.md | 2 ++ READMEPL.md | 2 ++ u-boot/Makefile | 31 +++++++++++++++++ u-boot/board/ar7240/db12x/db12x.c | 21 ++++++++++++ u-boot/cpu/mips/start_bootstrap.S | 57 +++++++++++++++++++++++++++++++ u-boot/include/configs/db12x.h | 2 +- 7 files changed, 124 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4842538..baca25d 100755 --- a/Makefile +++ b/Makefile @@ -97,6 +97,16 @@ tplink_wdr3600_43x0: @cp $(BUILD_TOPDIR)/u-boot/tuboot.bin $(BUILD_TOPDIR)/bin/temp.bin @make show_size +tplink_wdr3500: export UBOOT_FILE_NAME=uboot_for_tp-link_tl-wdr3500 +tplink_wdr3500: export MAX_UBOOT_SIZE=64 +tplink_wdr3500: export COMPRESSED_UBOOT=1 +tplink_wdr3500: export ETH_CONFIG=_s27 +tplink_wdr3500: + @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) wdr3500_config + @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all + @cp $(BUILD_TOPDIR)/u-boot/tuboot.bin $(BUILD_TOPDIR)/bin/temp.bin + @make show_size + tplink_mr3420_v2: export UBOOT_FILE_NAME=uboot_for_tp-link_tl-mr3420_v2 tplink_mr3420_v2: export MAX_UBOOT_SIZE=64 tplink_mr3420_v2: export COMPRESSED_UBOOT=1 diff --git a/README.md b/README.md index d357012..097520b 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ Currently supported devices: - **Atheros AR9344**: - TP-Link TL-WDR3600 v1 - TP-Link TL-WDR43x0 v1 + - TP-Link TL-WDR3500 v1 I tested this modification on most of these devices, with OpenWrt and OFW firmware. If you are not sure about the version of your device, please contact with me **before** you try to make an upgrade. Changing bootloader to a wrong version will probably damage your router and you will need special hardware to fix it, so please, **be very careful**. @@ -100,6 +101,7 @@ More information about supported devices: | [TP-Link TL-WA801ND v2](http://wikidevi.com/wiki/TP-LINK_TL-WA801ND_v2) | AR9341 | 4 MiB | 32 MiB DDR1 | 64 KiB, LZMA | RO | | [TP-Link TL-WDR3600 v1](http://wiki.openwrt.org/toh/tp-link/tl-wdr3600) | AR9344 | 8 MiB | 128 MiB DDR2 | 64 KiB, LZMA | RO | | [TP-Link TL-WDR43x0 v1](http://wiki.openwrt.org/toh/tp-link/tl-wdr4300) | AR9344 | 8 MiB | 128 MiB DDR2 | 64 KiB, LZMA | RO | +| [TP-Link TL-WDR3500 v1](http://wiki.openwrt.org/toh/tp-link/tl-wdr3500) | AR9344 | 8 MiB | 128 MiB DDR2 | 64 KiB, LZMA | RO | | [D-Link DIR-505 H/W ver. A1](http://wiki.openwrt.org/toh/d-link/dir-505) | AR1311 | 8 MiB | 64 MiB DDR2 | 64 KiB, LZMA | RO | *(LZMA) - U-Boot binary image is compressed with LZMA.* diff --git a/READMEPL.md b/READMEPL.md index cd50585..e24a800 100644 --- a/READMEPL.md +++ b/READMEPL.md @@ -74,6 +74,7 @@ Lista obecnie wspieranych urządzeń: - **Atheros AR9344**: - TP-Link TL-WDR3600 v1 - TP-Link TL-WDR43x0 v1 + - TP-Link TL-WDR3500 v1 Przetestowałem swoją modyfikację na większości z wymienionych powyżej urządzeń, z obrazami OpenWrt i oficjalnym firmware producenta. Jeżeli nie jesteś pewien wersji sprzętowej swojego urządzenia, proszę skontaktuj się ze mną **zanim** dokonasz wymiany obrazu bootloadera. Zmiana na niewłaściwą wersję najprawdopodobniej doprowadzi do uszkodzenia Twojego urządzenia i jedyną możliwością jego ponownego uruchomienia będzie przeprogramowanie kości FLASH w zewnętrznym programatorze. @@ -98,6 +99,7 @@ Dodatkowe informacje o wspieranych urządzeniach: | [TP-Link TL-WA801ND v2](http://wikidevi.com/wiki/TP-LINK_TL-WA801ND_v2) | AR9341 | 4 MiB | 32 MiB DDR1 | 64 KiB, LZMA | RO | | [TP-Link TL-WDR3600 v1](http://wiki.openwrt.org/toh/tp-link/tl-wdr3600) | AR9344 | 8 MiB | 128 MiB DDR2 | 64 KiB, LZMA | RO | | [TP-Link TL-WDR43x0 v1](http://wiki.openwrt.org/toh/tp-link/tl-wdr4300) | AR9344 | 8 MiB | 128 MiB DDR2 | 64 KiB, LZMA | RO | +| [TP-Link TL-WDR3500 v1](http://wiki.openwrt.org/toh/tp-link/tl-wdr3500) | AR9344 | 8 MiB | 128 MiB DDR2 | 64 KiB, LZMA | RO | | [D-Link DIR-505 H/W ver. A1](http://wiki.openwrt.org/toh/d-link/dir-505) | AR1311 | 8 MiB | 64 MiB DDR2 | 64 KiB, LZMA | RO | *(LZMA) - obraz binarny U-Boot został dodatkowo skompresowany przy pomocy LZMA.* diff --git a/u-boot/Makefile b/u-boot/Makefile index 292e048..f0d601e 100755 --- a/u-boot/Makefile +++ b/u-boot/Makefile @@ -516,6 +516,37 @@ wdr3600_43x0_config : unconfig wasp_common_config @./mkconfig -a db12x mips mips db12x ar7240 ar7240 +wdr3500_config : unconfig wasp_common_config + @echo '======= Configuring for TP-Link TL-WDR3500 at:' `date` '=======' + @echo "#define CONFIG_FOR_TPLINK_WDR3500_V1 1" >> include/config.h + @echo "#define DDR2_32BIT_SUPPORT 1" >> include/config.h + @echo "#define CFG_ATHRS27_PHY 1" >> include/config.h + @echo "#define CFG_AG7240_NMACS 2" >> include/config.h + @echo "#define GPIO_SYS_LED_BIT 14" >> include/config.h + @echo "#define GPIO_SYS_LED_ON 0" >> include/config.h + @echo "#define GPIO_WLAN_2G_LED_BIT 13" >> include/config.h + @echo "#define GPIO_WLAN_2G_LED_ON 0" >> include/config.h + @echo "#define GPIO_LAN1_LED_BIT 19" >> include/config.h + @echo "#define GPIO_LAN1_LED_ON 0" >> include/config.h + @echo "#define GPIO_LAN2_LED_BIT 20" >> include/config.h + @echo "#define GPIO_LAN2_LED_ON 0" >> include/config.h + @echo "#define GPIO_LAN3_LED_BIT 21" >> include/config.h + @echo "#define GPIO_LAN3_LED_ON 0" >> include/config.h + @echo "#define GPIO_LAN4_LED_BIT 22" >> include/config.h + @echo "#define GPIO_LAN4_LED_ON 0" >> include/config.h + @echo "#define GPIO_INTERNET_LED_BIT 18" >> include/config.h + @echo "#define GPIO_INTERNET_LED_ON 0" >> include/config.h + @echo "#define GPIO_QSS_LED_BIT 15" >> include/config.h + @echo "#define GPIO_QSS_LED_ON 0" >> include/config.h + @echo "#define GPIO_USB_LED_BIT 11" >> include/config.h + @echo "#define GPIO_USB_LED_ON 0" >> include/config.h + @echo "#define GPIO_RST_BUTTON_BIT 16" >> include/config.h + @echo "#define GPIO_RST_BUTTON_IS_ACTIVE_LOW 1" >> include/config.h + @echo "#define DEFAULT_FLASH_SIZE_IN_MB 8" >> include/config.h + @echo "#define BOARD_CUSTOM_STRING \"DB120 (AR9344) U-Boot for TL-WDR3500\"" >> include/config.h + + @./mkconfig -a db12x mips mips db12x ar7240 ar7240 + mr3420_v2_config : unconfig wasp_common_config @echo '======= Configuring for TP-Link TL-MR3420 v2 at:' `date` '=======' @echo "#define CONFIG_FOR_TPLINK_MR3420_V2 1" >> include/config.h diff --git a/u-boot/board/ar7240/db12x/db12x.c b/u-boot/board/ar7240/db12x/db12x.c index d25175b..7f91510 100755 --- a/u-boot/board/ar7240/db12x/db12x.c +++ b/u-boot/board/ar7240/db12x/db12x.c @@ -17,6 +17,7 @@ void led_toggle(void){ gpio = ar7240_reg_rd(AR934X_GPIO_OUT); #if defined(CONFIG_FOR_TPLINK_WDR3600_WDR43X0_V1) || \ + defined(CONFIG_FOR_TPLINK_WDR3500_V1) || \ defined(CONFIG_FOR_TPLINK_WR841N_V8) || \ defined(CONFIG_FOR_TPLINK_WA830RE_V2_WA801ND_V2) || \ defined(CONFIG_FOR_TPLINK_MR3420_V2) @@ -39,6 +40,16 @@ void all_led_on(void){ SETBITVAL(gpio, GPIO_USB1_LED_BIT, GPIO_USB1_LED_ON); SETBITVAL(gpio, GPIO_USB2_LED_BIT, GPIO_USB2_LED_ON); //SETBITVAL(gpio, GPIO_QSS_LED_BIT, GPIO_QSS_LED_ON); +#elif defined(CONFIG_FOR_TPLINK_WDR3500_V1) + SETBITVAL(gpio, GPIO_SYS_LED_BIT, GPIO_SYS_LED_ON); + SETBITVAL(gpio, GPIO_WLAN_2G_LED_BIT, GPIO_WLAN_2G_LED_ON); + SETBITVAL(gpio, GPIO_LAN1_LED_BIT, GPIO_LAN1_LED_ON); + SETBITVAL(gpio, GPIO_LAN2_LED_BIT, GPIO_LAN2_LED_ON); + SETBITVAL(gpio, GPIO_LAN3_LED_BIT, GPIO_LAN3_LED_ON); + SETBITVAL(gpio, GPIO_LAN4_LED_BIT, GPIO_LAN4_LED_ON); + SETBITVAL(gpio, GPIO_INTERNET_LED_BIT, GPIO_INTERNET_LED_ON); + SETBITVAL(gpio, GPIO_QSS_LED_BIT, GPIO_QSS_LED_ON); + SETBITVAL(gpio, GPIO_USB_LED_BIT, GPIO_USB_LED_ON); #elif defined(CONFIG_FOR_TPLINK_WR841N_V8) SETBITVAL(gpio, GPIO_SYS_LED_BIT, GPIO_SYS_LED_ON); SETBITVAL(gpio, GPIO_WLAN_LED_BIT, GPIO_WLAN_LED_ON); @@ -81,6 +92,16 @@ void all_led_off(void){ SETBITVAL(gpio, GPIO_USB1_LED_BIT, !GPIO_USB1_LED_ON); SETBITVAL(gpio, GPIO_USB2_LED_BIT, !GPIO_USB2_LED_ON); //SETBITVAL(gpio, GPIO_QSS_LED_BIT, !GPIO_QSS_LED_ON); +#elif defined(CONFIG_FOR_TPLINK_WDR3500_V1) + SETBITVAL(gpio, GPIO_SYS_LED_BIT, !GPIO_SYS_LED_ON); + SETBITVAL(gpio, GPIO_WLAN_2G_LED_BIT, !GPIO_WLAN_2G_LED_ON); + SETBITVAL(gpio, GPIO_LAN1_LED_BIT, !GPIO_LAN1_LED_ON); + SETBITVAL(gpio, GPIO_LAN2_LED_BIT, !GPIO_LAN2_LED_ON); + SETBITVAL(gpio, GPIO_LAN3_LED_BIT, !GPIO_LAN3_LED_ON); + SETBITVAL(gpio, GPIO_LAN4_LED_BIT, !GPIO_LAN4_LED_ON); + SETBITVAL(gpio, GPIO_INTERNET_LED_BIT, !GPIO_INTERNET_LED_ON); + SETBITVAL(gpio, GPIO_QSS_LED_BIT, !GPIO_QSS_LED_ON); + SETBITVAL(gpio, GPIO_USB_LED_BIT, !GPIO_USB_LED_ON); #elif defined(CONFIG_FOR_TPLINK_WR841N_V8) SETBITVAL(gpio, GPIO_SYS_LED_BIT, !GPIO_SYS_LED_ON); SETBITVAL(gpio, GPIO_WLAN_LED_BIT, !GPIO_WLAN_LED_ON); diff --git a/u-boot/cpu/mips/start_bootstrap.S b/u-boot/cpu/mips/start_bootstrap.S index 7ab95cc..b0619b0 100755 --- a/u-boot/cpu/mips/start_bootstrap.S +++ b/u-boot/cpu/mips/start_bootstrap.S @@ -249,6 +249,63 @@ reset: li v1, 0xF800 sw v1, 0(a1) +#elif defined(CONFIG_FOR_TPLINK_WDR3500_V1) + /* + * LEDs and buttons GPIOs on WDR3500 v1: + * + * 11 => USB LED + * 12 => USB POWER (active high) + * 13 => WLAN2G + * 14 => SYS + * 15 => QSS + * 18 => WAN + * 19 => LAN1 + * 20 => LAN2 + * 21 => LAN3 + * 22 => LAN4 + * + * 16 => Reset button + * 17 => Wi-Fi ON/OFF switch + * + * All OUT GPIOs are active LOW if not stated otherwise + */ + + // GPIO Init + li a1, AR934X_GPIO_OE + lw v1, 0(a1) + // Set GPIOs 11~15 and 18~22 as outputs + and v1, v1, 0xFF8307FF + // Set GPIOs 16~17 as inputs + or v1, v1, 0x30000 + sw v1, 0(a1) + + // Set GPIO function for GPIO 11 + li a1, AR934X_GPIO_OUT_FUNCTION2 + lw v1, 0(a1) + and v1, v1, 0x00FFFFFF + sw v1, 0(a1) + + // Set GPIO function for GPIOs 12~15 + li a1, AR934X_GPIO_OUT_FUNCTION3 + li v1, 0x0 + sw v1, 0(a1) + + // Set GPIO function for GPIOs 18~19 + li a1, AR934X_GPIO_OUT_FUNCTION4 + lw v1, 0(a1) + and v1, v1, 0xFFFF + sw v1, 0(a1) + + // Turn on power on USB + li a1, AR934X_GPIO_SET + li v1, 0x1000 + sw v1, 0(a1) + + // Turn off all LEDs + li a1, AR934X_GPIO_SET + li v1, 0x7CF800 + sw v1, 0(a1) + #elif defined(CONFIG_FOR_TPLINK_WR841N_V8) /* * LEDs and buttons GPIOs on WR841N/D v8: diff --git a/u-boot/include/configs/db12x.h b/u-boot/include/configs/db12x.h index 083be5d..ceae8d5 100755 --- a/u-boot/include/configs/db12x.h +++ b/u-boot/include/configs/db12x.h @@ -32,7 +32,7 @@ * Default bootargs */ #undef CONFIG_BOOTARGS -#if defined(CONFIG_FOR_TPLINK_WDR3600_WDR43X0_V1) +#if defined(CONFIG_FOR_TPLINK_WDR3600_WDR43X0_V1) || defined (CONFIG_FOR_TPLINK_WDR3500_V1) #define CONFIG_BOOTARGS "console=ttyS0,115200 root=31:02 rootfstype=squashfs init=/sbin/init mtdparts=ath-nor0:256k(u-boot),64k(u-boot-env),6336k(rootfs),1408k(uImage),64k(mib0),64k(ART)" #else #define CONFIG_BOOTARGS "console=ttyS0,115200 root=31:02 rootfstype=squashfs init=/sbin/init mtdparts=ath-nor0:128k(u-boot),1024k(kernel),2816k(rootfs),64k(config),64k(art)" -- 2.25.1