diff mbox series

[LEDE-DEV] ar71xx: add support for TP-Link TL-WDR7500v6

Message ID CAHLa1eurkoMr=SOHtK1siq606UxF6BRpYw86Nmk2AXeJVPeyDg@mail.gmail.com
State Changes Requested, archived
Delegated to: Piotr Dymacz
Headers show
Series [LEDE-DEV] ar71xx: add support for TP-Link TL-WDR7500v6 | expand

Commit Message

Bizon Oct. 30, 2017, 7:32 p.m. UTC
Add support for TP-Link TL-WDR7500 V6.

Specifications:
- WiSoC: QCA9563 - 3x3 2.4GHz
- Radio2: QCA9880 - 3x3 5GHz
- RAM: 64MB DDR2
- Storage: 8MB NOR SPI flash, can be replaced with 16M
- Switch: RTL8367S, now unmanaged
- Ethernet: 5x1G
- Misc: 2x button, 2x LED

Signed-off-by: Karol Bizewski <bizongod@gmail.com>
---
 package/boot/uboot-envtools/files/ar71xx                |  2 ++
 target/linux/ar71xx/base-files/etc/board.d/02_network   |  2 ++
 target/linux/ar71xx/base-files/etc/diag.sh              |  4 ++++
 .../base-files/etc/hotplug.d/firmware/11-ath10k-caldata |  5 +++++
 target/linux/ar71xx/base-files/lib/ar71xx.sh            |  6 ++++++
 target/linux/ar71xx/config-4.4                          |  1 +
 target/linux/ar71xx/config-4.9                          |  1 +
 .../linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt  | 10 ++++++++++
 target/linux/ar71xx/files/arch/mips/ath79/Makefile      |  1 +
 target/linux/ar71xx/files/arch/mips/ath79/machtypes.h   |  1 +
 target/linux/ar71xx/image/generic.mk                    | 17 +++++++++++++++++
 .../files/arch/mips/ath79/mach-tl-wdr7500-v6.c          | 112
+++++++++++++++++++++
 12 files changed, 162 insertions(+)
 create mode 100644
target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr7500-v6.c

 diff --git a/package/boot/uboot-envtools/files/ar71xx
b/package/boot/uboot-envtools/files/ar71xx
index 0bdb6de..789c317 100644
TL-WDR7500 v6", tl_wdr7500_v6_setup);

Comments

Chuanhong Guo Oct. 31, 2017, 2:43 p.m. UTC | #1
Hello!

