OpenWrt Forum Archive

Topic: [HowTo][DIR-300] Fix to use the WiFi LED instead of Status LED

The content of this topic has been archived on 19 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I have no idea why is it like this, but it is. In 8.09.2 and 10.03.1-rcX when wifi is on, the wrong LED blinks. Instead of the wifi one, the status led blinks like crazy.

I am pretty sure it looks exactly the same on all DIR-300's

GPIO 7 -- status led
GPIO 2 -- wifi led

I was quite intrigued why is it like this, but haven't found out - must be a typo in source code or something?
Anyway, I am quite pleased to say that I found the way to fix it and make it use the proper LED. It's a bit trickier than saving one value to a config file. Here's what to do:

1. Add softled=0 to your wireless config. This disables the use of our status LED (if set to 1, Enables software based LED control in the driver --  source: http://wiki.openwrt.org/doc/uci/wireless) --this point is important if you are using mmc-over-gpio because it prevents the wrong LED from lighting up at all on bootup - therefore you can be sure your memory card is safe. Without this, after doing just the second step, the driver automatically lights up the status led in early boot and _then_ switches to the proper one - we don't want this, better safe than sorry--
This can be done by entering:

uci set wireless.wifi0.softled=0
uci commit wireless

2. The next step actually changes the used LED (GPIO) and enables what we just disabled in previous step (let there be light again!).
Add the following two lines to your /etc/sysctl.conf file

dev.wifi0.ledpin=2
dev.wifi0.softled=1

After rebooting, the status led won't light up at all. The wifi led will light up a little later than the status led lit up usually, but that is a minor detail and will function normally.

A little more info:
You can check how it works without rebooting your router. Just enter:

sysctl -w dev.wifi0.ledpin=2
sysctl -w dev.wifi0.softled=1
gpioctl dirout 2

The last line isn't really necessary but it speeds up the process (for some reason GPIO2 is set to dirin by default, it also somehow automatically changes after bootup)

Different softled settings:

dev.wifi0.softled=0    # softled and LED is always off
dev.wifi0.softled=1    # This is the default. LED blinks when device athX is "up" and transmitting or receiving data. LED is off when device athX is "down" or madwifi module is unloaded.
dev.wifi0.softled=2    # LED keeps staying ON (no blinking at all!) when device athX is in status "up", and LED is off when device athX is "down".

Hope this helped, cheers smile

EDIT: Since some people asked "What about the status LED if I'm not using mmc-over-gpio? Is there a way to make it shine again"?
The answer is sure;

You can also control that LED as you wish, e.g. let it light up when the router can ping some address and turn it off when there's no Internet access, or even let it blink, if you know some basic linux scripting/bash smile

I'm not sure thought that openwrt's cron supports "on boot"/"on login" tasks, so you can write a simple script and put it in /etc/init.d

#!/bin/bash
gpioctl dirout 7 && gpioctl set 7

call it "stled" or something, then

chmod +x stled

, add a symlink to that file in rc.d folder

ln -s stled ../rc.d/S99stled

and voila, and it will run every time you boot your DIR-300. Fairly easy smile

(Last edited by dark_skeleton on 25 Nov 2011, 00:09)

Has anyone submitted a bug ticket for this .. problem?

Can someone create a ticket defining the issue, and code change that may address it?

So that is will end in trunk ..

(Last edited by david6 on 15 Dec 2011, 08:37)

The discussion might have continued from here.