Support for tp-link ec220-g5

Theoretically, you could try to mount the flash, after you've booted an initramfs, then try to make the changes you need.

Thanks for your answers, could you please elaborate? As I have basically zero knowledge about openwrt, flashing etc..

You're not going to flash anything, but you'll need serial console access.

I found the reason why the gpio 2 (wlan2g) didn't work.
It's because of rfkill in keys section:

       keys {
               compatible = "gpio-keys";

               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>;
               };
       };

I haven't noticed that before. It needs to clear out.

Here's working dts file:

# cat ./target/linux/ramips/dts/mt7620a_tplink_archer-c5-v4.dts
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

#include "mt7620a.dtsi"

#include <dt-bindings/input/input.h>
#include <dt-bindings/gpio/gpio.h>

/ {
	compatible = "tplink,archer-c5-v4", "ralink,mt7620a-soc";
	model = "TP-Link Archer C5 v4";

	aliases {
		led-boot = &led_power;
		led-failsafe = &led_power;
		led-running = &led_power;
		led-upgrade = &led_power;
		label-mac-device = &ethernet;
	};

	chosen {
		bootargs = "console=ttyS0,115200";
	};

	leds {
		compatible = "gpio-leds";

		led_power: power {
			label = "green:power";
			gpios = <&gpio2 2 GPIO_ACTIVE_LOW>;
		};

		wan_orange {
			label = "orange:wan";
			gpios = <&gpio0 7 GPIO_ACTIVE_LOW>;
		};

		wlan2g {
			label = "green:wlan2g";
			gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "phy1tpt";
		};

		wlan5g {
			label = "green:wlan5g";
			gpios = <&gpio0 9 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "phy0tpt";
		};

		lan {
			label = "green:lan";
			gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
		};
	};

	keys {
		compatible = "gpio-keys";

		reset {
			label = "reset";
			gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_RESTART>;
		};
	};

	rtl8367s {
		compatible = "realtek,rtl8367c";
		cpu_port = <7>;
		realtek,extif2 = <1 0 1 1 1 1 1 1 2>;
		mii-bus = <&mdio0>;
		phy-id = <29>;
	};
};

&gpio2 {
	status = "okay";
};

&spi0 {
	status = "okay";

	flash@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <60000000>;
		m25p,fast-read;

		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			partition@0 {
				label = "u-boot";
				reg = <0x0 0x20000>;
				read-only;
			};

			partition@20000 {
				compatible = "tplink,firmware";
				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;
			};
		};
	};
};

&state_default {
	gpio {
		groups = "i2c", "uartf", "ephy", "rgmii2";
		function = "gpio";
	};
};

&ethernet {
	pinctrl-names = "default";
	mtd-mac-address = <&rom 0xf100>;
	pinctrl-0 = <&rgmii1_pins &mdio_pins>;

	port@5 {
		status = "okay";
		mediatek,fixed-link = <1000 1 1 1>;
		phy-mode = "rgmii";
	};

	mdio0: mdio-bus {
		status = "okay";
		reset-gpios = <&gpio2 20 GPIO_ACTIVE_LOW>;
		reset-delay-us = <10000>;
	};
};

&ehci {
	status = "okay";
};

&ohci {
	status = "okay";
};

&wmac {
	ralink,mtd-eeprom = <&radio 0x0>;
	mtd-mac-address = <&rom 0xf100>;
};

&pcie {
	status = "okay";
};

&pcie0 {
	wifi@0,0 {
		reg = <0x0000 0 0 0 0>;
		mediatek,mtd-eeprom = <&radio 0x8000>;
		ieee80211-freq-limit = <5000000 6000000>;
		mtd-mac-address = <&rom 0xf100>;
		mtd-mac-address-increment = <2>;
	};
};


So I compiled 22.03.6 as in this post

Then I flashed the firmware, but ethernet and wlan5g won't work, it's happened because modules kmod-mt76x2 kmod-switch-rtl8367b haven't checked for some reasons during selecting target profile, don't know why.

I checked it out by hands in menuconfig. Now all works fine.

Try compiling version 23.05.2 from https://github.com/namiltd/openwrt/tree/openwrt-23.05-archer-c5-v4
Of course, correct the LEDs and keys to those appropriate for your router.

A little note: Since there are problems with the performance of 2.4GHz WiFi for Mediatek MT7620, disable 802.11w Management Frame Protection in Wireless Security.

GPL source code for TP-Link EC220-G5 v2

Support for TP-Link Archer C5 v4 has just been added to OpenWRT. Thanks to this, images for this router are available directly at https://firmware-selector.openwrt.org/?version=SNAPSHOT&target=ramips%2Fmt7620&id=tplink_archer-c5-v4
You can also build firmware for TP-Link ec220-g5 by changing mt7620a_tplink_archer-c5-v4.dts to:

// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

#include <dt-bindings/leds/common.h>

#include "mt7620a_tplink_archer.dtsi"

/ {
	compatible = "tplink,archer-c5-v4", "ralink,mt7620a-soc";
	model = "TP-Link Archer C5 v4";

	aliases {
		led-boot = &led_power;
		led-failsafe = &led_power;
		led-running = &led_power;
		led-upgrade = &led_power;
		label-mac-device = &ethernet;
	};

	leds {
		compatible = "gpio-leds";

		led_power: led-0 {
			function = LED_FUNCTION_POWER;
			color = <LED_COLOR_ID_GREEN>;
			gpios = <&gpio2 2 GPIO_ACTIVE_LOW>;
		};

		led-1 {
			function = LED_FUNCTION_WAN;
			color = <LED_COLOR_ID_ORANGE>;
			gpios = <&gpio0 7 GPIO_ACTIVE_LOW>;
		};

		led-2 {
			function = LED_FUNCTION_LAN;
			color = <LED_COLOR_ID_GREEN>;
			gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
		};

		led-3 {
			function = LED_FUNCTION_WLAN_2GHZ;
			color = <LED_COLOR_ID_GREEN>;
			gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "phy0tpt";
		};

		led-4 {
			function = LED_FUNCTION_WLAN_5GHZ;
			color = <LED_COLOR_ID_GREEN>;
			gpios = <&gpio0 9 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "phy1tpt";
		};
	};

	/delete-node/ keys;

	keys {
		compatible = "gpio-keys";

		reset {
			label = "reset";
			gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
			linux,code = <KEY_RESTART>;
		};
	};

	rtl8367s {
		compatible = "realtek,rtl8367b";
		cpu_port = <7>;
		realtek,extif2 = <1 0 1 1 1 1 1 1 2>;
		mii-bus = <&mdio0>;
		phy-id = <29>;
	};
};

&spi0 {
	flash@0 {
		#address-cells = <1>;
		#size-cells = <1>;
	};
};

&state_default {
	gpio {
		groups = "i2c", "uartf", "ephy", "rgmii2";
		function = "gpio";
	};
};

&ethernet {
	pinctrl-names = "default";
	pinctrl-0 = <&rgmii1_pins &mdio_pins>;

	port@5 {
		status = "okay";
		mediatek,fixed-link = <1000 1 1 1>;
		phy-mode = "rgmii";
	};

	mdio0: mdio-bus {
		status = "okay";
		reset-gpios = <&gpio2 20 GPIO_ACTIVE_LOW>;
		reset-delay-us = <10000>;
	};
};

&wmac {
	pinctrl-names = "default", "pa_gpio";
	pinctrl-0 = <&pa_pins>;
	pinctrl-1 = <&pa_gpio_pins>;

	nvmem-cells = <&eeprom_radio_0>, <&macaddr_rom_f100 0>;
	nvmem-cell-names = "eeprom", "mac-address";
};

&wifi {
	nvmem-cells = <&eeprom_radio_8000>, <&macaddr_rom_f100 2>;
	nvmem-cell-names = "eeprom", "mac-address";
};

I don't have such a router, so I haven't checked if everything works properly. So test it out and send me any comments. If all goes well, there will be no obstacles to adding this router to the OpenWRT repository under its name.

Is it possible to change dts file by building in firmware-selector ?

It can be added to the list by making such a correction at https://github.com/openwrt/openwrt/ but this requires testing first. I don't have such a router, so I can't check if it works.

Hello everyone, I have this EC220-G5, but I don't have any knowledge to compile a firmware for this router. If someone has done and tested it, could you share the firmware?! Thanks.

hello
I try to build with your config and got this error Unable to parse input tree

nt/data/tmp/openwrt/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7620/image-mt7620a_tplink_archer-c5-v4.dtb.tmp ../dts/mt7620a_tplink_archer-c5-v4.dts
/mnt/data/tmp/openwrt/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7620/linux-5.15.150/scripts/dtc/dtc -O dtb -i../dts/ -Wno-unit_address_vs_reg -Wno-simple_bus_reg -Wno-unit_address_format -Wno-pci_bridge -Wno-pci_device_bus_num -Wno-pci_device_reg -Wno-avoid_unnecessary_addr_size -Wno-alias_paths -Wno-graph_child_address -Wno-graph_port -Wno-unique_unit_address    -o /mnt/data/tmp/openwrt/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7620/image-mt7620a_tplink_archer-c5-v4.dtb /mnt/data/tmp/openwrt/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7620/image-mt7620a_tplink_archer-c5-v4.dtb.tmp
Error: ../dts/mt7620a_tplink_archer-c5-v4.dts:30.15-16 syntax error
FATAL ERROR: Unable to parse input tree
make[5]: *** [Makefile:235: /mnt/data/tmp/openwrt/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7620/image-mt7620a_tplink_archer-c5-v4.dtb] Error 1
make[5]: Leaving directory '/mnt/data/tmp/openwrt/target/linux/ramips/image'
make[4]: *** [Makefile:22: install] Error 2
make[4]: Leaving directory '/mnt/data/tmp/openwrt/target/linux/ramips'
make[3]: *** [Makefile:11: install] Error 2
make[3]: Leaving directory '/mnt/data/tmp/openwrt/target/linux'
time: target/linux/install#14.79#4.51#18.35
    ERROR: target/linux failed to build.