2017-10-31 3:32 GMT+08:00 Bizon <bizongod@gmail.com>:
> Add support for TP-Link TL-WDR7500 V6.
>
> Specifications:
> - WiSoC: QCA9563 - 3x3 2.4GHz
> - Radio2: QCA9880 - 3x3 5GHz
> - RAM: 64MB DDR2
> - Storage: 8MB NOR SPI flash, can be replaced with 16M
> - Switch: RTL8367S, now unmanaged
Do you mean that this device support is incomplete and the network
switch is currently broken?
I noticed that there is nothing about this switch in
mach-tl-wdr7500-v6.c and in board.d/02_network you've placed this
device with WR703N which has only one ethernet port.
> - Ethernet: 5x1G
> - Misc: 2x button, 2x LED
>
> Signed-off-by: Karol Bizewski <bizongod@gmail.com>
> ---
>  package/boot/uboot-envtools/files/ar71xx                |  2 ++
>  target/linux/ar71xx/base-files/etc/board.d/02_network   |  2 ++
>  target/linux/ar71xx/base-files/etc/diag.sh              |  4 ++++
>  .../base-files/etc/hotplug.d/firmware/11-ath10k-caldata |  5 +++++
>  target/linux/ar71xx/base-files/lib/ar71xx.sh            |  6 ++++++
>  target/linux/ar71xx/config-4.4                          |  1 +
>  target/linux/ar71xx/config-4.9                          |  1 +
>  .../linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt  | 10 ++++++++++
>  target/linux/ar71xx/files/arch/mips/ath79/Makefile      |  1 +
>  target/linux/ar71xx/files/arch/mips/ath79/machtypes.h   |  1 +
>  target/linux/ar71xx/image/generic.mk                    | 17 +++++++++++++++++
>  .../files/arch/mips/ath79/mach-tl-wdr7500-v6.c          | 112
> +++++++++++++++++++++
>  12 files changed, 162 insertions(+)
>  create mode 100644
> target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr7500-v6.c
>
>  diff --git a/package/boot/uboot-envtools/files/ar71xx
> b/package/boot/uboot-envtools/files/ar71xx
> index 0bdb6de..789c317 100644
> --- a/package/boot/uboot-envtools/files/ar71xx
> +++ b/package/boot/uboot-envtools/files/ar71xx
> @@ -46,6 +46,8 @@ om5p-acv2|\
>  om5p-an|\
>  sr3200|\
>  tube2h|\
> +tl-wdr7500-v6|\
> +tl-wdr7500-v6-16M|\
>  wndr3700|\
>  xd3200)
>   ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
> 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 d838352..6cdd2fe 100755
> --- a/target/linux/ar71xx/base-files/etc/board.d/02_network
> +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
> @@ -122,6 +122,8 @@ ar71xx_setup_interfaces()
>   tl-wa901nd-v2|\
>   tl-wa901nd-v3|\
>   tl-wa901nd-v4|\
> + tl-wdr7500-v6|\
> + tl-wdr7500-v6-16M|\
>   tl-wr703n|\
>   tl-wr802n-v1|\
>   tl-wr802n-v2|\
> diff --git a/target/linux/ar71xx/base-files/etc/diag.sh
> b/target/linux/ar71xx/base-files/etc/diag.sh
> index ade726f..f0ec9e6 100644
> --- a/target/linux/ar71xx/base-files/etc/diag.sh
> +++ b/target/linux/ar71xx/base-files/etc/diag.sh
> @@ -20,6 +20,10 @@ get_status_led() {
>   all0305)
>   status_led="eap7660d:green:ds4"
>   ;;
> + tl-wdr7500-v6|\
> + tl-wdr7500-v6-16M)
> + status_led="$board:blue:system"
> + ;;
>   antminer-s1|\
>   antminer-s3|\
>   antminer-r1|\
> 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 85a2a63..bd0cf2e 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
> @@ -98,6 +98,11 @@ case "$FIRMWARE" in
>   rb-952ui-5ac2nd)
>   ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 20480 2116
>   ;;
> + tl-wdr7500-v6|\
> + tl-wdr7500-v6-16M)
> + ath10kcal_extract "art" 8192 2116
> + ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +2)
> + ;;
>   re450|\
>   tl-wr902ac-v1)
>   ath10kcal_extract "art" 20480 2116
> diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh
> b/target/linux/ar71xx/base-files/lib/ar71xx.sh
> index 835ced6..dbf132b 100755
> --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
> +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
> @@ -1109,6 +1109,12 @@ ar71xx_board_detect() {
>   *"TL-WDR6500 v2")
>   name="tl-wdr6500-v2"
>   ;;
> + *"TL-WDR7500 v6")
> +                local size="$(mtd_get_part_size 'firmware')"
> +
> +                [ "$size" = "8060928" ] && name="tl-wdr7500-v6"
> +                [ "$size" = "16449536" ] && name="tl-wdr7500-v6-16M"
Actually you needn't specify two different "name" here as both of them
apply the same default configuration.
> + ;;
>   *"TL-WPA8630")
>   name="tl-wpa8630"
>   ;;
> diff --git a/target/linux/ar71xx/config-4.4 b/target/linux/ar71xx/config-4.4
> index 0e77560..32b7fbe 100644
> --- a/target/linux/ar71xx/config-4.4
> +++ b/target/linux/ar71xx/config-4.4
> @@ -196,6 +196,7 @@ CONFIG_ATH79_MACH_TL_WDR3320_V2=y
>  CONFIG_ATH79_MACH_TL_WDR3500=y
>  CONFIG_ATH79_MACH_TL_WDR4300=y
>  CONFIG_ATH79_MACH_TL_WDR6500_V2=y
> +CONFIG_ATH79_MACH_TL_WDR7500_V6=y
>  CONFIG_ATH79_MACH_TL_WPA8630=y
>  CONFIG_ATH79_MACH_TL_WR1041N_V2=y
>  CONFIG_ATH79_MACH_TL_WR1043ND=y
> diff --git a/target/linux/ar71xx/config-4.9 b/target/linux/ar71xx/config-4.9
> index c5b8908..5f74076 100644
> --- a/target/linux/ar71xx/config-4.9
> +++ b/target/linux/ar71xx/config-4.9
> @@ -194,6 +194,7 @@ CONFIG_ATH79_MACH_TL_WDR3320_V2=y
>  CONFIG_ATH79_MACH_TL_WDR3500=y
>  CONFIG_ATH79_MACH_TL_WDR4300=y
>  CONFIG_ATH79_MACH_TL_WDR6500_V2=y
> +CONFIG_ATH79_MACH_TL_WDR7500_V6=y
>  CONFIG_ATH79_MACH_TL_WPA8630=y
>  CONFIG_ATH79_MACH_TL_WR1041N_V2=y
>  CONFIG_ATH79_MACH_TL_WR1043ND=y
> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
> b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
> index 454aee6..c6e75db 100644
> --- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
> +++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
> @@ -1613,6 +1613,16 @@ config ATH79_MACH_TL_WDR6500_V2
>   select ATH79_DEV_USB
>   select ATH79_DEV_WMAC
>
> +config ATH79_MACH_TL_WDR7500_V6
> + bool "TP-LINK TL-WDR7500 v6 board 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_WMAC
> +
>  config ATH79_MACH_TL_WR703N
>   bool "TP-LINK TL-WR703N/TL-WR710N/TL-MR10U support"
>   select SOC_AR933X
> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Makefile
> b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
> index 0975aac..49686ed 100644
> --- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile
> +++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
> @@ -201,6 +201,7 @@ obj-$(CONFIG_ATH79_MACH_TL_WDR3320_V2) +=
> mach-tl-wdr3320-v2.o
>  obj-$(CONFIG_ATH79_MACH_TL_WDR3500) += mach-tl-wdr3500.o
>  obj-$(CONFIG_ATH79_MACH_TL_WDR4300) += mach-tl-wdr4300.o
>  obj-$(CONFIG_ATH79_MACH_TL_WDR6500_V2) += mach-tl-wdr6500-v2.o
> +obj-$(CONFIG_ATH79_MACH_TL_WDR7500_V6) += mach-tl-wdr7500-v6.o
>  obj-$(CONFIG_ATH79_MACH_TL_WPA8630) += mach-tl-wpa8630.o
>  obj-$(CONFIG_ATH79_MACH_TL_WR1041N_V2) += mach-tl-wr1041n-v2.o
>  obj-$(CONFIG_ATH79_MACH_TL_WR1043ND) += mach-tl-wr1043nd.o
> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
> b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
> index 756d406..fb27498 100644
> --- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
> +++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
> @@ -241,6 +241,7 @@ enum ath79_mach_type {
>   ATH79_MACH_TL_WDR4300, /* TP-LINK TL-WDR4300 */
>   ATH79_MACH_TL_WDR4900_V2, /* TP-LINK TL-WDR4900 v2 */
>   ATH79_MACH_TL_WDR6500_V2, /* TP-LINK TL-WDR6500 v2 */
> + ATH79_MACH_TL_WDR7500_V6,               /* TP-LINK TL-WDR7500 v6 */
>   ATH79_MACH_TL_WPA8630, /* TP-Link TL-WPA8630 */
>   ATH79_MACH_TL_WR1041N_V2, /* TP-LINK TL-WR1041N v2 */
>   ATH79_MACH_TL_WR1043ND, /* TP-LINK TL-WR1043ND */
> diff --git a/target/linux/ar71xx/image/generic.mk
> b/target/linux/ar71xx/image/generic.mk
> index 6f5a701..39be043 100644
> --- a/target/linux/ar71xx/image/generic.mk
> +++ b/target/linux/ar71xx/image/generic.mk
> @@ -713,6 +713,23 @@ define Device/tellstick-znet-lite
>  endef
>  TARGET_DEVICES += tellstick-znet-lite
>
> +define Device/tl-wdr7500-v6
> +  DEVICE_TITLE := TP-LINK WDR7500 v6
> +  DEVICE_PACKAGES := kmod-ath10k ath10k-firmware-qca988x
> +  BOARDNAME := TL-WDR7500-V6
> +  IMAGE_SIZE := 7872k
> +  MTDPARTS := spi0.0:192k(u-boot)ro,64k(u-boot-env),7872k(firmware),64k(art)ro
> +endef
> +TARGET_DEVICES += tl-wdr7500-v6
> +
> +define Device/tl-wdr7500-v6-16M
> +  $(Device/tl-wdr7500-v6)
> +  DEVICE_TITLE := TP-LINK WDR7500 v6 16M
> +  IMAGE_SIZE := 16064k
> +  MTDPARTS := spi0.0:192k(u-boot)ro,64k(u-boot-env),16064k(firmware),64k(art)ro
> +endef
> +TARGET_DEVICES += tl-wdr7500-v6-16M
> +
>  define Device/oolite
>    $(Device/tplink-16mlzma)
>    DEVICE_TITLE := Gainstrong OOLITE
> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr7500-v6.c
> b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr7500-v6.c
> new file mode 100644
> index 0000000..8c1c989
> --- /dev/null
> +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr7500-v6.c
> @@ -0,0 +1,112 @@
> +/*
> + * Support for TP-Link TL-WDR7500 v6 board
> + *
> + * Copyright (C) 2017 Karol Bizewski <bizongod@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License version 2 as published
> + * by the Free Software Foundation.
> + */
> +
> +#include <linux/phy.h>
> +#include <linux/gpio.h>
> +#include <linux/ar8216_platform.h>
> +#include <linux/platform_device.h>
> +
> +#include <asm/mach-ath79/ath79.h>
> +#include <asm/mach-ath79/ar71xx_regs.h>
> +
> +#include "common.h"
> +#include "dev-ap9x-pci.h"
> +#include "dev-eth.h"
> +#include "dev-gpio-buttons.h"
> +#include "dev-leds-gpio.h"
> +#include "dev-m25p80.h"
> +#include "dev-usb.h"
> +#include "dev-wmac.h"
> +#include "machtypes.h"
> +
> +#define WDR7500V6_GPIO_LED_SYSTEM       21
> +#define WDR7500V6_GPIO_LED_TURBO        6
> +
> +#define WDR7500V6_GPIO_BTN_RESET        1
> +#define WDR7500V6_GPIO_BTN_TURBO        5
> +
> +#define WDR7500V6_KEYS_POLL_INTERVAL    20
> +#define WDR7500V6_KEYS_DEBOUNCE_INTERVAL        \
> +                (3 * WDR7500V6_KEYS_POLL_INTERVAL)
> +
> +
> +static struct gpio_led wdr7500v6_leds_gpio[] __initdata = {
> +        {
> +                .name           = "wdr7500v6:blue:system",
> +                .gpio           = WDR7500V6_GPIO_LED_SYSTEM,
> +                .active_low     = 1,
> +        },
> +        {
> +                .name           = "wdr7500v6:green:turbo",
> +                .gpio           = WDR7500V6_GPIO_LED_TURBO,
> +                .active_low     = 1,
> +        },
> +};
> +
> +static struct gpio_keys_button wdr7500v6_gpio_keys[] __initdata = {
> +        {
> +                .desc           = "reset",
> +                .type           = EV_KEY,
> +                .code           = KEY_RESTART,
> +                .debounce_interval = WDR7500V6_KEYS_DEBOUNCE_INTERVAL,
> +                .gpio           = WDR7500V6_GPIO_BTN_RESET,
> +                .active_low     = 1,
> +        },
> + {
> + .desc = "turbo",
> + .type = EV_KEY,
> + .debounce_interval = WDR7500V6_KEYS_DEBOUNCE_INTERVAL,
> + .gpio = WDR7500V6_GPIO_BTN_TURBO,
> + .active_low = 1,
> + },
> +};
> +
> +static void __init tl_wdr7500_v6_setup(void)
> +{
> + u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
> +
> + ath79_register_m25p80(NULL);
> +
> + ath79_register_mdio(0, 0x0);
> +
> + /* GMAC0 is connected to RTL8367S switch */
> + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
> + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
> + ath79_eth0_data.speed = SPEED_1000;
> + ath79_eth0_data.duplex = DUPLEX_FULL;
> +
> + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
> + ath79_register_eth(0);
> +
> + ath79_register_wmac(mac + 0x1000, NULL);
> +
> + ap91_pci_init(mac + 0x2000, NULL);
> +
> + ath79_gpio_direction_select(WDR7500V6_GPIO_LED_SYSTEM, true);
> + ath79_gpio_direction_select(WDR7500V6_GPIO_LED_TURBO , true);
> +
> + /* Turn off LEDs on boot */
> + gpio_set_value(WDR7500V6_GPIO_LED_SYSTEM, 1);
> + gpio_set_value(WDR7500V6_GPIO_LED_TURBO , 1);
> +
> + ath79_gpio_output_select(WDR7500V6_GPIO_LED_SYSTEM, 0);
> + ath79_gpio_output_select(WDR7500V6_GPIO_LED_TURBO , 0);
> +
> + ath79_register_gpio_keys_polled(-1, WDR7500V6_KEYS_POLL_INTERVAL,
> + ARRAY_SIZE(wdr7500v6_gpio_keys),
> + wdr7500v6_gpio_keys);
> +
> +        ath79_register_leds_gpio(-1, ARRAY_SIZE(wdr7500v6_leds_gpio),
> +                                 wdr7500v6_leds_gpio);
> +
> +
> +}
> +
> +MIPS_MACHINE(ATH79_MACH_TL_WDR7500_V6, "TL-WDR7500-V6", "TP-LINK
> TL-WDR7500 v6", tl_wdr7500_v6_setup);
>
> _______________________________________________
> Lede-dev mailing list
> Lede-dev@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/lede-dev
Bizon Oct. 31, 2017, 6:22 p.m. UTC | #2
Hi!

2017-10-31 15:43 GMT+01:00 Chuanhong Guo <gch981213@gmail.com>:
> Hello!
>
> 2017-10-31 3:32 GMT+08:00 Bizon <bizongod@gmail.com>:
>> Add support for TP-Link TL-WDR7500 V6.
>>
>> Specifications:
>> - WiSoC: QCA9563 - 3x3 2.4GHz
>> - Radio2: QCA9880 - 3x3 5GHz
>> - RAM: 64MB DDR2
>> - Storage: 8MB NOR SPI flash, can be replaced with 16M
>> - Switch: RTL8367S, now unmanaged
> Do you mean that this device support is incomplete and the network
> switch is currently broken?
> I noticed that there is nothing about this switch in
> mach-tl-wdr7500-v6.c and in board.d/02_network you've placed this
> device with WR703N which has only one ethernet port.

That's correct. Now it works, but is unmanaged.
RTL8367S is very rare and I did not found exacly it in any sources.
Datasheet is also unavailable.
RTL and QCA is connected using single SGMII.

During analysis of device, after disconnecting MDIO between QCA and
RTL I found that without proper initialization switch keeps shutdown.

So using oscillocope I captured transmission on MDIO bus during boot and
analyzed it.

As You can see in:
https://github.com/bizongod/u-boot_wdr7500v6/blob/master/board/atheros/common/athrs17_phy.c
there are substituted functions:
void athrs17_reg_init()
BOOL athrs17_phy_setup(int ethUnit)
int athrs17_phy_is_fdx(int ethUnit)
int athrs17_phy_is_up(int ethUnit)

First one perform data exchange with RTL like original u-boot.
Other three, due to SGMII is used have no more usage, so they
returns const.

RTL needs special frame format, which is constructed using functions:
uint32_t rtl_reg_read(uint32_t reg_addr);
void rtl_reg_write(uint32_t reg_addr, uint32_t reg_val);

What is important, in this way switch is initialized correctly and is usable.
Only VLANs are not set.


After futher research I found, that captured data transmission looks very
similar to those found in sources for RTL8367C.

I think, that most of code for RTL8367C can be adapted for RTL8367S.
Major differences are in SDS settings, but I think that once this is done on
boot, don't need any more changes.

If this patch would take effect I would like to start porting
switch manageability to LEDE.

>> - Ethernet: 5x1G
>> - Misc: 2x button, 2x LED
>>
>> Signed-off-by: Karol Bizewski <bizongod@gmail.com>
>> ---
>>  package/boot/uboot-envtools/files/ar71xx                |  2 ++
>>  target/linux/ar71xx/base-files/etc/board.d/02_network   |  2 ++
>>  target/linux/ar71xx/base-files/etc/diag.sh              |  4 ++++
>>  .../base-files/etc/hotplug.d/firmware/11-ath10k-caldata |  5 +++++
>>  target/linux/ar71xx/base-files/lib/ar71xx.sh            |  6 ++++++
>>  target/linux/ar71xx/config-4.4                          |  1 +
>>  target/linux/ar71xx/config-4.9                          |  1 +
>>  .../linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt  | 10 ++++++++++
>>  target/linux/ar71xx/files/arch/mips/ath79/Makefile      |  1 +
>>  target/linux/ar71xx/files/arch/mips/ath79/machtypes.h   |  1 +
>>  target/linux/ar71xx/image/generic.mk                    | 17 +++++++++++++++++
>>  .../files/arch/mips/ath79/mach-tl-wdr7500-v6.c          | 112
>> +++++++++++++++++++++
>>  12 files changed, 162 insertions(+)
>>  create mode 100644
>> target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr7500-v6.c
>>
>>  diff --git a/package/boot/uboot-envtools/files/ar71xx
>> b/package/boot/uboot-envtools/files/ar71xx
>> index 0bdb6de..789c317 100644
>> --- a/package/boot/uboot-envtools/files/ar71xx
>> +++ b/package/boot/uboot-envtools/files/ar71xx
>> @@ -46,6 +46,8 @@ om5p-acv2|\
>>  om5p-an|\
>>  sr3200|\
>>  tube2h|\
>> +tl-wdr7500-v6|\
>> +tl-wdr7500-v6-16M|\
>>  wndr3700|\
>>  xd3200)
>>   ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
>> 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 d838352..6cdd2fe 100755
>> --- a/target/linux/ar71xx/base-files/etc/board.d/02_network
>> +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
>> @@ -122,6 +122,8 @@ ar71xx_setup_interfaces()
>>   tl-wa901nd-v2|\
>>   tl-wa901nd-v3|\
>>   tl-wa901nd-v4|\
>> + tl-wdr7500-v6|\
>> + tl-wdr7500-v6-16M|\
>>   tl-wr703n|\
>>   tl-wr802n-v1|\
>>   tl-wr802n-v2|\
>> diff --git a/target/linux/ar71xx/base-files/etc/diag.sh
>> b/target/linux/ar71xx/base-files/etc/diag.sh
>> index ade726f..f0ec9e6 100644
>> --- a/target/linux/ar71xx/base-files/etc/diag.sh
>> +++ b/target/linux/ar71xx/base-files/etc/diag.sh
>> @@ -20,6 +20,10 @@ get_status_led() {
>>   all0305)
>>   status_led="eap7660d:green:ds4"
>>   ;;
>> + tl-wdr7500-v6|\
>> + tl-wdr7500-v6-16M)
>> + status_led="$board:blue:system"
>> + ;;
>>   antminer-s1|\
>>   antminer-s3|\
>>   antminer-r1|\
>> 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 85a2a63..bd0cf2e 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
>> @@ -98,6 +98,11 @@ case "$FIRMWARE" in
>>   rb-952ui-5ac2nd)
>>   ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 20480 2116
>>   ;;
>> + tl-wdr7500-v6|\
>> + tl-wdr7500-v6-16M)
>> + ath10kcal_extract "art" 8192 2116
>> + ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +2)
>> + ;;
>>   re450|\
>>   tl-wr902ac-v1)
>>   ath10kcal_extract "art" 20480 2116
>> diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh
>> b/target/linux/ar71xx/base-files/lib/ar71xx.sh
>> index 835ced6..dbf132b 100755
>> --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
>> +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
>> @@ -1109,6 +1109,12 @@ ar71xx_board_detect() {
>>   *"TL-WDR6500 v2")
>>   name="tl-wdr6500-v2"
>>   ;;
>> + *"TL-WDR7500 v6")
>> +                local size="$(mtd_get_part_size 'firmware')"
>> +
>> +                [ "$size" = "8060928" ] && name="tl-wdr7500-v6"
>> +                [ "$size" = "16449536" ] && name="tl-wdr7500-v6-16M"
> Actually you needn't specify two different "name" here as both of them
> apply the same default configuration.

