ramips: add support for TP-Link Archer C20 v1

TP-Link Archer C20 v1 is a router with 5-port FE switch and
non-detachable antennas. It's very similiar to TP-Link Archer C50.
Also it's based on MediaTek MT7620A+MT7610EN.

Specification:
- MediaTek MT7620A (580 Mhz)
- 64 MB of RAM
- 8 MB of FLASH
- 2T2R 2.4 GHz and 1T1R 5 GHz
- 5x 10/100 Mbps Ethernet
- 2x external, non-detachable antennas
- UART (J1) header on PCB (115200 8n1)
- 8x LED (GPIO-controlled*), 2x button, power input switch
- 1 x USB 2.0 port

* WAN LED in this devices is a dual-color, dual-leads type which isn't
  (fully) supported by gpio-leds driver. This type of LED requires both
  GPIOs state change at the same time to select color or turn it off.
  For now, we support/use only the blue part of the LED.
* MT7610EN ac chip isn't not supported by LEDE. Therefore 5Ghz won't
  work.

Factory image notes:

These devices use version 3 of TP-Link header, fortunately without RSA
signature (at least in case of devices sold in Europe). The difference
lays in the requirement for a non-zero value in "Additional Hardware
Version" field. Ideally, it should match the value stored in vendor
firmware header on device.

We are able to prepare factory firwmare file which is accepted and
(almost) correctly flashed from the vendor GUI. As it turned out, it
accepts files without U-Boot image with second header at the beginning
but due to some kind of bug in upgrade routine, flashed image gets
corrupted before it's written to flash. So, to flash this device we must
to prepare image using original firmware from tp-link site with uboot.

Flash instruction:

Until (if at all) TP-Link fixes described problem, the only way to flash
LEDE image in these devices is to use tftp recovery mode in U-Boot.
There are two ways to flash the device to LEDE:

1) Using tftp mode with UART connection and original LEDE image

 - Place lede-ramips-mt7620-ArcherC20-squashfs-factory.bin in tftp
   server directory
 - Configure PC with static IP 192.168.0.66/24 and tftp server.
 - Connect PC with one of LAN ports, power up the router and press
   key "4" to access U-Boot CLI.
 - Use the following commands to update the device to LEDE:

    setenv serverip 192.168.0.66
    tftp 0x80060000 lede-ramips-mt7620-ArcherC20-squashfs-factory.bin
    erase tplink 0x20000 0x7a0000
    cp.b 0x80060000 0x20000 0x7a0000
    reset

 - After that the device will reboot and boot to LEDE

2) Using tftp mode without UART connection but require some
   manipulations with target image

 - Download and unpack TP-Link Archer C20 v1 firmware from original web
   site
 - Split uboot.bin from original firmware by this command (example):

    dd if=Archer_C20v1_0.9.1_4.0_up_boot(160427)_2016-04-27_13.53.59.bin of=uboot.bin bs=512 count=256 skip=1

 - Create ArcherC20V1_tp_recovery.bin using this command:

    cat uboot.bin lede-ramips-mt7620-ArcherC20-squashfs-factory.bin > ArcherC20V1_tp_recovery.bin

 - Place ArcherC20V1_tp_recovery.bin in tftp server directory.
 - Configure PC with static IP 192.168.0.66/24 and tftp server.
 - Connect PC with one of LAN ports, press the reset button, power up
   the router and keep button pressed for around 6-7 seconds, until
   device starts downloading the file.
 - Router will download file from server, write it to flash and reboot.

Signed-off-by: Maxim Anisimov <maxim.anisimov.ua@gmail.com>
This commit is contained in:
Maxim Anisimov 2017-09-08 12:39:17 +03:00 committed by Mathias Kresin
parent eff3549c58
commit 161a3be5ad
8 changed files with 220 additions and 0 deletions

View file

@ -86,6 +86,12 @@ c108)
ucidef_set_led_netdev "lan" "lan" "$board:green:lan" "eth0"
ucidef_set_led_netdev "modem" "modem" "$board:green:modem" "wwan0"
;;
c20)
ucidef_set_led_switch "lan" "lan" "$board:blue:lan" "switch0" "0x1e"
ucidef_set_led_switch "wan" "wan" "$board:blue:wan" "switch0" "0x01"
set_usb_led "$board:blue:usb"
ucidef_set_led_netdev "wlan2g" "wlan2g" "$board:blue:wlan2g" "wlan0"
;;
c20i)
ucidef_set_led_switch "lan" "lan" "$board:blue:lan" "switch0" "0x1e"
ucidef_set_led_switch "wan" "wan" "$board:blue:wan" "switch0" "0x01"

View file

@ -184,6 +184,7 @@ ramips_setup_interfaces()
ucidef_add_switch "switch0" \
"1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0"
;;
c20|\
c50)
ucidef_add_switch "switch0" \
"1:lan:3" "2:lan:4" "3:lan:1" "4:lan:2" "0:wan" "6@eth0"

View file

