Led command

All about firmwares for routers. Support for RouterTech firmwares is here too.
Locked
User avatar
thechief
RouterTech Team
RouterTech Team
Posts: 12067
Joined: Wed Feb 01, 2006 10:22 pm
Location: England, the Centre of Africa
Contact:

Led command

Post by thechief » Fri Jul 23, 2010 10:31 am

This is a brief readme for the Led command in the RouterTech firmwares.

The Led command can be used to activate Led configurations that are defined by the active led.conf file. The led.conf file defines a set of modules used to control the Leds on the outside of the router. Each module has a number of states, for example

Code: Select all

module = usb    #
state   = 0     # 0 = link down
gpio    = 12    # USB LED
mode    = 0     # 0 = off

state   = 1     # 1 = link up
gpio    = 12    # USB LED
mode    = 1     # 1 = on

state   = 2     # 2 = pkt rcv
gpio    = 12    # USB LED
mode    = 2     # 2 = blinkoff
param1  = 100   # blink rate in ms

state   = 3     # 3 = pkt xmit
gpio    = 12    # USB LED
mode    = 2     # 2 = blinkoff
param1  = 100   # blink rate in ms
Each state is associated with a "general purpose input/output" (GPIO) connection to the processor and the mode is what this led connection does when the state is activated. The GPIOs are handled by the Linux kernel, but the led configuration program ledcfg and the led manipulation tool Led are "userspace" applications that communicate using a /proc interface to the kernel. For example, with this configuration, you can switch the usb led on with

Code: Select all

Led usb 1
and off again with

Code: Select all

Led usb 0
NOTE that attempting to take control of an led that is under active control of another program may result in no effect, or, in the worst case, a router crash.

The RouterTech firmware does not automatically control led modules such as "power" or "status", so these are free to be controlled by the Led command.

NOTE also that, sometimes, the ADSL leds are defined in the led.conf file, but are actually hard-wired to the DSP chip. In such cases, they are likely not be controllable with the Led command.

Custom led.conf files can be loaded using

Code: Select all

ledcfg -f myfile.conf
but this cannot reconfigure active modules, and is likely not to have the same effect as led.conf files loaded at startup.

Custom led.conf files can be configured using a local minix (/nvram) directory using

Code: Select all

setenv led_conf /nvram/myled
If attempting to determine correct GPIO assignments by trial and error, please be aware that activating a particular GPIO may have the same effect as pressing the reset button (i.e., it will reset the firmware to factory defaults). Others may affect the serial console or Ethernet/Switch devices. In short, experiment with GPIOs at your own peril.

The following script can be used to perform a test of GPIOs

Code: Select all

#!/bin/sh
if [ "$1" = "" ]; then
    echo "Usage $0 GPIO_Number"
    exit
fi

CNF=/var/tmp/ledtest.conf   

cat >$CNF<<EOF
module = test
state   = 0     
gpio    = $1
mode    = 0     # 0 = off

state   = 1
gpio    = $1
mode    = 1     # 1 = on

state   = 2     
gpio    = $1   
mode    = 2     # 2 = blinkoff
param1  = 50    # blink/flash rate in ms

state   = 3     
gpio    = $1   
mode    = 3     # 3 = blinkon
param1  = 50    # blink/flash rate in ms

state   = 4     
gpio    = $1   
mode    = 4     # 4 = Flash
param1  = 100   # flash on duration in ms
param2  = 200   # flash off duration in ms

EOF

/sbin/ledcfg -f $CNF
LED=/usr/bin/Led

for i in 1 2 0 3 4 ; do
    echo "Testing GPIO $1 mode = $i"
    $LED test $i
    sleep 2
done
This creates a led conf file defining a module "test", activates it, and then tests all the configured modes with 2 second gaps.

Results of using this script on a Linksys ADSL2MUE, GPIO:
11 is the same as the reset button - resets to defaults
19 crashed the serial console interface
28 crashed the Ethernet ssh session
The Chief: :afro: Be sure to read the Firmware FAQ and do a Forum Search before posting!
No support via PM. Ask all questions on the open forum.
Locked