Shall I remove second one?

>> + ;;
>>   *"TL-WPA8630")
>>   name="tl-wpa8630"
>>   ;;
>> diff --git a/target/linux/ar71xx/config-4.4 b/target/linux/ar71xx/config-4.4
>> index 0e77560..32b7fbe 100644
>> --- a/target/linux/ar71xx/config-4.4
>> +++ b/target/linux/ar71xx/config-4.4
>> @@ -196,6 +196,7 @@ CONFIG_ATH79_MACH_TL_WDR3320_V2=y
>>  CONFIG_ATH79_MACH_TL_WDR3500=y
>>  CONFIG_ATH79_MACH_TL_WDR4300=y
>>  CONFIG_ATH79_MACH_TL_WDR6500_V2=y
>> +CONFIG_ATH79_MACH_TL_WDR7500_V6=y
>>  CONFIG_ATH79_MACH_TL_WPA8630=y
>>  CONFIG_ATH79_MACH_TL_WR1041N_V2=y
>>  CONFIG_ATH79_MACH_TL_WR1043ND=y
>> diff --git a/target/linux/ar71xx/config-4.9 b/target/linux/ar71xx/config-4.9
>> index c5b8908..5f74076 100644
>> --- a/target/linux/ar71xx/config-4.9
>> +++ b/target/linux/ar71xx/config-4.9
>> @@ -194,6 +194,7 @@ CONFIG_ATH79_MACH_TL_WDR3320_V2=y
>>  CONFIG_ATH79_MACH_TL_WDR3500=y
>>  CONFIG_ATH79_MACH_TL_WDR4300=y
>>  CONFIG_ATH79_MACH_TL_WDR6500_V2=y
>> +CONFIG_ATH79_MACH_TL_WDR7500_V6=y
>>  CONFIG_ATH79_MACH_TL_WPA8630=y
>>  CONFIG_ATH79_MACH_TL_WR1041N_V2=y
>>  CONFIG_ATH79_MACH_TL_WR1043ND=y
>> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
>> b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
>> index 454aee6..c6e75db 100644
>> --- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
>> +++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
>> @@ -1613,6 +1613,16 @@ config ATH79_MACH_TL_WDR6500_V2
>>   select ATH79_DEV_USB
>>   select ATH79_DEV_WMAC
>>
>> +config ATH79_MACH_TL_WDR7500_V6
>> + bool "TP-LINK TL-WDR7500 v6 board 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_WMAC
>> +
>>  config ATH79_MACH_TL_WR703N
>>   bool "TP-LINK TL-WR703N/TL-WR710N/TL-MR10U support"
>>   select SOC_AR933X
>> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Makefile
>> b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
>> index 0975aac..49686ed 100644
>> --- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile
>> +++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
>> @@ -201,6 +201,7 @@ obj-$(CONFIG_ATH79_MACH_TL_WDR3320_V2) +=
>> mach-tl-wdr3320-v2.o
>>  obj-$(CONFIG_ATH79_MACH_TL_WDR3500) += mach-tl-wdr3500.o
>>  obj-$(CONFIG_ATH79_MACH_TL_WDR4300) += mach-tl-wdr4300.o
>>  obj-$(CONFIG_ATH79_MACH_TL_WDR6500_V2) += mach-tl-wdr6500-v2.o
>> +obj-$(CONFIG_ATH79_MACH_TL_WDR7500_V6) += mach-tl-wdr7500-v6.o
>>  obj-$(CONFIG_ATH79_MACH_TL_WPA8630) += mach-tl-wpa8630.o
>>  obj-$(CONFIG_ATH79_MACH_TL_WR1041N_V2) += mach-tl-wr1041n-v2.o
>>  obj-$(CONFIG_ATH79_MACH_TL_WR1043ND) += mach-tl-wr1043nd.o
>> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
>> b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
>> index 756d406..fb27498 100644
>> --- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
>> +++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
>> @@ -241,6 +241,7 @@ enum ath79_mach_type {
>>   ATH79_MACH_TL_WDR4300, /* TP-LINK TL-WDR4300 */
>>   ATH79_MACH_TL_WDR4900_V2, /* TP-LINK TL-WDR4900 v2 */
>>   ATH79_MACH_TL_WDR6500_V2, /* TP-LINK TL-WDR6500 v2 */
>> + ATH79_MACH_TL_WDR7500_V6,               /* TP-LINK TL-WDR7500 v6 */
>>   ATH79_MACH_TL_WPA8630, /* TP-Link TL-WPA8630 */
>>   ATH79_MACH_TL_WR1041N_V2, /* TP-LINK TL-WR1041N v2 */
>>   ATH79_MACH_TL_WR1043ND, /* TP-LINK TL-WR1043ND */
>> diff --git a/target/linux/ar71xx/image/generic.mk
>> b/target/linux/ar71xx/image/generic.mk
>> index 6f5a701..39be043 100644
>> --- a/target/linux/ar71xx/image/generic.mk
>> +++ b/target/linux/ar71xx/image/generic.mk
>> @@ -713,6 +713,23 @@ define Device/tellstick-znet-lite
>>  endef
>>  TARGET_DEVICES += tellstick-znet-lite
>>
>> +define Device/tl-wdr7500-v6
>> +  DEVICE_TITLE := TP-LINK WDR7500 v6
>> +  DEVICE_PACKAGES := kmod-ath10k ath10k-firmware-qca988x
>> +  BOARDNAME := TL-WDR7500-V6
>> +  IMAGE_SIZE := 7872k
>> +  MTDPARTS := spi0.0:192k(u-boot)ro,64k(u-boot-env),7872k(firmware),64k(art)ro
>> +endef
>> +TARGET_DEVICES += tl-wdr7500-v6
>> +
>> +define Device/tl-wdr7500-v6-16M
>> +  $(Device/tl-wdr7500-v6)
>> +  DEVICE_TITLE := TP-LINK WDR7500 v6 16M
>> +  IMAGE_SIZE := 16064k
>> +  MTDPARTS := spi0.0:192k(u-boot)ro,64k(u-boot-env),16064k(firmware),64k(art)ro
>> +endef
>> +TARGET_DEVICES += tl-wdr7500-v6-16M
>> +
>>  define Device/oolite
>>    $(Device/tplink-16mlzma)
>>    DEVICE_TITLE := Gainstrong OOLITE
>> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr7500-v6.c
>> b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr7500-v6.c
>> new file mode 100644
>> index 0000000..8c1c989
>> --- /dev/null
>> +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr7500-v6.c
>> @@ -0,0 +1,112 @@
>> +/*
>> + * Support for TP-Link TL-WDR7500 v6 board
>> + *
>> + * Copyright (C) 2017 Karol Bizewski <bizongod@gmail.com>
>> + *
>> + * This program is free software; you can redistribute it and/or modify it
>> + * under the terms of the GNU General Public License version 2 as published
>> + * by the Free Software Foundation.
>> + */
>> +
>> +#include <linux/phy.h>
>> +#include <linux/gpio.h>
>> +#include <linux/ar8216_platform.h>
>> +#include <linux/platform_device.h>
>> +
>> +#include <asm/mach-ath79/ath79.h>
>> +#include <asm/mach-ath79/ar71xx_regs.h>
>> +
>> +#include "common.h"
>> +#include "dev-ap9x-pci.h"
>> +#include "dev-eth.h"
>> +#include "dev-gpio-buttons.h"
>> +#include "dev-leds-gpio.h"
>> +#include "dev-m25p80.h"
>> +#include "dev-usb.h"
>> +#include "dev-wmac.h"
>> +#include "machtypes.h"
>> +
>> +#define WDR7500V6_GPIO_LED_SYSTEM       21
>> +#define WDR7500V6_GPIO_LED_TURBO        6
>> +
>> +#define WDR7500V6_GPIO_BTN_RESET        1
>> +#define WDR7500V6_GPIO_BTN_TURBO        5
>> +
>> +#define WDR7500V6_KEYS_POLL_INTERVAL    20
>> +#define WDR7500V6_KEYS_DEBOUNCE_INTERVAL        \
>> +                (3 * WDR7500V6_KEYS_POLL_INTERVAL)
>> +
>> +
>> +static struct gpio_led wdr7500v6_leds_gpio[] __initdata = {
>> +        {
>> +                .name           = "wdr7500v6:blue:system",
>> +                .gpio           = WDR7500V6_GPIO_LED_SYSTEM,
>> +                .active_low     = 1,
>> +        },
>> +        {
>> +                .name           = "wdr7500v6:green:turbo",
>> +                .gpio           = WDR7500V6_GPIO_LED_TURBO,
>> +                .active_low     = 1,
>> +        },
>> +};
>> +
>> +static struct gpio_keys_button wdr7500v6_gpio_keys[] __initdata = {
>> +        {
>> +                .desc           = "reset",
>> +                .type           = EV_KEY,
>> +                .code           = KEY_RESTART,
>> +                .debounce_interval = WDR7500V6_KEYS_DEBOUNCE_INTERVAL,
>> +                .gpio           = WDR7500V6_GPIO_BTN_RESET,
>> +                .active_low     = 1,
>> +        },
>> + {
>> + .desc = "turbo",
>> + .type = EV_KEY,
>> + .debounce_interval = WDR7500V6_KEYS_DEBOUNCE_INTERVAL,
>> + .gpio = WDR7500V6_GPIO_BTN_TURBO,
>> + .active_low = 1,
>> + },
>> +};
>> +
>> +static void __init tl_wdr7500_v6_setup(void)
>> +{
>> + u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
>> +
>> + ath79_register_m25p80(NULL);
>> +
>> + ath79_register_mdio(0, 0x0);
>> +
>> + /* GMAC0 is connected to RTL8367S switch */
>> + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
>> + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
>> + ath79_eth0_data.speed = SPEED_1000;
>> + ath79_eth0_data.duplex = DUPLEX_FULL;
>> +
>> + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
>> + ath79_register_eth(0);
>> +
>> + ath79_register_wmac(mac + 0x1000, NULL);
>> +
>> + ap91_pci_init(mac + 0x2000, NULL);
>> +
>> + ath79_gpio_direction_select(WDR7500V6_GPIO_LED_SYSTEM, true);
>> + ath79_gpio_direction_select(WDR7500V6_GPIO_LED_TURBO , true);
>> +
>> + /* Turn off LEDs on boot */
>> + gpio_set_value(WDR7500V6_GPIO_LED_SYSTEM, 1);
>> + gpio_set_value(WDR7500V6_GPIO_LED_TURBO , 1);
>> +
>> + ath79_gpio_output_select(WDR7500V6_GPIO_LED_SYSTEM, 0);
>> + ath79_gpio_output_select(WDR7500V6_GPIO_LED_TURBO , 0);
>> +
>> + ath79_register_gpio_keys_polled(-1, WDR7500V6_KEYS_POLL_INTERVAL,
>> + ARRAY_SIZE(wdr7500v6_gpio_keys),
>> + wdr7500v6_gpio_keys);
>> +
>> +        ath79_register_leds_gpio(-1, ARRAY_SIZE(wdr7500v6_leds_gpio),
>> +                                 wdr7500v6_leds_gpio);
>> +
>> +
>> +}
>> +
>> +MIPS_MACHINE(ATH79_MACH_TL_WDR7500_V6, "TL-WDR7500-V6", "TP-LINK
>> TL-WDR7500 v6", tl_wdr7500_v6_setup);
>>
>> _______________________________________________
>> Lede-dev mailing list
>> Lede-dev@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/lede-dev
Piotr Dymacz Nov. 5, 2017, 10:22 p.m. UTC | #3
Hello Karol,

Thank you for your patch but it seems that it got whitespace mangled and 
tabs were replaced with spaces. Please, send v2 using git send-email.

Also, please see my comments inline, below.

On 30.10.2017 20:32, Bizon wrote:
> Add support for TP-Link TL-WDR7500 V6.
> 
> Specifications:
> - WiSoC: QCA9563 - 3x3 2.4GHz
> - Radio2: QCA9880 - 3x3 5GHz
> - RAM: 64MB DDR2
> - Storage: 8MB NOR SPI flash, can be replaced with 16M
> - Switch: RTL8367S, now unmanaged
> - Ethernet: 5x1G
> - Misc: 2x button, 2x LED

Please, include in commit message how to install LEDE on this device as 
described under "commit description" section on [1].

> 
> Signed-off-by: Karol Bizewski <bizongod@gmail.com>
> ---
>   package/boot/uboot-envtools/files/ar71xx                |  2 ++
>   target/linux/ar71xx/base-files/etc/board.d/02_network   |  2 ++
>   target/linux/ar71xx/base-files/etc/diag.sh              |  4 ++++
>   .../base-files/etc/hotplug.d/firmware/11-ath10k-caldata |  5 +++++
>   target/linux/ar71xx/base-files/lib/ar71xx.sh            |  6 ++++++
>   target/linux/ar71xx/config-4.4                          |  1 +
>   target/linux/ar71xx/config-4.9                          |  1 +
>   .../linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt  | 10 ++++++++++
>   target/linux/ar71xx/files/arch/mips/ath79/Makefile      |  1 +
>   target/linux/ar71xx/files/arch/mips/ath79/machtypes.h   |  1 +
>   target/linux/ar71xx/image/generic.mk                    | 17 +++++++++++++++++
>   .../files/arch/mips/ath79/mach-tl-wdr7500-v6.c          | 112
> +++++++++++++++++++++
>   12 files changed, 162 insertions(+)
>   create mode 100644
> target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr7500-v6.c
> 
>   diff --git a/package/boot/uboot-envtools/files/ar71xx
> b/package/boot/uboot-envtools/files/ar71xx
> index 0bdb6de..789c317 100644
> --- a/package/boot/uboot-envtools/files/ar71xx
> +++ b/package/boot/uboot-envtools/files/ar71xx
> @@ -46,6 +46,8 @@ om5p-acv2|\
>   om5p-an|\
>   sr3200|\
>   tube2h|\
> +tl-wdr7500-v6|\
> +tl-wdr7500-v6-16M|\

Please, drop this "tl-wdr7500-v6-16M" thing. As far as I understand, 
this is only your custom hardware modification and the default/factory 
version comes with just 8 MB of FLASH.

And I really don't think this device has a writable U-Boot environment 
in a separate sector. Please, provide some explanation.

>   wndr3700|\
>   xd3200)
>    ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
> 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 d838352..6cdd2fe 100755
> --- a/target/linux/ar71xx/base-files/etc/board.d/02_network
> +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
> @@ -122,6 +122,8 @@ ar71xx_setup_interfaces()
>    tl-wa901nd-v2|\
>    tl-wa901nd-v3|\
>    tl-wa901nd-v4|\
> + tl-wdr7500-v6|\
> + tl-wdr7500-v6-16M|\
>    tl-wr703n|\
>    tl-wr802n-v1|\
>    tl-wr802n-v2|\
> diff --git a/target/linux/ar71xx/base-files/etc/diag.sh
> b/target/linux/ar71xx/base-files/etc/diag.sh
> index ade726f..f0ec9e6 100644
> --- a/target/linux/ar71xx/base-files/etc/diag.sh
> +++ b/target/linux/ar71xx/base-files/etc/diag.sh
> @@ -20,6 +20,10 @@ get_status_led() {
>    all0305)
>    status_led="eap7660d:green:ds4"
>    ;;
> + tl-wdr7500-v6|\
> + tl-wdr7500-v6-16M)
> + status_led="$board:blue:system"
> + ;;
>    antminer-s1|\
>    antminer-s3|\
>    antminer-r1|\
> 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 85a2a63..bd0cf2e 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
> @@ -98,6 +98,11 @@ case "$FIRMWARE" in
>    rb-952ui-5ac2nd)
>    ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 20480 2116
>    ;;
> + tl-wdr7500-v6|\
> + tl-wdr7500-v6-16M)
> + ath10kcal_extract "art" 8192 2116
> + ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +2)
> + ;;
>    re450|\
>    tl-wr902ac-v1)
>    ath10kcal_extract "art" 20480 2116
> diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh
> b/target/linux/ar71xx/base-files/lib/ar71xx.sh
> index 835ced6..dbf132b 100755
> --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
> +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
> @@ -1109,6 +1109,12 @@ ar71xx_board_detect() {
>    *"TL-WDR6500 v2")
>    name="tl-wdr6500-v2"
>    ;;
> + *"TL-WDR7500 v6")
> +                local size="$(mtd_get_part_size 'firmware')"
> +
> +                [ "$size" = "8060928" ] && name="tl-wdr7500-v6"
> +                [ "$size" = "16449536" ] && name="tl-wdr7500-v6-16M"

