Trendnet TEW-810DR LEDs

The TEW-810DR has 2 Lenses: A power symbol and a Globe. Behind each lense sit a green and amber LED. I have and older TEW-732BR running OpenWRT that has the same LED arrangement.
The power symbol seems to work. Blinking Orange while booting and Steady green once booted. The Globe LED never illuminates. On the TEW-732BR, running 19.07.1, the Globe lense is steady green at rest and blinks with pings over the ethernet.

I followed these directions
https://openwrt.org/docs/guide-developer/add.new.device to interogate the GPIO's but did not get much information.
GPIO's 9, 12, 13, and 15 were busy. All the other GPIO's produced no output or were inaccessible.

The TEW-732BR LEDs have this OpenWRT configuration

tew-732br)
ucidef_set_led_netdev "wan" "WAN" "trendnet:green:wan" "eth1"

My TEW-810DR dts has this entry:

/ {
compatible = "trendnet,tew-810dr", "ralink,mt7620a-soc";
model = "TRENDnet TEW-810DR";

    leds {
            compatible = "gpio-leds";

            led_power_green: power {
                    label = "tew-810dr:green:power";
                    gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>;
            };

            wan {
                    label = "tew-810dr:green:wan";
                    gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;
            };

            power2 {
                    label = "tew-810dr:orange:power";
                    gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
            };
    };

};

Can someone point me in the right direction?

More information to add.

After recovering the TEW-810DR and flashing it with my snapshot build, I still have one hurdle to overcome prior to submitting a patch - the "Globe" led does not function. The Trendnet/D-Link manuals for this board indicate the Globe LED should be green with an LAN connection and blink with data packets.

I ran the script from the Documentation
https://openwrt.org/docs/guide-developer/add.new.device
with this output:

root@OpenWrt:/tmp# sh gpio_dump.sh 
[GPIO0] value 0
sh: write error: Resource busy
sh: write error: Resource busy
sh: write error: Invalid argument
sh: write error: Invalid argument
sh: write error: Invalid argument
sh: write error: Invalid argument
[GPIO7] value 1
[GPIO8] value 1
sh: write error: Resource busy
[GPIO10] value 1
[GPIO11] value 1
sh: write error: Resource busy
sh: write error: Resource busy
[GPIO14] value 1
sh: write error: Invalid argument
sh: write error: Invalid argument
sh: write error: Invalid argument
sh: write error: Invalid argument
sh: write error: Invalid argument
sh: write error: Invalid argument
sh: write error: Invalid argument

Using the single GPIO test on the same page for GPIO's 0, 7 ,8 ,10, 11 and 14, I did not seen any activity in the Globe LED (no green or amber).

Ideally, I would like to duplicate the factory LEDs.

Suggestions appreciated

All other LEDs are working as expected?
To find new LED use scripts form this page.

Some progress. I found this recent entry for the DIR-810L

> - Button codes OK both
>
> - No missing functionalities
>
> I noticed, however, that the green "Internet" LED blinks to the LAN4
> port, while -I guess- it should blink to the INTERNET (wan/eth0.2) port.
> But this was already happening before, it's not related to your patch.
>
> Roger

I moved my NIC cable from LAN1 to LAN4 and the "Internet/Globe" led now functions.

Is is possible to reassign the LED to wan/eth0.2

If I understand correctly:

  1. Bi-color power LED is ok.
  2. Globe/Internet LED isn't driven by wan gpio.
  3. Globe/Internet LED is driven by internal switch port marked as LAN4
    Right?
    Then turn ephy LED into gpio mode and find which gpio (40-44) correspond to LAN4 port.

Both the TEW-810DR and the D-Link DIR-810L share a common board manufactured by Cameo. The code I pasted above is incorrect; the lan led pin 12 is orange.

leds {
            compatible = "gpio-leds";

            led_power_green: power {
                    label = "tew-810dr:green:power";
                    gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>;
            };

            wan {
                    label = "tew-810dr:orange:wan";
                    gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;
            };

            power2 {
                    label = "tew-810dr:orange:power";
                    gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
            };
    };

There appears to be a gpio pin assignment for the lan but it is orange. That said, I've never seen the "Internet/Globe" led display orange.

Now that the cable is plugged in to LAN4 /sys/devices/platform/10000000.palmbus/10000600.gpio/gpiochip0/gpio/gpio14 has shown up.

I'm guessing that tew-810dr:green:wan is gpio 14. On testing GPIO=14, the resource is busy.

It's hard to understand you. May I ask again:

  • Bi-color power LED is ok. YES
  • Globe/Internet LED isn't driven by wan gpio. Half true. There are a pair of leds behind the Globe/internet LED - one green and one orange. There is a gpio pin assignment (12) in the dts for the orange one. The green Globe/Internet led could be gpio14. GPIO14 is not specified in the dts and did not show up until I plugged a NIC into LAN4
  • Globe/Internet LED is driven by internal switch port marked as LAN4. Could the internal switch have spawned gpio14?

What do you mean:

? Any of ports LAN1,LAN4? I think that your router have only 4 ports :slight_smile:

Typo: ...I plugged a NIC into LAN14... should read ...I plugged a NIC into LAN4...

LAN1, LAN2 and LAN3 do not result in a green Globe/Internet led. Only LAN4 results in a green Globe/Internet led. LAN4 also results in a new GPIO14 appearing in /sys/class/gpio. GPIO14 was not in /sys/class/gpio when the NIC was plugged into LAN1.

Ok.
Pls show content of /sys/class/gpio/gpio14/{direction,value}
And check gpio 40-44 with script from https://openwrt.org/docs/techref/hardware/port.gpio.

gpio14 direction in
gpio14 value 1
gpio14 active_low 0
gpio14 edge none

root@Shepnet:/tmp# chmod +x gpiocontrol.sh 
root@Shepnet:/tmp# ./gpiocontrol.sh 40 out 1

./gpiocontrol.sh: line 31: can't create /sys/class/gpio/gpio40/direction: nonexistent directory
./gpiocontrol.sh: line 45: can't create /sys/class/gpio/gpio40/value: nonexistent directory
root@Shepnet:/tmp# ./gpiocontrol.sh 41 out 1
./gpiocontrol.sh: line 31: can't create /sys/class/gpio/gpio41/direction: nonexistent directory
./gpiocontrol.sh: line 45: can't create /sys/class/gpio/gpio41/value: nonexistent directory
root@Shepnet:/tmp# ./gpiocontrol.sh 42 out 1
./gpiocontrol.sh: line 31: can't create /sys/class/gpio/gpio42/direction: nonexistent directory
./gpiocontrol.sh: line 45: can't create /sys/class/gpio/gpio42/value: nonexistent directory
root@Shepnet:/tmp# ./gpiocontrol.sh 43 out 1
./gpiocontrol.sh: line 31: can't create /sys/class/gpio/gpio43/direction: nonexistent directory
./gpiocontrol.sh: line 45: can't create /sys/class/gpio/gpio43/value: nonexistent directory
root@Shepnet:/tmp# ./gpiocontrol.sh 44 out 1
./gpiocontrol.sh: line 31: can't create /sys/class/gpio/gpio44/direction: nonexistent directory
./gpiocontrol.sh: line 45: can't create /sys/class/gpio/gpio44/value: nonexistent directory
root@Shepnet:/tmp# ./gpiocontrol.sh 14 out 1
root@Shepnet:/tmp# ./gpiocontrol.sh 14 in
1

blink or blink_all script
UPDATE: Modify dts-file:

&state_default {
	gpio {
		ralink,group = "i2c", "uartf", "ephy";
		ralink,function = "gpio";
	};
};

and

&gsw {
	mediatek,port4 = "ephy";
};

to control gpio 40-44 by gpio controller.
And blink again.

I'll modify and make a new build - will take some time. I'll post the blink_all script output tomorrow.

Thanks

With the *dts changes the Globe/Internet led went blank. I watched the Globe/Internet led while the blink_add script was running and the Globe/Internet led never blinked green or orange.

blink_all.sh

root@Shepnet:/tmp# ./blink_all.sh 
GPIO LED Test
Usage: ./blink_all.sh [wait time] [gpio start] [gpio end]
Example: ./blink_all.sh 3s 0 1
leave gpio range blank to test all GPIOs.

[gpiochip0:0:out] = 0
[gpiochip0:0:out] = 1
sh: write error: Resource busy
[gpiochip0:1] = Failed to export
sh: write error: Resource busy
[gpiochip0:2] = Failed to export
sh: write error: Invalid argument
[gpiochip0:3] = Failed to export
sh: write error: Invalid argument
[gpiochip0:4] = Failed to export
sh: write error: Invalid argument
[gpiochip0:5] = Failed to export
sh: write error: Invalid argument
[gpiochip0:6] = Failed to export
[gpiochip0:7:out] = 0
[gpiochip0:7:out] = 1
[gpiochip0:8:out] = 0
[gpiochip0:8:out] = 1
sh: write error: Resource busy
[gpiochip0:9] = Failed to export
[gpiochip0:10:out] = 0
[gpiochip0:10:out] = 1
[gpiochip0:11:out] = 0
[gpiochip0:11:out] = 1
sh: write error: Resource busy
[gpiochip0:12] = Failed to export
sh: write error: Resource busy
[gpiochip0:13] = Failed to export
[gpiochip0:14:out] = 0
[gpiochip0:14:out] = 1
sh: write error: Invalid argument
[gpiochip0:15] = Failed to export
sh: write error: Invalid argument
[gpiochip0:16] = Failed to export
sh: write error: Invalid argument
[gpiochip0:17] = Failed to export
sh: write error: Invalid argument
[gpiochip0:18] = Failed to export
sh: write error: Invalid argument
[gpiochip0:19] = Failed to export
sh: write error: Invalid argument
[gpiochip0:20] = Failed to export
sh: write error: Invalid argument
[gpiochip0:21] = Failed to export
sh: write error: Invalid argument
[gpiochip0:22] = Failed to export
sh: write error: Invalid argument
[gpiochip0:23] = Failed to export

Run script as:

./blink_all.sh 3s 40 44
root@Shepnet:/tmp# chmod +x blink_all.sh 
root@Shepnet:/tmp# ./blink_all.sh 3s 40 44
GPIO LED Test
Usage: ./blink_all.sh [wait time] [gpio start] [gpio end]
Example: ./blink_all.sh 3s 0 1
leave gpio range blank to test all GPIOs.

There is a blank line at the bottom of the preformatted text box. I also tried ./blink_all.sh 3s 4 16 and the Globe/Internet LED did not blink at GPIO=14. Moved the NIC from LAN4 -> LAN1. GPIO 14 persisted although I did not reboot the router.

Thanks again, I'm learning alot.

Addendum: I downloaded the RaLink MT7620 spec sheet. The chip can support up to 72 gpio's. There is a separate pin, G4, name: WLED_N, type: O, IPU Description: WLAN Activity LED.

Could the default kernel not be configured for gpio's 40 to 44?

What is result of the gpio 40-44 test? It's not clear from your message.

This part of dts-file:

&state_default {
	gpio {
		ralink,group = "i2c", "uartf", "ephy";
		ralink,function = "gpio";
	};
};

set control of "i2c" (gpio 1-2), "uartf" (7-14), "ehpy" (40-44) pins of SoC to gpio.

I double checked the dts modifications you provided in your post and rebuilt 2x.

Running ./blink_all.sh 3s 40 44 does not provide any output after "leave gpio range blank to test all GPIOs.", just an empty line. If I leave the GPIO range blank, no gpio's are detected after 23.

root@Shepnet:/tmp# ./blink_all.sh 3s 40 44
GPIO LED Test
Usage: ./blink_all.sh [wait time] [gpio start] [gpio end]
Example: ./blink_all.sh 3s 0 1
leave gpio range blank to test all GPIOs.

root@Shepnet:/tmp#

In FreeBSD, not all pins on a sound chip are utilized, some are left unconnected and I suspect that may be the case here.

The Trendnet TEW-810DR is an exact clone of the D-link DIR-810L which is already committed. I basically used the D-Link commits to build the TEW-810DR. The D-Link commit has the same issue with the "Globe/Internet" led. From this mailing list thread between 2 capable developers:
http://lists.infradead.org/pipermail/openwrt-devel/2020-March/022045.html

Hi, > *I noticed, however, that the green "Internet" LED blinks to the LAN4 port,* > *while -I guess- it should blink to the INTERNET (wan/eth0.2) port.* > *But this was already happening before, it's not related to your patch.* green internet LED is not present in the DTS (only orange WAN LED), and there is no entry for the device in 01_leds. So, the LED seems to be controlled by some driver ... Best Adrian

I thought I should make the effort to improve the LED's on the Trendnet prior to submitting.

The only result of script is LEDs blinking and no other output if no access error. Does WAN green LED blink during script execution?