@ -119,6 +119,7 @@ get_status_led() {
w502u)
status_led="$board:blue:wps"
;;
c20|\
d240|\
dap-1350|\
na930|\

View file

@ -88,6 +88,9 @@ ramips_board_detect() {
*"C108")
name="c108"
;;
*"C20")
name="c20"
;;
*"C20i")
name="c20i"
;;

View file

@ -230,6 +230,7 @@ platform_check_image() {
}
return 0
;;
c20|\
c20i|\
c50|\
mr200|\

View file

@ -0,0 +1,189 @@
/dts-v1/;
#include "mt7620a.dtsi"
#include <dt-bindings/input/input.h>
#include <dt-bindings/gpio/gpio.h>
/ {
compatible = "tplink,c20", "ralink,mt7620a-soc";
model = "TP-Link Archer C20";
chosen {
bootargs = "console=ttyS0,115200";
};
gpio-leds {
compatible = "gpio-leds";
lan {
label = "c20:blue:lan";
gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
};
power {
label = "c20:blue:power";
gpios = <&gpio0 7 GPIO_ACTIVE_LOW>;
};
usb {
label = "c20:blue:usb";
gpios = <&gpio2 4 GPIO_ACTIVE_LOW>;
};
wan {
label = "c20:blue:wan";
gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>;
};
wan_orange {
label = "c20:orange:wan";
gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>;
};
wlan5g {
label = "c20:blue:wlan5g";
gpios = <&gpio0 17 GPIO_ACTIVE_LOW>;
};
wlan2g {
label = "c20:blue:wlan2g";
gpios = <&gpio3 0 GPIO_ACTIVE_LOW>;
};
wps {
label = "c20:blue:wps";
gpios = <&gpio1 15 GPIO_ACTIVE_LOW>;
};
};
gpio-keys-polled {
compatible = "gpio-keys-polled";
#address-cells = <1>;
#size-cells = <0>;
poll-interval = <20>;
reset {
label = "reset";
gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
};
rfkill {
label = "rfkill";
gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RFKILL>;
}; };
};
&gpio1 {
status = "okay";
};
&gpio2 {
status = "okay";
};
&gpio3 {
status = "okay";
};
&spi0 {
status = "okay";
m25p80@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <10000000>;
partition@0 {
label = "u-boot";
reg = <0x0 0x20000>;
read-only;
};
partition@20000 {
label = "firmware";
reg = <0x20000 0x7a0000>;
};
partition@7c0000 {
label = "config";
reg = <0x7c0000 0x10000>;
read-only;
};
rom: partition@7d0000 {
label = "rom";
reg = <0x7d0000 0x10000>;
read-only;
};
partition@7e0000 {
label = "romfile";
reg = <0x7e0000 0x10000>;
read-only;
};
radio: partition@7f0000 {
label = "radio";
reg = <0x7f0000 0x10000>;
read-only;
};
};
};
&pinctrl {
state_default: pinctrl0 {
gpio {
ralink,group = "i2c", "uartf", "wled", "ephy", "spi refclk", "wdt";
ralink,function = "gpio";
};
pa {
ralink,group = "pa";
ralink,function = "pa";
};
};
};
&ethernet {
pinctrl-names = "default";
mtd-mac-address = <&rom 0xf100>;
mediatek,portmap = "wllll";
};
&ehci {
status = "okay";
};
&ohci {
status = "okay";
};
&gsw {
mediatek,port4 = "ephy";
};
&wmac {
ralink,mtd-eeprom = <&radio 0>;
mtd-mac-address = <&rom 0xf100>;
mtd-mac-address-increment = <(-2)>;
};
&pcie {
status = "okay";
pcie-bridge {
mt76@0,0 {
reg = <0x0000 0 0 0 0>;
device_type = "pci";
mediatek,mtd-eeprom = <&radio 32768>;
ieee80211-freq-limit = <5000000 6000000>;
mtd-mac-address = <&rom 0xf100>;
mtd-mac-address-increment = <(-1)>;
};
};
};

View file

@ -32,6 +32,17 @@ define Device/Archer
IMAGE/sysupgrade.bin := tplink-v2-image -s | append-metadata
endef
define Device/ArcherC20
$(Device/Archer)
DTS := ArcherC20
SUPPORTED_DEVICES := c20
TPLINK_BOARD_ID := ArcherC20
IMAGES += factory.bin
DEVICE_TITLE := TP-Link ArcherC20
DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-ledtrig-usbport
endef
TARGET_DEVICES += ArcherC20
define Device/ArcherC20i
$(Device/Archer)
DTS := ArcherC20i

View file

@ -180,6 +180,14 @@ static struct board_info boards[] = {
.hw_id = 0x89800001,
.hw_rev = 14,
.layout_id = "8Mltq",
}, {
.id = "ArcherC20",
.hw_id = 0xc2000001,
.hw_rev = 0x44,
.hw_ver_add = 0x1,
.layout_id = "8Mmtk",
.hdr_ver = 3,
.flags = FLAG_LE_KERNEL_LA_EP
}, {
.id = "ArcherC20i",
.hw_id = 0xc2000001,