As above.
Please don't include support for custom modified hardware.

[snip]

> diff --git a/target/linux/ar71xx/image/generic.mk
> b/target/linux/ar71xx/image/generic.mk
> index 6f5a701..39be043 100644
> --- a/target/linux/ar71xx/image/generic.mk
> +++ b/target/linux/ar71xx/image/generic.mk
> @@ -713,6 +713,23 @@ define Device/tellstick-znet-lite
>   endef
>   TARGET_DEVICES += tellstick-znet-lite
> 
> +define Device/tl-wdr7500-v6
> +  DEVICE_TITLE := TP-LINK WDR7500 v6
> +  DEVICE_PACKAGES := kmod-ath10k ath10k-firmware-qca988x
> +  BOARDNAME := TL-WDR7500-V6
> +  IMAGE_SIZE := 7872k
> +  MTDPARTS := spi0.0:192k(u-boot)ro,64k(u-boot-env),7872k(firmware),64k(art)ro

This is definitely not a correct mtd organization for this device.
Based on bootlogs found on OpenWrt forum [2], it should look more or 
less like:

[    0.290000] 0x000000000000-0x00000001d800 : "factory_boot"
[    0.310000] 0x00000001d800-0x00000001e000 : "factory_info"
[    0.310000] 0x00000001e000-0x000000020000 : "art"
[    0.320000] 0x000000020000-0x000000030000 : "config"
[    0.330000] 0x000000030000-0x000000040000 : "normal_boot"
[    0.330000] 0x000000040000-0x00000014027c : "kernel"
[    0.350000] 0x00000014027c-0x0000006b0000 : "rootfs"
[    0.380000] 0x0000006b0000-0x000000800000 : "rootfs_data"
[    0.380000] 0x000000040000-0x000000800000 : "firmware"