make[2]: *** [target/Makefile:32: target/linux/install] Error 1
make[2]: Leaving directory '/mnt/data/tmp/openwrt'
make[1]: *** [target/Makefile:26: /mnt/data/tmp/openwrt/staging_dir/target-mipsel_24kc_musl/stamp/.target_install] Error 2
make[1]: Leaving directory '/mnt/data/tmp/openwrt'
make: *** [/mnt/data/tmp/openwrt/include/toplevel.mk:232: world] Ошибка 2

-download and extract zip file: https://codeload.github.com/openwrt/openwrt/zip/refs/heads/main
-edit file: mt7620a_tplink_archer-c5-v4.dts
-run:

./scripts/feeds update -a
./scripts/feeds install -a
make defconfig
make menuconfig
make -j$(nproc) download
make -j$(nproc) V=s

select:
Target System -> Mediatek Ralink Mips
Subtarget->MT7620 Based Boards
Target Profile ->TP-Llink Archer C5 v4
Luci->Collections->luci *

The images are located in a subfolder: bin/target/ramips/mt7620

@ricardovitor: Link to binaries: https://easyupload.io/2ym3ol_

A little note: Since there are problems with the performance of 2.4GHz WiFi for Mediatek MT7620, disable 802.11w Management Frame Protection in Wireless Security.

However, it should be borne in mind that, like the Archer C5 v4, the router can be used with two different families of chips: rtl8367c or rtl8367d. Compiled images only support the rtl8367c family. If it is incorrect, there will be no LAN communication and the need to restore the previous flash.

After led-3 { you should close the '{':

led-3 {
			function = LED_FUNCTION_WLAN;
			color = <LED_COLOR_ID_GREEN>;
			function-enumerator = <2>;
			gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "phy0tpt";
};   // <-- here

unfortunately those links doesn't work for me :confused:

Fortunately, it is possible to download directly from TP-Link from the links below:

1 Like

Thanks for the binaries. I was able to install using the TFTP recovery file, but there were no LED lights and no Wan port. I noticed that all the ports were Lans.

Without connecting a serial terminal, it will not be known for sure what the cause is, but your router probably has an unsupported rtl8367d family chip.

The experimental flash image for this family can be downloaded here: https://disk.yandex.ru/d/HrT5PMczO8PPBw but it is for Archer c5 v4.

hello.
so after editing the dts config I was able to assemble the image. LED indication works. All ports were also only in the LAN segment and were confused with each other. I manually found wan port, it was Lan1 and replaced it with Vlan2. more details in the screenshot below. after that my internet started working. I also had 2 switches displayed in my system. deleted it with command

uci delete network.@switch[0] && uci commit

Hi zenck, could you send your firmware file and your configuration correcting the Vlan? Thanks

You probably just need to replace the WLAN definitions
at target/linux/ramips/mt7620/base-files/etc/board.d/02_network

	tplink,archer-c5-v4)
		ucidef_add_switch "switch0"
		ucidef_add_switch_attr "switch0" "enable" "0"
		ucidef_add_switch "switch1" \
			"0:wan" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4" "7@eth0"

Probably too target/linux/ramips/mt7620/base-files/etc/board.d/01_leds

tplink,archer-c5-v4)
	ucidef_set_led_switch "lan" "lan" "green:lan" "switch1" "0x1e"
	ucidef_set_led_switch "wan" "wan" "orange:wan" "switch1" "0x01"
	;;

Please check.
If everything is OK, it will be possible to generate a PR supporting this router at https://github.com/openwrt/openwrt
To make it easier for others to install OpenWRT on a router, a description of the installation and restoration, parameters and order of the serial port, etc. are also required.

Thanks mietekn, with your file I was able to make it work and thanks to the @zench1k I was able to make the wan port work and now I have internet although I measure the speed and I'm stuck at /100 whereas my connection is /1000 and I have more than 300 megs on the network. My LEDs are not functional, I'm waiting for someone who made them to work to test them on mine.