Adding OpenWrt support for HYC-G920

Hi
I have this Device which is nearly Identical to ASUS RT-AC57U

SoC: MediaTek MT7621AT
RAM: 256M (SK hynix H5TQ2G63FFR)
FLASH: 16MB (Winbond 25Q128FVSG)
WiFi: MediaTek MT7602EN bgn 2SS
WiFi: MediaTek MT7612EN nac 2SS
BTN: Reset
LED: - Power RED
- WAN Green
- LAN {1-4}
- WiFi 2.4 GHz Blue
- WiFi 5 GHz Blue
- USB Green
UART:
GND - 3V3 - TX - RX - GND / 57600-8N1

I have BreedWeb installed on device. and i flashed sysupgrade snapshot image for ASUS RT-AC57U
everything is working fine except for wifi 2.4GHz LED and USB LED and reset button.

Note that i tested it with ASUS firmware and 2.4GHz Wifi LED is working.

If you can help me how to provide you with information to add support for this device. as it does not need much work.
i tried to work out with some gpio scripts you provide. but i do not understand what is needed and where to pull it from.

Any Help would be appreciated.

I have BreedWeb installed on device.

You can test gpio using Breed Colsole. Use telnet to connect to the device running Breed and use the gpio commands to get relevant data.

GPIO testing commands from this thread:
https://www.right.com.cn/forum/thread-161906-1-1.html

[gpio]
语法:gpio [status|list]
          gpio button
          gpio led
          gpio get <n>
          gpio set <n> <hi|lo>
          gpio dir set <n> <in|out>
          gpio led set <name> <on|off>
参数: [status] - 列出所有 GPIO 及其状态
           <n> - GPIO 号
           <hi> <lo> - 高/低电平
           <in> <out> - GPIO 方向为输入/输出
           <name> - LED 名称
           <on> <off> - LED 亮/灭
说明:gpio [status|list] 列出所有 GPIO 及其状态
           gpio button 显示当前路由上按钮的状态
           gpio led 显示当前路由上部分 LED 的状态
           gpio get 获取指定 GPIO 的电平状态
           gpio set 设置指定 GPIO 的电平状态
           gpio dir set 设置指定 GPIO 的方向
           gpio led set 设置 LED 的亮灭

Thanks for help
Actually the Breedweb is for a compatible device it is not for that specific device
so gpio info are not correct.
the only thing i know for sure is that reset is @ gpio 3 active low
i will try to run gpio scripts to figure it out.

I am sure of
RESET BTN @ gpio 3 Active low
Power LED @ gpio 0 Active low
USB LED @ gpio 18 Active low
wifi5g LED @ gpio 19 Active low (I cannot turn it on with scripts but when wireless interface is enabled and gpio 19 triggered by scripts it goes off)
wifi2g LEG @ gpio 20 Active low (assumption)

Then you’re pretty much good to go, finally you need to match the mac address scheme to the original firmware, and you‘re ready to make a pull request.

By the way, the breedweb gpio test functionality doesn‘t require you to have the same device. What it does isn’t outputting information that‘s already there, but rather giving you a way to test the GPIO pin numbers, i.e. you can control the GPIO status with commands, or using a screw driver / tweezer to short a LED and it’ll tell you which GPIO pin you‘re shorting.

that i did not understand.
when i short any LED nothing happen on ttl consol.
note that reset gpio 3 configured as button so status would be pressed or released.
only power and USB are controllable via gpio tool in breed web
no other LEDs are able to control.
even with openwrt running and running scripts for blinking leds.
power and USB too are the only responding.

i do not have a device right now with original firmware. but i will try to get one soon ..
but can you explain more what do you mean by matching mac address scheme?

you mean this tool > btntst ?

Yes.

As for matching MAC address scheme, it means you‘ll have to do some patches to the DTS file to make sure when flashed with Openwrt firmware, the device has the same MAC address on all network interfaces as the OEM firmware. e.g. LAN, WAN, 2G, 5G

1 Like

Hi
I edited dts file to be like that

changes in file marked with ** in the beginning and ** in the end of each line.
Also i removed WPS button code. as WPS does not exist

mt7621_asus_rt-ac57u.dts

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

#include "mt7621.dtsi"

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