> +endef
> +TARGET_DEVICES += tl-wdr7500-v6

We have a separate place for TP-Link devices, please use 
image/tp-link.mk file instead.

[snip]

[1] https://lede-project.org/submitting-patches
[2] https://forum.openwrt.org/viewtopic.php?pid=358852#p358852
Bizon Nov. 6, 2017, 5:58 p.m. UTC | #4
Hi Piotr,

 Thank You for comments.

Before sending v2 patch lets clarify all doubts.

2017-11-05 23:22 GMT+01:00 Piotr Dymacz <pepe2k@gmail.com>:
> Hello Karol,
>
> Thank you for your patch but it seems that it got whitespace mangled and
> tabs were replaced with spaces. Please, send v2 using git send-email.
>
> Also, please see my comments inline, below.
>
> On 30.10.2017 20:32, Bizon wrote:
>>
>> Add support for TP-Link TL-WDR7500 V6.
>>
>> Specifications:
>> - WiSoC: QCA9563 - 3x3 2.4GHz
>> - Radio2: QCA9880 - 3x3 5GHz
>> - RAM: 64MB DDR2
>> - Storage: 8MB NOR SPI flash, can be replaced with 16M
>> - Switch: RTL8367S, now unmanaged
>> - Ethernet: 5x1G
>> - Misc: 2x button, 2x LED
>
>
> Please, include in commit message how to install LEDE on this device as
> described under "commit description" section on [1].

Ok, will prepare manual how to change bootloader to non-RSA one, move art and
install LEDE.

>
>>
>> Signed-off-by: Karol Bizewski <bizongod@gmail.com>
>> ---
>>   package/boot/uboot-envtools/files/ar71xx                |  2 ++
>>   target/linux/ar71xx/base-files/etc/board.d/02_network   |  2 ++
>>   target/linux/ar71xx/base-files/etc/diag.sh              |  4 ++++
>>   .../base-files/etc/hotplug.d/firmware/11-ath10k-caldata |  5 +++++
>>   target/linux/ar71xx/base-files/lib/ar71xx.sh            |  6 ++++++
>>   target/linux/ar71xx/config-4.4                          |  1 +
>>   target/linux/ar71xx/config-4.9                          |  1 +
>>   .../linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt  | 10 ++++++++++
>>   target/linux/ar71xx/files/arch/mips/ath79/Makefile      |  1 +
>>   target/linux/ar71xx/files/arch/mips/ath79/machtypes.h   |  1 +
>>   target/linux/ar71xx/image/generic.mk                    | 17
>> +++++++++++++++++
>>   .../files/arch/mips/ath79/mach-tl-wdr7500-v6.c          | 112
>> +++++++++++++++++++++
>>   12 files changed, 162 insertions(+)
>>   create mode 100644
>> target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr7500-v6.c
>>
>>   diff --git a/package/boot/uboot-envtools/files/ar71xx
>> b/package/boot/uboot-envtools/files/ar71xx
>> index 0bdb6de..789c317 100644
>> --- a/package/boot/uboot-envtools/files/ar71xx
>> +++ b/package/boot/uboot-envtools/files/ar71xx
>> @@ -46,6 +46,8 @@ om5p-acv2|\
>>   om5p-an|\
>>   sr3200|\
>>   tube2h|\
>> +tl-wdr7500-v6|\
>> +tl-wdr7500-v6-16M|\
>
>
> Please, drop this "tl-wdr7500-v6-16M" thing. As far as I understand, this is
> only your custom hardware modification and the default/factory version comes
> with just 8 MB of FLASH.

Ok. 16MB flash is hw mod.

>
> And I really don't think this device has a writable U-Boot environment in a
> separate sector. Please, provide some explanation.

Original bootloader checks RSA for second bootloader and system.
To install LEDE I chose to replace bootloader instead of using any
workarounds (if even exists).

Working bootloader is available at:
https://github.com/bizongod/u-boot_wdr7500v6
It is based on u-boot from TL-WDR1043v4 plus initializing routines for
switch and other usable mods. It has also writable env.

With changing bootloader I decided also that's good opportunity to move
art to better address, that's end of flash.

>
>
>>   wndr3700|\
>>   xd3200)
>>    ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
>> 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 d838352..6cdd2fe 100755
>> --- a/target/linux/ar71xx/base-files/etc/board.d/02_network
>> +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
>> @@ -122,6 +122,8 @@ ar71xx_setup_interfaces()
>>    tl-wa901nd-v2|\
>>    tl-wa901nd-v3|\
>>    tl-wa901nd-v4|\
>> + tl-wdr7500-v6|\
>> + tl-wdr7500-v6-16M|\
>>    tl-wr703n|\
>>    tl-wr802n-v1|\
>>    tl-wr802n-v2|\
>> diff --git a/target/linux/ar71xx/base-files/etc/diag.sh
>> b/target/linux/ar71xx/base-files/etc/diag.sh
>> index ade726f..f0ec9e6 100644
>> --- a/target/linux/ar71xx/base-files/etc/diag.sh
>> +++ b/target/linux/ar71xx/base-files/etc/diag.sh
>> @@ -20,6 +20,10 @@ get_status_led() {
>>    all0305)
>>    status_led="eap7660d:green:ds4"
>>    ;;
>> + tl-wdr7500-v6|\
>> + tl-wdr7500-v6-16M)
>> + status_led="$board:blue:system"
>> + ;;
>>    antminer-s1|\
>>    antminer-s3|\
>>    antminer-r1|\
>> 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 85a2a63..bd0cf2e 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
>> @@ -98,6 +98,11 @@ case "$FIRMWARE" in
>>    rb-952ui-5ac2nd)
>>    ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 20480 2116
>>    ;;
>> + tl-wdr7500-v6|\
>> + tl-wdr7500-v6-16M)
>> + ath10kcal_extract "art" 8192 2116
>> + ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +2)
>> + ;;
>>    re450|\
>>    tl-wr902ac-v1)
>>    ath10kcal_extract "art" 20480 2116
>> diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh
>> b/target/linux/ar71xx/base-files/lib/ar71xx.sh
>> index 835ced6..dbf132b 100755
>> --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
>> +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
>> @@ -1109,6 +1109,12 @@ ar71xx_board_detect() {
>>    *"TL-WDR6500 v2")
>>    name="tl-wdr6500-v2"
>>    ;;
>> + *"TL-WDR7500 v6")
>> +                local size="$(mtd_get_part_size 'firmware')"
>> +
>> +                [ "$size" = "8060928" ] && name="tl-wdr7500-v6"
>> +                [ "$size" = "16449536" ] && name="tl-wdr7500-v6-16M"
>
>
> As above.
> Please don't include support for custom modified hardware.
>
> [snip]
>
>> diff --git a/target/linux/ar71xx/image/generic.mk
>> b/target/linux/ar71xx/image/generic.mk
>> index 6f5a701..39be043 100644
>> --- a/target/linux/ar71xx/image/generic.mk
>> +++ b/target/linux/ar71xx/image/generic.mk
>> @@ -713,6 +713,23 @@ define Device/tellstick-znet-lite
>>   endef
>>   TARGET_DEVICES += tellstick-znet-lite
>>
>> +define Device/tl-wdr7500-v6
>> +  DEVICE_TITLE := TP-LINK WDR7500 v6
>> +  DEVICE_PACKAGES := kmod-ath10k ath10k-firmware-qca988x
>> +  BOARDNAME := TL-WDR7500-V6
>> +  IMAGE_SIZE := 7872k
>> +  MTDPARTS :=
>> spi0.0:192k(u-boot)ro,64k(u-boot-env),7872k(firmware),64k(art)ro
>
>
> This is definitely not a correct mtd organization for this device.
> Based on bootlogs found on OpenWrt forum [2], it should look more or less
> like:
>
> [    0.290000] 0x000000000000-0x00000001d800 : "factory_boot"
> [    0.310000] 0x00000001d800-0x00000001e000 : "factory_info"
> [    0.310000] 0x00000001e000-0x000000020000 : "art"
> [    0.320000] 0x000000020000-0x000000030000 : "config"
> [    0.330000] 0x000000030000-0x000000040000 : "normal_boot"
> [    0.330000] 0x000000040000-0x00000014027c : "kernel"
> [    0.350000] 0x00000014027c-0x0000006b0000 : "rootfs"
> [    0.380000] 0x0000006b0000-0x000000800000 : "rootfs_data"
> [    0.380000] 0x000000040000-0x000000800000 : "firmware"
>

As above.

>> +endef
>> +TARGET_DEVICES += tl-wdr7500-v6
>
>
> We have a separate place for TP-Link devices, please use image/tp-link.mk
> file instead.

As I saw, image/tp-link.mk is used because of specific tp-link image header etc,
what in case of replaced bootloader, which accepts normal header, don't make
sense any more.
Is this correct?

>
> [snip]
>
> [1] https://lede-project.org/submitting-patches
> [2] https://forum.openwrt.org/viewtopic.php?pid=358852#p358852
>
> --
> Cheers,
> Piotr

Best regards,
Karol
Piotr Dymacz Nov. 29, 2017, 7:03 p.m. UTC | #5
Hello Karol,

Sorry for a late reply.

On 06.11.2017 18:58, Bizon wrote:
> Hi Piotr,
> 
>   Thank You for comments.
> 
> Before sending v2 patch lets clarify all doubts.
> 
> 2017-11-05 23:22 GMT+01:00 Piotr Dymacz <pepe2k@gmail.com>:
>> Hello Karol,
>>
>> Thank you for your patch but it seems that it got whitespace mangled and
>> tabs were replaced with spaces. Please, send v2 using git send-email.
>>
>> Also, please see my comments inline, below.
>>
>> On 30.10.2017 20:32, Bizon wrote:
>>>
>>> Add support for TP-Link TL-WDR7500 V6.
>>>
>>> Specifications:
>>> - WiSoC: QCA9563 - 3x3 2.4GHz
>>> - Radio2: QCA9880 - 3x3 5GHz
>>> - RAM: 64MB DDR2
>>> - Storage: 8MB NOR SPI flash, can be replaced with 16M
>>> - Switch: RTL8367S, now unmanaged
>>> - Ethernet: 5x1G
>>> - Misc: 2x button, 2x LED
>>
>>
>> Please, include in commit message how to install LEDE on this device as
>> described under "commit description" section on [1].
> 
> Ok, will prepare manual how to change bootloader to non-RSA one, move art and
> install LEDE.

