Skip to content

Instantly share code, notes, and snippets.

@teslamint
Last active February 28, 2017 08:59
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teslamint/6eebe10b99244410acb7 to your computer and use it in GitHub Desktop.
Save teslamint/6eebe10b99244410acb7 to your computer and use it in GitHub Desktop.
OpenWrt patch to add support TP-LINK Archer C2(0) router board (WIP, UNTESTED)
From 898b8af1fdc9cace5bfe55ded60f9574d41f3516 Mon Sep 17 00:00:00 2001
From: Jaehoon You <teslamint@gmail.com>
Date: Sat, 29 Aug 2015 11:09:19 +0900
Subject: [PATCH] ramips: add support for TP-LINK Archer C2, C20i board
---
.../linux/ramips/base-files/etc/board.d/02_network | 1 +
target/linux/ramips/base-files/lib/ramips.sh | 9 ++
.../ramips/base-files/lib/upgrade/platform.sh | 2 +
target/linux/ramips/dts/ArcherC2.dts | 125 +++++++++++++++++++++
target/linux/ramips/dts/ArcherC20.dts | 119 ++++++++++++++++++++
target/linux/ramips/image/Makefile | 4 +
target/linux/ramips/mt7620/config-4.3 | 3 +
target/linux/ramips/mt7620/profiles/tp-link.mk | 43 +++++++
tools/firmware-utils/src/mktplinkfw2.c | 14 +++
9 files changed, 320 insertions(+)
create mode 100644 target/linux/ramips/dts/ArcherC2.dts
create mode 100644 target/linux/ramips/dts/ArcherC20.dts
create mode 100644 target/linux/ramips/mt7620/profiles/tp-link.mk
diff --git a/target/linux/ramips/base-files/etc/board.d/02_network b/target/linux/ramips/base-files/etc/board.d/02_network
index 0121e51..0a3147b 100755
--- a/target/linux/ramips/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/base-files/etc/board.d/02_network
@@ -109,6 +109,7 @@ ramips_setup_interfaces()
atp-52b|\
awm002-evb|\
awm003-evb|\
+ c2 | \
dir-645|\
dir-860l-b1|\
f5d8235-v1|\
diff --git a/target/linux/ramips/base-files/lib/ramips.sh b/target/linux/ramips/base-files/lib/ramips.sh
index c6c32fe..b292b89 100755
--- a/target/linux/ramips/base-files/lib/ramips.sh
+++ b/target/linux/ramips/base-files/lib/ramips.sh
@@ -52,6 +52,15 @@ ramips_board_detect() {
*"AR725W")
name="ar725w"
;;
+ *"Archer C2")
+ name="c2"
+ ;;
+ *"Archer C20")
+ name="c20"
+ ;;
+ *"Archer C20i")
+ name="c20i"
+ ;;
*"ASL26555")
name="asl26555"
;;
diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh b/target/linux/ramips/base-files/lib/upgrade/platform.sh
index 5575b4c..836dc6c 100755
--- a/target/linux/ramips/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh
@@ -162,6 +162,8 @@ platform_check_image() {
}
return 0
;;
+ c2|\
+ c20|\
c20i)
[ "$magic" != "03000000" ] && {
echo "Invalid image type."
diff --git a/target/linux/ramips/dts/ArcherC2.dts b/target/linux/ramips/dts/ArcherC2.dts
new file mode 100644
index 0000000..0acfd51
--- /dev/null
+++ b/target/linux/ramips/dts/ArcherC2.dts
@@ -0,0 +1,125 @@
+/dts-v1/;
+
+/include/ "mt7620a.dtsi"
+
+/ {
+ compatible = "ralink,mt7620a-soc";
+ model = "TP-Link Archer C2";
+
+ chosen {
+ bootargs = "console=ttyS0,115200";
+ };
+
+ palmbus@10000000 {
+ gpio2: gpio@660 {
+ status = "okay";
+ };
+
+ spi@b00 {
+ status = "okay";
+
+ m25p80@0 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "s25fl064k";
+ reg = <0 0>;
+ linux,modalias = "m25p80", "mx25l6405d";
+ 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>;
+ };
+
+ rom: partition@7d0000 {
+ label = "rom";
+ reg = <0x7d0000 0x10000>;
+ };
+
+ partition@7e0000 {
+ label = "romfile";
+ reg = <0x7e0000 0x10000>;
+ };
+
+ radio: partition@7f0000 {
+ label = "radio";
+ reg = <0x7f0000 0x10000>;
+ };
+ };
+ };
+ };
+
+ pinctrl {
+ state_default: pinctrl0 {
+ gpio {
+ ralink,group = "i2c", "uartf", "rgmii1", "rgmii2", "wled", "nd_sd";
+ ralink,function = "gpio";
+ };
+ };
+ };
+
+ ethernet@10100000 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&ephy_pins>;
+
+ mtd-mac-address = <&rom 0xf100>;
+ ralink,port-map = "wllll";
+ };
+
+ rtl8367b {
+ compatible = "rtl8367b";
+ gpio-sda = <&gpio0 1 0>;
+ gpio-sck = <&gpio0 2 0>;
+ };
+
+ ehci@101c0000 {
+ status = "okay";
+ };
+
+ ohci@101c1000 {
+ status = "okay";
+ };
+
+ gsw@10110000 {
+ ralink,port4 = "ephy";
+ };
+
+ wmac@10180000 {
+ ralink,mtd-eeprom = <&radio 0>;
+ };
+
+ pcie@10140000 {
+ status = "okay";
+
+ pcie-bridge {
+ mt76@0,0 {
+ reg = <0x0000 0 0 0 0>;
+ device_type = "pci";
+ mediatek,mtd-eeprom = <&radio 32768>;
+ mediatek,2ghz = <0>;
+ };
+ };
+ };
+
+ gpio-leds {
+ compatible = "gpio-leds";
+ };
+
+ gpio-keys-polled {
+ compatible = "gpio-keys-polled";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ poll-interval = <20>;
+ };
+};
diff --git a/target/linux/ramips/dts/ArcherC20.dts b/target/linux/ramips/dts/ArcherC20.dts
new file mode 100644
index 0000000..aef60cc
--- /dev/null
+++ b/target/linux/ramips/dts/ArcherC20.dts
@@ -0,0 +1,119 @@
+/dts-v1/;
+
+/include/ "mt7620a.dtsi"
+
+/ {
+ compatible = "ralink,mt7620a-soc";
+ model = "TP-Link Archer C20";
+
+ chosen {
+ bootargs = "console=ttyS0,115200";
+ };
+
+ palmbus@10000000 {
+ gpio2: gpio@660 {
+ status = "okay";
+ };
+
+ spi@b00 {
+ status = "okay";
+
+ m25p80@0 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "en25q64";
+ reg = <0 0>;
+ linux,modalias = "m25p80", "mx25l6405d";
+ 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>;
+ };
+
+ rom: partition@7d0000 {
+ label = "rom";
+ reg = <0x7d0000 0x10000>;
+ };
+
+ partition@7e0000 {
+ label = "romfile";
+ reg = <0x7e0000 0x10000>;
+ };
+
+ radio: partition@7f0000 {
+ label = "radio";
+ reg = <0x7f0000 0x10000>;
+ };
+ };
+ };
+ };
+
+ pinctrl {
+ state_default: pinctrl0 {
+ gpio {
+ ralink,group = "i2c", "uartf", "rgmii1", "rgmii2", "wled", "nd_sd";
+ ralink,function = "gpio";
+ };
+ };
+ };
+
+ ethernet@10100000 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&ephy_pins>;
+
+ mtd-mac-address = <&rom 0xf100>;
+ ralink,port-map = "wllll";
+ };
+
+ ehci@101c0000 {
+ status = "okay";
+ };
+
+ ohci@101c1000 {
+ status = "okay";
+ };
+
+ gsw@10110000 {
+ ralink,port4 = "ephy";
+ };
+
+ wmac@10180000 {
+ ralink,mtd-eeprom = <&radio 0>;
+ };
+
+ pcie@10140000 {
+ status = "okay";
+
+ pcie-bridge {
+ mt76@0,0 {
+ reg = <0x0000 0 0 0 0>;
+ device_type = "pci";
+ mediatek,mtd-eeprom = <&radio 32768>;
+ mediatek,2ghz = <0>;
+ };
+ };
+ };
+
+ gpio-leds {
+ compatible = "gpio-leds";
+ };
+
+ gpio-keys-polled {
+ compatible = "gpio-keys-polled";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ poll-interval = <20>;
+ };
+};
diff --git a/target/linux/ramips/image/Makefile b/target/linux/ramips/image/Makefile
index 8bdd76a..7202641 100644
--- a/target/linux/ramips/image/Makefile
+++ b/target/linux/ramips/image/Makefile
@@ -951,6 +951,8 @@ Image/Build/Profile/ZTE-Q7=$(call BuildFirmware/Default8M/$(1),$(1),zte-q7,ZTE-Q
Image/Build/Profile/YOUKU-YK1=$(call BuildFirmware/Default16M/$(1),$(1),youku-yk1,YOUKU-YK1)
Image/Build/Profile/ZBT-WA05=$(call BuildFirmware/Default8M/$(1),$(1),zbt-wa05,ZBT-WA05)
Image/Build/Profile/ZBT-WR8305RT=$(call BuildFirmware/Default8M/$(1),$(1),zbt-wr8305rt,ZBT-WR8305RT)
+Image/Build/Profile/ArcherC2=$(call BuildFirmware/Tplink/$(1),$(1),ArcherC2,ArcherC2)
+Image/Build/Profile/ArcherC20=$(call BuildFirmware/Tplink/$(1),$(1),ArcherC20,ArcherC20)
Image/Build/Profile/ArcherC20i=$(call BuildFirmware/Tplink/$(1),$(1),ArcherC20i,ArcherC20i)
microwrt_mtd_size=16515072
Image/Build/Profile/MicroWRT=$(call BuildFirmware/CustomFlash/$(1),$(1),microwrt,MicroWRT,$(microwrt_mtd_size))
@@ -993,6 +995,8 @@ define Image/Build/Profile/Default
$(call Image/Build/Profile/YOUKU-YK1,$(1))
$(call Image/Build/Profile/ZBT-WA05,$(1))
$(call Image/Build/Profile/ZBT-WR8305RT,$(1))
+ $(call Image/Build/Profile/ArcherC2,$(1))
+ $(call Image/Build/Profile/ArcherC20,$(1))
$(call Image/Build/Profile/ArcherC20i,$(1))
$(call Image/Build/Profile/MicroWRT,$(1))
$(call Image/Build/Profile/TINY-AC,$(1))
diff --git a/target/linux/ramips/mt7620/config-4.3 b/target/linux/ramips/mt7620/config-4.3
index 2ad77f1..d705f40 100644
--- a/target/linux/ramips/mt7620/config-4.3
+++ b/target/linux/ramips/mt7620/config-4.3
@@ -170,6 +170,9 @@ CONFIG_RALINK=y
CONFIG_RALINK_WDT=y
# CONFIG_RCU_STALL_COMMON is not set
CONFIG_RESET_CONTROLLER=y
+CONFIG_RTL8366_SMI=y
+CONFIG_RTL8367B_PHY=y
+CONFIG_RTL8367_PHY=y
CONFIG_SCHED_HRTICK=y
# CONFIG_SCHED_INFO is not set
# CONFIG_SCSI_DMA is not set
diff --git a/target/linux/ramips/mt7620/profiles/tp-link.mk b/target/linux/ramips/mt7620/profiles/tp-link.mk
new file mode 100644
index 0000000..1a95dcd
--- /dev/null
+++ b/target/linux/ramips/mt7620/profiles/tp-link.mk
@@ -0,0 +1,43 @@
+#
+# Copyright (C) 2015 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define Profile/ArcherC2
+ NAME:=TP-Link Archer C2
+ PACKAGES:=\
+ kmod-usb-core kmod-usb2 kmod-usb-ohci kmod-scsi-generic \
+ kmod-ledtrig-usbdev kmod-mt76 swconfig
+endef
+
+define Profile/ArcherC2/Description
+ Default package set compatible with TP-Link Archer C2
+endef
+
+define Profile/ArcherC20
+ NAME:=TP-Link Archer C20
+ PACKAGES:=\
+ kmod-usb-core kmod-usb2 kmod-usb-ohci kmod-scsi-generic \
+ kmod-ledtrig-usbdev kmod-mt76
+endef
+
+define Profile/ArcherC20/Description
+ Default package set compatible with TP-Link Archer C20
+endef
+
+define Profile/ArcherC20i
+ NAME:=TP-Link Archer C20i
+ PACKAGES:=\
+ kmod-usb-core kmod-usb2 kmod-usb-ohci kmod-scsi-generic \
+ kmod-ledtrig-usbdev kmod-mt76
+endef
+
+define Profile/ArcherC20i/Description
+ Default package set compatible with TP-Link Archer C20i
+endef
+
+$(eval $(call Profile,ArcherC2))
+$(eval $(call Profile,ArcherC20))
+$(eval $(call Profile,ArcherC20i))
diff --git a/tools/firmware-utils/src/mktplinkfw2.c b/tools/firmware-utils/src/mktplinkfw2.c
index 9b9ebf5..3182848 100644
--- a/tools/firmware-utils/src/mktplinkfw2.c
+++ b/tools/firmware-utils/src/mktplinkfw2.c
@@ -179,6 +179,20 @@ static struct board_info boards[] = {
.hdr_ver = 3,
.endian_swap = true,
}, {
+ .id = "ArcherC20",
+ .hw_id = 0xc2000001,
+ .hw_rev = 68,
+ .layout_id = "8Mmtk",
+ .hdr_ver = 3,
+ .endian_swap = true,
+ }, {
+ .id = "ArcherC2",
+ .hw_id = 0xc7500001,
+ .hw_rev = 50,
+ .layout_id = "8Mmtk",
+ .hdr_ver = 3,
+ .endian_swap = true,
+ }, {
.id = "ArcherVR200V",
.hw_id = 0x73b70801,
.hw_rev = 0x2f,
--
2.5.4 (Apple Git-61)
@alext234
Copy link

Is it tested for C2?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment