Help w/ Configuring the LED of TOTOLINK A3

Hi, Folks,

Got a not-so-popular TOTOLINK A3 router (a clone of ipTIME A3). After successively flashing the custom-built firmware from the forum and the official 22.03.5 firmware, the router works great, except for part of the LEDs.

Just to be a little bit informative, this wee router has 5 LEDs (Power, WLAN, WAN, LAN1 and LAN2), and the first two can be turned on or off by using echo 1 or echo 0 to the corresponding brightness files. But the last three LEDs are neither enumerated nor configurable, and just keep blinking once the Ethernet cable is plugged in. The output of ls -l is as follows,

root@OpenWrt:~# ls -l /sys/class/leds
lrwxrwxrwx 1 root root 0 Jan  1  1970 blue:cpu -> ../../devices/platform/leds/leds/blue:cpu
lrwxrwxrwx 1 root root 0 Jan  1  1970 blue:wlan -> ../../devices/platform/leds/leds/blue:wlan
lrwxrwxrwx 1 root root 0 Apr 27 21:41 mt76-phy0 -> ../../devices/platform/10300000.wmac/leds/mt76-phy0
lrwxrwxrwx 1 root root 0 Apr 27 21:41 mt76-phy1 -> ../../devices/pci0000:00/0000:00:00.0/0000:01:00.0/leds/mt76-phy1

After searching on the Web for weeks, just stumbled upon a thread posted on Padavan-related forum by pa2w. As mentioned in that thread, the GPIO of WAN and LAN are likely to be 43 and 41, respectively.

board.h -

/* TOTOLINK A3 */

#define BOARD_PID "za3"
#define BOARD_NAME "za3"
#define BOARD_DESC "TOTOLINK A3"
...
#define BOARD_GPIO_BTN_RESET 6
#define BOARD_GPIO_BTN_WPS 13
...
#define BOARD_GPIO_LED_POWER 11
#define BOARD_GPIO_LED_LAN 41
#define BOARD_GPIO_LED_WAN 43
...
#define BOARD_GPIO_LED_WAN_PHY 42
...
#define BOARD_NUM_ETH_LEDS 0
#define BOARD_HAS_EPHY_L1000 0
#define BOARD_HAS_EPHY_W1000 0 

After appending the following lines to the corresponding .dts file, re-compiling and flashing the generated firmware, neither of these three LEDs is configurable.

--- a/target/linux/ramips/dts/mt7628an_totolink_a3.dts	2023-06-28 21:50:32.409113962 +0800
+++ b/target/linux/ramips/dts/mt7628an_totolink_a3.dts	2023-06-28 22:18:34.233634737 +0800
@@ -15,21 +15,29 @@
 
 	leds {
 		compatible = "gpio-leds";
 
 		led_cpu: cpu {
 			label = "blue:cpu";
 			gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
 		};
 
 		wlan {
 			label = "blue:wlan";
 			gpios = <&gpio 46 GPIO_ACTIVE_LOW>;
 			linux,default-trigger = "phy0tpt";
 		};
+		wan {
+			label = "blue:wan";
+			gpios = <&gpio 43 GPIO_ACTIVE_LOW>;
+		};
+		lan {
+			label = "blue:lan";
+			gpios = <&gpio 41 GPIO_ACTIVE_LOW>;
+		};
 	};
 };
 
 &esw {
 	mediatek,portmap = <0x3e>;
 	mediatek,portdisable = <0x32>;
 };

When running the newly generated firmware, the output of ls -l is as follows,

root@OpenWrt:~# ls -l /sys/class/leds
lrwxrwxrwx 1 root root 0 Jan  1  1970 blue:cpu -> ../../devices/platform/leds/leds/blue:cpu
lrwxrwxrwx 1 root root 0 Jan  1  1970 blue:lan -> ../../devices/platform/leds/leds/blue:lan
lrwxrwxrwx 1 root root 0 Jan  1  1970 blue:wan -> ../../devices/platform/leds/leds/blue:wan
lrwxrwxrwx 1 root root 0 Jan  1  1970 blue:wlan -> ../../devices/platform/leds/leds/blue:wlan
lrwxrwxrwx 1 root root 0 Apr 27 22:11 mt76-phy0 -> ../../devices/platform/10300000.wmac/leds/mt76-phy0

To test further, the gpio-test.sh posted on OpenWrt WiKi has also been run, and none of these three mystery LEDs blinked during testing (except for the one connecting with the laptop).

Since the programming or electronic stuff is way over my head, I would be grateful if any help could be given in this regard.

Many thanks,

CL

Hi,Folks,

Before the thread is closed automatically, I reckon that I would be better off to post the findings in case there is anyone interested in configuring the LEDs of WAN, LAN1 and LAN2.

Basically, WAN sits on GPIO43, LAN1 on GPIO40 and LAN2 on GPIO41. In addition to the dts file, the .dtsi file needs to be patched at the same time. To make the story complete, the 01_led file is also patched.

The patches are as follows,

diff -ru a/target/linux/ramips/dts/mt7628an_totolink_a3.dts b/target/linux/ramips/dts/mt7628an_totolink_a3.dts
--- a/target/linux/ramips/dts/mt7628an_totolink_a3.dts	2023-07-14 10:42:23.246797688 +0800
+++ b/target/linux/ramips/dts/mt7628an_totolink_a3.dts	2023-07-14 10:47:31.184683163 +0800
@@ -26,6 +26,21 @@
 			gpios = <&gpio 46 GPIO_ACTIVE_LOW>;
 			linux,default-trigger = "phy0tpt";
 		};
+
+		wan {
+			label = "blue:wan";
+			gpios = <&gpio 43 GPIO_ACTIVE_LOW>;
+		};
+
+		lan1 {
+			label = "blue:lan1";
+			gpios = <&gpio 40 GPIO_ACTIVE_LOW>;
+		};
+
+		lan2 {
+			label = "blue:lan2";
+			gpios = <&gpio 41 GPIO_ACTIVE_LOW>;
+		};
 	};
 };

diff -ru a/target/linux/ramips/dts/mt7628an_iptime.dtsi b/target/linux/ramips/dts/mt7628an_iptime.dtsi
--- a/target/linux/ramips/dts/mt7628an_iptime.dtsi	2023-07-14 10:42:23.234791688 +0800
+++ b/target/linux/ramips/dts/mt7628an_iptime.dtsi	2023-07-14 10:47:31.136659164 +0800
@@ -71,7 +71,7 @@
 
 &state_default {
 	gpio {
-		groups = "uart1", "wdt";
+		groups = "uart1", "p0led_an", "p3led_an", "p2led_an", "wdt";
 		function = "gpio";
 	};
 };

diff -ru a/target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds b/target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds
--- a/target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds	2023-07-14 10:57:54.692268005 +0800
+++ b/target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds	2023-07-14 10:48:17.695926188 +0800
@@ -56,6 +56,11 @@
 rakwireless,rak633)
 	ucidef_set_led_netdev "wifi_led" "wifi" "blue:wifi" "wlan0"
 	;;
+totolink,a3)
+	ucidef_set_led_switch "wan" "wan" "blue:wan" "switch0" "0x01"
+	ucidef_set_led_switch "lan1" "lan1" "blue:lan1" "switch0" "0x08"
+	ucidef_set_led_switch "lan2" "lan2" "blue:lan2" "switch0" "0x04"
+	;;
 tama,w06)
 	ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth0"
 	ucidef_set_led_wlan "wlan" "WLAN" "green:wlan" "phy0tpt"

Regards,
CL

1 Like