I'm sorry but I'm against accepting support for devices which requires 
such invasive modifications. We always try to make it possible for users 
to get back to the stock firmware which wouldn't be easy (or possible at 
all) with your changes in mtd layout and after bootloader swap.
Bill Moffitt Nov. 29, 2017, 7:17 p.m. UTC | #6
Hello Piotr and Karol,


On 11/29/2017 11:03 AM, Piotr Dymacz wrote:
> Hello Karol,
>
> Sorry for a late reply.
>
> On 06.11.2017 18:58, Bizon wrote:
>> Hi Piotr,
>>
>>   Thank You for comments.
>>
>> Before sending v2 patch lets clarify all doubts.
>>
>> 2017-11-05 23:22 GMT+01:00 Piotr Dymacz <pepe2k@gmail.com>:
>>> Hello Karol,
>>>
>>> Thank you for your patch but it seems that it got whitespace mangled 
>>> and
>>> tabs were replaced with spaces. Please, send v2 using git send-email.
>>>
>>> Also, please see my comments inline, below.
>>>
>>> On 30.10.2017 20:32, Bizon wrote:
>>>>
>>>> Add support for TP-Link TL-WDR7500 V6.
>>>>
>>>> Specifications:
>>>> - WiSoC: QCA9563 - 3x3 2.4GHz
>>>> - Radio2: QCA9880 - 3x3 5GHz
>>>> - RAM: 64MB DDR2
>>>> - Storage: 8MB NOR SPI flash, can be replaced with 16M
>>>> - Switch: RTL8367S, now unmanaged
>>>> - Ethernet: 5x1G
>>>> - Misc: 2x button, 2x LED
>>>
>>>
>>> Please, include in commit message how to install LEDE on this device as
>>> described under "commit description" section on [1].
>>
>> Ok, will prepare manual how to change bootloader to non-RSA one, move 
>> art and
>> install LEDE.
>
> I'm sorry but I'm against accepting support for devices which requires 
> such invasive modifications. We always try to make it possible for 
> users to get back to the stock firmware which wouldn't be easy (or 
> possible at all) with your changes in mtd layout and after bootloader 
> swap.
>
In general, of course, I agree. However, we are seeing an increasing 
number of vendors (TP-Link and Ubiquiti, to name 2) using some form of 
locking in the bootloader to prevent loading of third-party firmware. 
The only option for loading OpenWRT (permanently - not using initramfs) 
on these devices will be replacing the bootloader, as Karol does in this 
patch.

If the only objection is that it involves invasive modifications that 
may not (probably won't) allow the device to be re-flashed to stock, I 
would prefer we accept the patch and make a very strongly-worded note in 
the ToH and the device's wiki page explaining the situation.

FWIW,

Bill
Piotr Dymacz Nov. 29, 2017, 8:03 p.m. UTC | #7
Hello Bill,

On 29.11.2017 20:17, Bill Moffitt wrote:
> Hello Piotr and Karol,

[snip]

>>>> Please, include in commit message how to install LEDE on this device as
>>>> described under "commit description" section on [1].
>>>
>>> Ok, will prepare manual how to change bootloader to non-RSA one, move 
>>> art and
>>> install LEDE.
>>
>> I'm sorry but I'm against accepting support for devices which requires 
>> such invasive modifications. We always try to make it possible for 
>> users to get back to the stock firmware which wouldn't be easy (or 
>> possible at all) with your changes in mtd layout and after bootloader 
>> swap.
>>
> In general, of course, I agree. However, we are seeing an increasing
> number of vendors (TP-Link and Ubiquiti, to name 2) using some form of
> locking in the bootloader to prevent loading of third-party firmware.

Then buy and use hardware from vendors who are open source friendly and 
allow users to actually fully own the hardware they paid for! :)

> The only option for loading OpenWRT (permanently - not using initramfs)
> on these devices will be replacing the bootloader, as Karol does in this
> patch.

Swapping bootloader isn't the only issue I see here. Moving ART which is 
essential and unique per device might end up in a data loss which cannot 
be recovered in any way.

> If the only objection is that it involves invasive modifications that
> may not (probably won't) allow the device to be re-flashed to stock, I
> would prefer we accept the patch and make a very strongly-worded note in
> the ToH and the device's wiki page explaining the situation.

This is not the only one objection. Personally I don't have problems 
with swapping bootloader and for ar71xx target we already have a 
dedicated package with old U-Boot sources: [1]

The problem here is that the bootloader the user has to use for this 
device comes from some random GitHub repository which exist today but 
may disappear tomorrow. Who will make sure that the bootloader image the 
author of the support mentions in his patch will be still available in 
next years and is correct and won't break users device?
If the bootloader code was in our repository or in upstream, I would be 
first one accepting support for this device.

What's also important to notice here, devices with QCA WiSoCs and SPI 
NOR flash chips aren't easy to recover from a failed bootloader flash. 
If there is no JTAG on the board the only way to bring device back to 
life is to use flash chip programmer.

[1] 
https://github.com/lede-project/source/tree/master/package/boot/uboot-ar71xx
Bill Moffitt Nov. 30, 2017, 9:06 p.m. UTC | #8
Piotr-

Good points all...


On 11/29/2017 12:03 PM, Piotr Dymacz wrote:
> Hello Bill,
>
> On 29.11.2017 20:17, Bill Moffitt wrote:
>> Hello Piotr and Karol,
>
> [snip]
>
>>>>> Please, include in commit message how to install LEDE on this 
>>>>> device as
>>>>> described under "commit description" section on [1].
>>>>
>>>> Ok, will prepare manual how to change bootloader to non-RSA one, 
>>>> move art and
>>>> install LEDE.
>>>
>>> I'm sorry but I'm against accepting support for devices which 
>>> requires such invasive modifications. We always try to make it 
>>> possible for users to get back to the stock firmware which wouldn't 
>>> be easy (or possible at all) with your changes in mtd layout and 
>>> after bootloader swap.
>>>
>> In general, of course, I agree. However, we are seeing an increasing
>> number of vendors (TP-Link and Ubiquiti, to name 2) using some form of
>> locking in the bootloader to prevent loading of third-party firmware.
>
> Then buy and use hardware from vendors who are open source friendly 
> and allow users to actually fully own the hardware they paid for! :)
Hey, THERE'S a good idea!!! Suggestions??? :-D (especially for outdoors 
- that's why I'm working with the Comfast devices...)
>
>> The only option for loading OpenWRT (permanently - not using initramfs)
>> on these devices will be replacing the bootloader, as Karol does in this
>> patch.
>
> Swapping bootloader isn't the only issue I see here. Moving ART which 
> is essential and unique per device might end up in a data loss which 
> cannot be recovered in any way.
Yes, that's true. But the only other option is not use the hardware.
>
>> If the only objection is that it involves invasive modifications that
>> may not (probably won't) allow the device to be re-flashed to stock, I
>> would prefer we accept the patch and make a very strongly-worded note in
>> the ToH and the device's wiki page explaining the situation.
>
> This is not the only one objection. Personally I don't have problems 
> with swapping bootloader and for ar71xx target we already have a 
> dedicated package with old U-Boot sources: [1]
>
> The problem here is that the bootloader the user has to use for this 
> device comes from some random GitHub repository which exist today but 
> may disappear tomorrow. Who will make sure that the bootloader image 
> the author of the support mentions in his patch will be still 
> available in next years and is correct and won't break users device?
> If the bootloader code was in our repository or in upstream, I would 
> be first one accepting support for this device.
Good point.
>
> What's also important to notice here, devices with QCA WiSoCs and SPI 
> NOR flash chips aren't easy to recover from a failed bootloader flash. 
> If there is no JTAG on the board the only way to bring device back to 
> life is to use flash chip programmer.
Very good point.
>
> [1] 
> https://github.com/lede-project/source/tree/master/package/boot/uboot-ar71xx
>
But I'd still rather endorse a notation in the ToH and the wiki than 
just prevent the patch from being accepted.

Everything in OpenWRT is pretty much "use at your own risk." Could we 
make a distinction between "Use at your own risk - might cause problems 
that will be hard to get around" and "Use at your own risk - you have a 
pretty good chance of bricking this thing?" Or, put another way, instead 
of just saying "supported" could we have platforms that are "Supported 
and easy" to "Supported, but, hey, this thing is ugly and will hurt you 
if you're not careful?"

We should do everything we can to reduce the risk of a repo going away, 
etc., but I'd endorse using some sketchy sources if necessary to gain 
support of a particular device.

It is good and necessary to look out for the naive beginner (as we all 
were at one time). But, at the same time, there is value in supporting 
the wisened and experienced user who can go to some extra effort and 
undertake some risk for a particular purpose.

That's how I feel about it. As always, FWIW.

-Bill
Mathias Kresin Dec. 1, 2017, 8:13 a.m. UTC | #9
30.11.2017 22:06, Bill Moffitt:
> On 11/29/2017 12:03 PM, Piotr Dymacz wrote:
>> On 29.11.2017 20:17, Bill Moffitt wrote:
>> Swapping bootloader isn't the only issue I see here. Moving ART which 
>> is essential and unique per device might end up in a data loss which 
>> cannot be recovered in any way.
> Yes, that's true. But the only other option is not use the hardware.

Not using the hardware is a valid option and so far no veto from any 
other dev.

> But I'd still rather endorse a notation in the ToH and the wiki than 
> just prevent the patch from being accepted.

Forget about it! People don't read. Instead we will be flooded on all 
public and private (!) channels with request for help similar to:

  - how to install LEDE on the board
  - where to get the custom bootloader
  - i bricked my board help! help!

> It is good and necessary to look out for the naive beginner (as we all 
> were at one time). But, at the same time, there is value in supporting 
> the wisened and experienced user who can go to some extra effort and 
> undertake some risk for a particular purpose.

Well, your patch can be now found by $searchengine and anyone how is 
brave enough, can add support for this board to a local clone.

I'm perfect fine with the decision made by Piotr. If it is to hard to 
get LEDE installed on a board/to error prone, we do not necessarily need 
to add support for this board to a target with > 100 already supported 
boards of all kinds.

Mathias
Bill Moffitt Dec. 4, 2017, 5:24 a.m. UTC | #10
Mathias-

Good points all. I don't think I have anything to add.


On 12/01/2017 12:13 AM, Mathias Kresin wrote:
> 30.11.2017 22:06, Bill Moffitt:
>> On 11/29/2017 12:03 PM, Piotr Dymacz wrote:
>>> On 29.11.2017 20:17, Bill Moffitt wrote:
>>> Swapping bootloader isn't the only issue I see here. Moving ART 
>>> which is essential and unique per device might end up in a data loss 
>>> which cannot be recovered in any way.
>> Yes, that's true. But the only other option is not use the hardware.
>
> Not using the hardware is a valid option and so far no veto from any 
> other dev.
>
>> But I'd still rather endorse a notation in the ToH and the wiki than 
>> just prevent the patch from being accepted.
>
> Forget about it! People don't read. Instead we will be flooded on all 
> public and private (!) channels with request for help similar to:
>
>  - how to install LEDE on the board
>  - where to get the custom bootloader
>  - i bricked my board help! help!
>
>> It is good and necessary to look out for the naive beginner (as we 
>> all were at one time). But, at the same time, there is value in 
>> supporting the wisened and experienced user who can go to some extra 
>> effort and undertake some risk for a particular purpose.
>
> Well, your patch can be now found by $searchengine and anyone how is 
> brave enough, can add support for this board to a local clone.
>
> I'm perfect fine with the decision made by Piotr. If it is to hard to 
> get LEDE installed on a board/to error prone, we do not necessarily 
> need to add support for this board to a target with > 100 already 
> supported boards of all kinds.
>
> Mathias
>
> _______________________________________________
> Lede-dev mailing list
> Lede-dev@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/lede-dev
Thanks,

Bill
Piotr Dymacz Dec. 12, 2017, 7:49 p.m. UTC | #11
Hello Bill,

On 30.11.2017 22:06, Bill Moffitt wrote:
> Piotr-
> 
> Good points all...

[snip]

>>> In general, of course, I agree. However, we are seeing an increasing
>>> number of vendors (TP-Link and Ubiquiti, to name 2) using some form of
>>> locking in the bootloader to prevent loading of third-party firmware.
>>
>> Then buy and use hardware from vendors who are open source friendly 
>> and allow users to actually fully own the hardware they paid for! :)
> Hey, THERE'S a good idea!!! Suggestions??? :-D (especially for outdoors
> - that's why I'm working with the Comfast devices...)