/ {
	compatible = "asus,rt-ac57u", "mediatek,mt7621-soc";
	model = "ASUS RT-AC57U";

	aliases {
		led-boot = &led_power;
		led-failsafe = &led_power;
		led-running = &led_power;
		led-upgrade = &led_power;
	};

	leds {
		compatible = "gpio-leds";

		led_power: power {
			label = "red:power";
			**gpios = <&gpio 0 GPIO_ACTIVE_LOW>;**
		};

		usb {
			label = "green:usb";
			**gpios = <&gpio 18 GPIO_ACTIVE_LOW>;**
			trigger-sources = <&ehci_port2>;
			linux,default-trigger = "usbport";
		};
	};

	keys {
		compatible = "gpio-keys";

		reset {
			label = "reset";
			**gpios = <&gpio 3 GPIO_ACTIVE_LOW>;**
			linux,code = <KEY_RESTART>;
			debounce-interval = <60>;
		};
	};

	led-regulator {
		compatible = "regulator-fixed";
		regulator-name = "LED-Power";
		gpio = <&gpio 46 GPIO_ACTIVE_LOW>;
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		regulator-always-on;
	};
};

&spi0 {
	status = "okay";

	flash@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <10000000>;

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

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

			partition@30000 {
				label = "config";
				reg = <0x30000 0x10000>;
				read-only;
			};

			factory: partition@40000 {
				label = "factory";
				reg = <0x40000 0x10000>;
				read-only;
			};

			partition@50000 {
				compatible = "denx,uimage";
				label = "firmware";
				reg = <0x50000 0xfb0000>;
			};
		};
	};
};

&pcie {
	status = "okay";
};

&pcie0 {
	wifi@0,0 {
		compatible = "mediatek,mt76";
		reg = <0x0000 0 0 0 0>;
		mediatek,mtd-eeprom = <&factory 0x8000>;

		led {
			led-sources = <2>;
			led-active-low;
		};
	};
};

&pcie1 {
	wifi@0,0 {
		compatible = "mediatek,mt76";
		reg = <0x0000 0 0 0 0>;
		mediatek,mtd-eeprom = <&factory 0x0000>;

		led {
			**led-sources = <2>;**
			led-active-low;
		};
	};
};

&gmac0 {
	nvmem-cells = <&macaddr_factory_e000>;
	nvmem-cell-names = "mac-address";
};

&switch0 {
	ports {
		port@0 {
			status = "okay";
			label = "wan";
			nvmem-cells = <&macaddr_factory_e006>;
			nvmem-cell-names = "mac-address";
		};

		port@1 {
			status = "okay";
			label = "lan1";
		};

		port@2 {
			status = "okay";
			label = "lan2";
		};

		port@3 {
			status = "okay";
			label = "lan3";
		};

		port@4 {
			status = "okay";
			label = "lan4";
		};
	};
};

&state_default {
	gpio {
		groups = "sdhci";
		function = "gpio";
	};
};

&factory {
	compatible = "nvmem-cells";
	#address-cells = <1>;
	#size-cells = <1>;

	macaddr_factory_e000: macaddr@e000 {
		reg = <0xe000 0x6>;
	};

	macaddr_factory_e006: macaddr@e006 {
		reg = <0xe006 0x6>;
	};
};

Now All LEDs are working as expected and reset button too.

i will wait until i get a fresh device so i can check the MAC address schema
but for now
LAN MAC
WAN MAC
5gwifi MAC
4gwifi MAC
are all set and working
thanks for your support.

Any Help to submit patch for adding this device.
i do not know how to patch this up.

Do you know how to use git? If not, maybe start with that.

1 Like

Github is the most straightforward, or you can use the mailing list.

Starting point is to go through the ‘add a new device’ guide and create the unique dts for your device, as well as detailing any other changes needed.

A hacked dts for another device won’t be accepted.

Your build needs to show an option for this device in menuconfig and then build a valid image.

1 Like

For me asus was ok after this patch

git diff target/linux/ramips/dts/RT-AC57U.dts
diff --git a/target/linux/ramips/dts/RT-AC57U.dts b/target/linux/ramips/dts/RT-AC57U.dts
index 6fec0cdf61..5c2399a04c 100644
--- a/target/linux/ramips/dts/RT-AC57U.dts
+++ b/target/linux/ramips/dts/RT-AC57U.dts
@@ -119,7 +119,7 @@
                compatible = "mediatek,mt76";
                reg = <0x0000 0 0 0 0>;
                mediatek,mtd-eeprom = <&factory 0x8000>;
-
+               ieee80211-freq-limit = <5000000 6000000>;
                led {
                        led-sources = <2>;
                        led-active-low;
@@ -132,8 +132,9 @@
                compatible = "mediatek,mt76";
                reg = <0x0000 0 0 0 0>;
                mediatek,mtd-eeprom = <&factory 0x0000>;
-
+                ieee80211-freq-limit = <2400000 2500000>;
                led {
+                       led-sources = <2>;
                        led-active-low;
                };
        };