There are great people working on the Wiki and table of hardware [1]. 
The ToH is now mostly driven by information included in commits which 
add support for new devices. You can also ask on the forum [2] for 
hardware suggestions.

>>> The only option for loading OpenWRT (permanently - not using initramfs)
>>> on these devices will be replacing the bootloader, as Karol does in this
>>> patch.
>>
>> Swapping bootloader isn't the only issue I see here. Moving ART which 
>> is essential and unique per device might end up in a data loss which 
>> cannot be recovered in any way.
> Yes, that's true. But the only other option is not use the hardware.

I wouldn't be surprised if there is some other way but people usually 
prefer "make it working and forget" approach (I follow it very often, too).

[snip]

> But I'd still rather endorse a notation in the ToH and the wiki than
> just prevent the patch from being accepted.

I think it's always up to the person who takes care (and spends time 
reviewing, merging and then maintaining related code in future) about 
the patch/PR as we don't have any strictly defined rule/s about what 
device/platform can be accepted.

If someone else feels that this patch should be included, I won't argue 
- I have already pointed out what's in my opinion wrong with it.

> Everything in OpenWRT is pretty much "use at your own risk." Could we
> make a distinction between "Use at your own risk - might cause problems
> that will be hard to get around" and "Use at your own risk - you have a
> pretty good chance of bricking this thing?" Or, put another way, instead
> of just saying "supported" could we have platforms that are "Supported
> and easy" to "Supported, but, hey, this thing is ugly and will hurt you
> if you're not careful?"

I hope some day in future OpenWrt/LEDE will have all the code required 
to support every platform from top to bottom, including bootloader/s, 
radio firmware, JTAG configs, etc. But we are not there yet.

FWIW, there is an ongoing work on making Barebox bootloader support MIPS 
based QCA WiSoCs [3] and a PR with packaging it is under review: [4].

> We should do everything we can to reduce the risk of a repo going away,
> etc., but I'd endorse using some sketchy sources if necessary to gain
> support of a particular device.

I think it's always a trade off and every single person would have 
different opinion here.

> It is good and necessary to look out for the naive beginner (as we all
> were at one time). But, at the same time, there is value in supporting
> the wisened and experienced user who can go to some extra effort and
> undertake some risk for a particular purpose.

As Mathias wrote, the patch was sent to a public mailing list and now 
any [experienced] user can take it and make use of it... assuming that 
(s)he would magically find out where to get, compile and write the 
custom bootloader. The patch doesn't include any clue about that.

> That's how I feel about it. As always, FWIW.

Thanks, I appreciate every valuable comment!

[1] https://lede-project.org/toh/start

[2] https://forum.lede-project.org/

[3] https://git.pengutronix.de/cgit/barebox/log/?qt=grep&q=ath79

[4] https://github.com/lede-project/source/pull/1556
Bill Moffitt Dec. 13, 2017, 7:14 p.m. UTC | #12
Piotr-

Thank you for your time and energy in helping me understand the issues.

First, I strongly agree with your comment about "I think it's always up 
to the person who takes care" of the PRs, etc - it is, and should be, 
entirely your call! I cannot do and do not want the job!!! :-D

Second, Mathias's point "any [experienced] user can take it and make use 
of it" is also very well-taken.

Together, I think these more than adequately answer my concerns - I 
certainly have no objections.

Thank you again,

Bill


On 12/12/2017 11:49 AM, Piotr Dymacz wrote:
> Hello Bill,
>
> On 30.11.2017 22:06, Bill Moffitt wrote:
>> Piotr-
>>
>> Good points all...
>
> [snip]
>
>>>> In general, of course, I agree. However, we are seeing an increasing
>>>> number of vendors (TP-Link and Ubiquiti, to name 2) using some form of
>>>> locking in the bootloader to prevent loading of third-party firmware.
>>>
>>> Then buy and use hardware from vendors who are open source friendly 
>>> and allow users to actually fully own the hardware they paid for! :)
>> Hey, THERE'S a good idea!!! Suggestions??? :-D (especially for outdoors
>> - that's why I'm working with the Comfast devices...)
>
> There are great people working on the Wiki and table of hardware [1]. 
> The ToH is now mostly driven by information included in commits which 
> add support for new devices. You can also ask on the forum [2] for 
> hardware suggestions.
>
>>>> The only option for loading OpenWRT (permanently - not using 
>>>> initramfs)
>>>> on these devices will be replacing the bootloader, as Karol does in 
>>>> this
>>>> patch.
>>>
>>> Swapping bootloader isn't the only issue I see here. Moving ART 
>>> which is essential and unique per device might end up in a data loss 
>>> which cannot be recovered in any way.
>> Yes, that's true. But the only other option is not use the hardware.
>
> I wouldn't be surprised if there is some other way but people usually 
> prefer "make it working and forget" approach (I follow it very often, 
> too).
>
> [snip]
>
>> But I'd still rather endorse a notation in the ToH and the wiki than
>> just prevent the patch from being accepted.
>
> I think it's always up to the person who takes care (and spends time 
> reviewing, merging and then maintaining related code in future) about 
> the patch/PR as we don't have any strictly defined rule/s about what 
> device/platform can be accepted.
>
> If someone else feels that this patch should be included, I won't 
> argue - I have already pointed out what's in my opinion wrong with it.
>
>> Everything in OpenWRT is pretty much "use at your own risk." Could we
>> make a distinction between "Use at your own risk - might cause problems
>> that will be hard to get around" and "Use at your own risk - you have a
>> pretty good chance of bricking this thing?" Or, put another way, instead
>> of just saying "supported" could we have platforms that are "Supported
>> and easy" to "Supported, but, hey, this thing is ugly and will hurt you
>> if you're not careful?"
>
> I hope some day in future OpenWrt/LEDE will have all the code required 
> to support every platform from top to bottom, including bootloader/s, 
> radio firmware, JTAG configs, etc. But we are not there yet.
>
> FWIW, there is an ongoing work on making Barebox bootloader support 
> MIPS based QCA WiSoCs [3] and a PR with packaging it is under review: 
> [4].
>
>> We should do everything we can to reduce the risk of a repo going away,
>> etc., but I'd endorse using some sketchy sources if necessary to gain
>> support of a particular device.
>
> I think it's always a trade off and every single person would have 
> different opinion here.
>
>> It is good and necessary to look out for the naive beginner (as we all
>> were at one time). But, at the same time, there is value in supporting
>> the wisened and experienced user who can go to some extra effort and
>> undertake some risk for a particular purpose.
>
> As Mathias wrote, the patch was sent to a public mailing list and now 
> any [experienced] user can take it and make use of it... assuming that 
> (s)he would magically find out where to get, compile and write the 
> custom bootloader. The patch doesn't include any clue about that.
>
>> That's how I feel about it. As always, FWIW.
>
> Thanks, I appreciate every valuable comment!
>
> [1] https://lede-project.org/toh/start
>
> [2] https://forum.lede-project.org/
>
> [3] https://git.pengutronix.de/cgit/barebox/log/?qt=grep&q=ath79
>
> [4] https://github.com/lede-project/source/pull/1556
>
diff mbox series

Patch

--- a/package/boot/uboot-envtools/files/ar71xx
+++ b/package/boot/uboot-envtools/files/ar71xx
@@ -46,6 +46,8 @@  om5p-acv2|\
 om5p-an|\
 sr3200|\
 tube2h|\
+tl-wdr7500-v6|\
+tl-wdr7500-v6-16M|\
 wndr3700|\
 xd3200)
  ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
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 d838352..6cdd2fe 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/02_network
+++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
@@ -122,6 +122,8 @@  ar71xx_setup_interfaces()
  tl-wa901nd-v2|\
  tl-wa901nd-v3|\
  tl-wa901nd-v4|\
+ tl-wdr7500-v6|\
+ tl-wdr7500-v6-16M|\
  tl-wr703n|\
  tl-wr802n-v1|\
  tl-wr802n-v2|\
diff --git a/target/linux/ar71xx/base-files/etc/diag.sh
b/target/linux/ar71xx/base-files/etc/diag.sh
index ade726f..f0ec9e6 100644
--- a/target/linux/ar71xx/base-files/etc/diag.sh
+++ b/target/linux/ar71xx/base-files/etc/diag.sh
@@ -20,6 +20,10 @@  get_status_led() {
  all0305)
  status_led="eap7660d:green:ds4"
  ;;
+ tl-wdr7500-v6|\
+ tl-wdr7500-v6-16M)
+ status_led="$board:blue:system"
+ ;;
  antminer-s1|\
  antminer-s3|\
  antminer-r1|\
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 85a2a63..bd0cf2e 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
@@ -98,6 +98,11 @@  case "$FIRMWARE" in
  rb-952ui-5ac2nd)
  ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 20480 2116
  ;;
+ tl-wdr7500-v6|\
+ tl-wdr7500-v6-16M)
+ ath10kcal_extract "art" 8192 2116
+ ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +2)
+ ;;
  re450|\
  tl-wr902ac-v1)
  ath10kcal_extract "art" 20480 2116
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh
b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index 835ced6..dbf132b 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -1109,6 +1109,12 @@  ar71xx_board_detect() {
  *"TL-WDR6500 v2")
  name="tl-wdr6500-v2"
  ;;
+ *"TL-WDR7500 v6")
+                local size="$(mtd_get_part_size 'firmware')"
+
+                [ "$size" = "8060928" ] && name="tl-wdr7500-v6"
+                [ "$size" = "16449536" ] && name="tl-wdr7500-v6-16M"
+ ;;
  *"TL-WPA8630")
  name="tl-wpa8630"
  ;;
diff --git a/target/linux/ar71xx/config-4.4 b/target/linux/ar71xx/config-4.4
index 0e77560..32b7fbe 100644
--- a/target/linux/ar71xx/config-4.4
+++ b/target/linux/ar71xx/config-4.4
@@ -196,6 +196,7 @@  CONFIG_ATH79_MACH_TL_WDR3320_V2=y
 CONFIG_ATH79_MACH_TL_WDR3500=y
 CONFIG_ATH79_MACH_TL_WDR4300=y
 CONFIG_ATH79_MACH_TL_WDR6500_V2=y
+CONFIG_ATH79_MACH_TL_WDR7500_V6=y
 CONFIG_ATH79_MACH_TL_WPA8630=y
 CONFIG_ATH79_MACH_TL_WR1041N_V2=y
 CONFIG_ATH79_MACH_TL_WR1043ND=y
diff --git a/target/linux/ar71xx/config-4.9 b/target/linux/ar71xx/config-4.9
index c5b8908..5f74076 100644
--- a/target/linux/ar71xx/config-4.9
+++ b/target/linux/ar71xx/config-4.9
@@ -194,6 +194,7 @@  CONFIG_ATH79_MACH_TL_WDR3320_V2=y
 CONFIG_ATH79_MACH_TL_WDR3500=y
 CONFIG_ATH79_MACH_TL_WDR4300=y
 CONFIG_ATH79_MACH_TL_WDR6500_V2=y
+CONFIG_ATH79_MACH_TL_WDR7500_V6=y
 CONFIG_ATH79_MACH_TL_WPA8630=y
 CONFIG_ATH79_MACH_TL_WR1041N_V2=y
 CONFIG_ATH79_MACH_TL_WR1043ND=y
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
index 454aee6..c6e75db 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
@@ -1613,6 +1613,16 @@  config ATH79_MACH_TL_WDR6500_V2
  select ATH79_DEV_USB
  select ATH79_DEV_WMAC

+config ATH79_MACH_TL_WDR7500_V6
+ bool "TP-LINK TL-WDR7500 v6 board 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_WMAC
+
 config ATH79_MACH_TL_WR703N
  bool "TP-LINK TL-WR703N/TL-WR710N/TL-MR10U support"
  select SOC_AR933X
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Makefile
b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
index 0975aac..49686ed 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
@@ -201,6 +201,7 @@  obj-$(CONFIG_ATH79_MACH_TL_WDR3320_V2) +=
mach-tl-wdr3320-v2.o
 obj-$(CONFIG_ATH79_MACH_TL_WDR3500) += mach-tl-wdr3500.o
 obj-$(CONFIG_ATH79_MACH_TL_WDR4300) += mach-tl-wdr4300.o
 obj-$(CONFIG_ATH79_MACH_TL_WDR6500_V2) += mach-tl-wdr6500-v2.o
+obj-$(CONFIG_ATH79_MACH_TL_WDR7500_V6) += mach-tl-wdr7500-v6.o
 obj-$(CONFIG_ATH79_MACH_TL_WPA8630) += mach-tl-wpa8630.o
 obj-$(CONFIG_ATH79_MACH_TL_WR1041N_V2) += mach-tl-wr1041n-v2.o
 obj-$(CONFIG_ATH79_MACH_TL_WR1043ND) += mach-tl-wr1043nd.o
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
index 756d406..fb27498 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
+++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
@@ -241,6 +241,7 @@  enum ath79_mach_type {
  ATH79_MACH_TL_WDR4300, /* TP-LINK TL-WDR4300 */
  ATH79_MACH_TL_WDR4900_V2, /* TP-LINK TL-WDR4900 v2 */
  ATH79_MACH_TL_WDR6500_V2, /* TP-LINK TL-WDR6500 v2 */
+ ATH79_MACH_TL_WDR7500_V6,               /* TP-LINK TL-WDR7500 v6 */
  ATH79_MACH_TL_WPA8630, /* TP-Link TL-WPA8630 */
  ATH79_MACH_TL_WR1041N_V2, /* TP-LINK TL-WR1041N v2 */
  ATH79_MACH_TL_WR1043ND, /* TP-LINK TL-WR1043ND */
diff --git a/target/linux/ar71xx/image/generic.mk
b/target/linux/ar71xx/image/generic.mk
index 6f5a701..39be043 100644
--- a/target/linux/ar71xx/image/generic.mk
+++ b/target/linux/ar71xx/image/generic.mk
@@ -713,6 +713,23 @@  define Device/tellstick-znet-lite
 endef
 TARGET_DEVICES += tellstick-znet-lite

+define Device/tl-wdr7500-v6
+  DEVICE_TITLE := TP-LINK WDR7500 v6
+  DEVICE_PACKAGES := kmod-ath10k ath10k-firmware-qca988x
+  BOARDNAME := TL-WDR7500-V6
+  IMAGE_SIZE := 7872k
+  MTDPARTS := spi0.0:192k(u-boot)ro,64k(u-boot-env),7872k(firmware),64k(art)ro
+endef
+TARGET_DEVICES += tl-wdr7500-v6
+
+define Device/tl-wdr7500-v6-16M
+  $(Device/tl-wdr7500-v6)
+  DEVICE_TITLE := TP-LINK WDR7500 v6 16M
+  IMAGE_SIZE := 16064k
+  MTDPARTS := spi0.0:192k(u-boot)ro,64k(u-boot-env),16064k(firmware),64k(art)ro
+endef
+TARGET_DEVICES += tl-wdr7500-v6-16M
+
 define Device/oolite
   $(Device/tplink-16mlzma)
   DEVICE_TITLE := Gainstrong OOLITE
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr7500-v6.c
b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr7500-v6.c
new file mode 100644
index 0000000..8c1c989
--- /dev/null
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr7500-v6.c
@@ -0,0 +1,112 @@ 
+/*
+ * Support for TP-Link TL-WDR7500 v6 board
+ *
+ * Copyright (C) 2017 Karol Bizewski <bizongod@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include <linux/phy.h>
+#include <linux/gpio.h>
+#include <linux/ar8216_platform.h>
+#include <linux/platform_device.h>
+
+#include <asm/mach-ath79/ath79.h>
+#include <asm/mach-ath79/ar71xx_regs.h>
+
+#include "common.h"
+#include "dev-ap9x-pci.h"
+#include "dev-eth.h"
+#include "dev-gpio-buttons.h"
+#include "dev-leds-gpio.h"
+#include "dev-m25p80.h"
+#include "dev-usb.h"
+#include "dev-wmac.h"
+#include "machtypes.h"
+
+#define WDR7500V6_GPIO_LED_SYSTEM       21
+#define WDR7500V6_GPIO_LED_TURBO        6
+
+#define WDR7500V6_GPIO_BTN_RESET        1
+#define WDR7500V6_GPIO_BTN_TURBO        5
+
+#define WDR7500V6_KEYS_POLL_INTERVAL    20
+#define WDR7500V6_KEYS_DEBOUNCE_INTERVAL        \
+                (3 * WDR7500V6_KEYS_POLL_INTERVAL)
+
+
+static struct gpio_led wdr7500v6_leds_gpio[] __initdata = {
+        {
+                .name           = "wdr7500v6:blue:system",
+                .gpio           = WDR7500V6_GPIO_LED_SYSTEM,
+                .active_low     = 1,
+        },
+        {
+                .name           = "wdr7500v6:green:turbo",
+                .gpio           = WDR7500V6_GPIO_LED_TURBO,
+                .active_low     = 1,
+        },
+};
+
+static struct gpio_keys_button wdr7500v6_gpio_keys[] __initdata = {
+        {
+                .desc           = "reset",
+                .type           = EV_KEY,
+                .code           = KEY_RESTART,
+                .debounce_interval = WDR7500V6_KEYS_DEBOUNCE_INTERVAL,
+                .gpio           = WDR7500V6_GPIO_BTN_RESET,
+                .active_low     = 1,
+        },
+ {
+ .desc = "turbo",
+ .type = EV_KEY,
+ .debounce_interval = WDR7500V6_KEYS_DEBOUNCE_INTERVAL,
+ .gpio = WDR7500V6_GPIO_BTN_TURBO,
+ .active_low = 1,
+ },
+};
+
+static void __init tl_wdr7500_v6_setup(void)
+{
+ u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
+
+ ath79_register_m25p80(NULL);
+
+ ath79_register_mdio(0, 0x0);
+
+ /* GMAC0 is connected to RTL8367S switch */
+ ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
+ ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
+ ath79_eth0_data.speed = SPEED_1000;
+ ath79_eth0_data.duplex = DUPLEX_FULL;
+
+ ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
+ ath79_register_eth(0);
+
+ ath79_register_wmac(mac + 0x1000, NULL);
+
+ ap91_pci_init(mac + 0x2000, NULL);
+
+ ath79_gpio_direction_select(WDR7500V6_GPIO_LED_SYSTEM, true);
+ ath79_gpio_direction_select(WDR7500V6_GPIO_LED_TURBO , true);
+
+ /* Turn off LEDs on boot */
+ gpio_set_value(WDR7500V6_GPIO_LED_SYSTEM, 1);
+ gpio_set_value(WDR7500V6_GPIO_LED_TURBO , 1);
+
+ ath79_gpio_output_select(WDR7500V6_GPIO_LED_SYSTEM, 0);
+ ath79_gpio_output_select(WDR7500V6_GPIO_LED_TURBO , 0);
+
+ ath79_register_gpio_keys_polled(-1, WDR7500V6_KEYS_POLL_INTERVAL,
+ ARRAY_SIZE(wdr7500v6_gpio_keys),
+ wdr7500v6_gpio_keys);
+
+        ath79_register_leds_gpio(-1, ARRAY_SIZE(wdr7500v6_leds_gpio),
+                                 wdr7500v6_leds_gpio);
+
+
+}
+
+MIPS_MACHINE(ATH79_MACH_TL_WDR7500_V6, "TL-WDR7500-V6", "TP-LINK