ALIX 2c3 and pfsense (LEDs)



  • Is there a way to make the lights do something with pfsense?
    in my ALIX 2c3 I have 3 front lights 1 is power there other 2 stay off…. I would like to assign one to WAN and the other to wireless...

    Thank You!



  • I believe the WRAP boards had /dev/led devices, which were created when you added the cpu_geode or the cpu_soekris options to the kernel. This doesn't work for the ALIX, perhaps due to geode.c looking for a the WRAP bios string and not the ALIX. I wondered about just changing the string and happened on this: http://www.kvedulv.de/alix-howto.html which suggests pulling geode.c from CURRENT may have ALIX support. If I have some time, I may try compiling a kernel and see if it has led support. If so, the existing code that was developed for the WRAP will probably work.

    edit:this should really be in the hardware forum…



  • I compiled a 7.0 kernel with the geode.c from CURRENT on a test box- used
    options cpu_geode
    options cpu_soekris
    Copied the kernel to my Alix running a minimal 7.0 install on CF. Rebooted.
    Now I have /dev/led/led1-3 on my Alix!
    The old Wrap tricks with echo work fine. I dug up RSW's blinkled- the binary didn't work under FreeBSD 7, but luckily he provided the source and it compiled on 7. Something like blinkled -i vr0 -l /dev/led/led2 works as expected.



  • Thanks for the reply.

    I found this on the openWRT wiki… s meant for the 2c2 but I am sure there are not much different....

    1.4. Controlling the LEDs

    Using the LEDs on the alix:

    You should get three LED devices under /sys/class/leds/

    • alix:1, alix:2 and alix:3

    This should turn on one led:
      echo 1 > /sys/class/leds/alix:1/brightness

    And off:
      echo 0 > /sys/class/leds/alix:1/brightness

    And this should make it blink:
      echo timer > /sys/class/leds/alix:1/trigger
      echo 1000 > /sys/class/leds/alix:1/delay_off
      echo 100 > /sys/class/leds/alix:1/delay_on

    I do apologize it should be in the hardware forum….



  • @dotdash:

    I compiled a 7.0 kernel with the geode.c from CURRENT on a test box- used
    options cpu_geode
    options cpu_soekris
    Copied the kernel to my Alix running a minimal 7.0 install on CF. Rebooted.
    Now I have /dev/led/led1-3 on my Alix!
    The old Wrap tricks with echo work fine. I dug up RSW's blinkled- the binary didn't work under FreeBSD 7, but luckily he provided the source and it compiled on 7. Something like blinkled -i vr0 -l /dev/led/led2 works as expected.

    That is awesome!!!
    I am using pfSense 1.2 FreeBSD 6.3 Any chance this can go in?
    It would be very useful.



  • OpenWRT is Linux, so not very helpful there.
    I wouldn't hold my breath on the changes getting backported to the 6 branch, but 1.2.1 is going to be 7 anyway.
    Note that I don't have anything very useful at this point. My kernel is pretty stock and not suited for pfSense. You would need to get the module compiled into a proper kernel. That's only going to happen when

    1. pfSense is based on a FreeBSD version with the changes (7.1?)
    2. A developer with an Alix wants flashing LEDs enough to put the new version in.
    3. Someone wants cool lights on their Alix enough to put a bounty up to get it done.
      I'll drop in a feature request to see if anyone is interested.
      edit for ticket number: http://cvstrac.pfsense.com/tktview?tn=1784


  • It makes lots of sense!
    And thanks for your fast response.


  • Rebel Alliance Developer Netgate

    I know this thread is very old, but I just thought I'd mention that I just committed a patch that should bring rev 1.11 of geode.c to the 1.2.3-RC snapshots.

    At least it's a step in the right direction for ALIX users, the LEDs should at least have hardware support now.

    As of right now (11:56PM EDT June 18th, 2009) a new snapshot hasn't happened yet, so if you want to test, wait for the next snapshot after that date/time.


  • Rebel Alliance Developer Netgate

    @dotdash:

    1. A developer with an Alix wants flashing LEDs enough to put the new version in.

    That did it.

    Must. Have. Blinkenlights.  :o




  • Rebel Alliance Developer Netgate


  • Rebel Alliance Developer Netgate

    Ok, I fixed the patch and committed again. Not sure when the next snapshot will be due.

    I've got one building on my own builder, too, so if mine finishes first (unlikely) I'll test it on my ALIX and report what I found.



  • jimp,

    Thank you very much!

    Do you know how I can get them tide up one for networking and one for HDD led….

    Must see blinking leds  :o


  • Rebel Alliance Developer Netgate

    @serialdie:

    jimp,

    Thank you very much!

    Do you know how I can get them tide up one for networking and one for HDD led….

    Must see blinking leds  :o

    Not sure about that part yet. I have a new image built, but I haven't tried it yet, I'm chasing a different problem down at the moment.


  • Rebel Alliance Developer Netgate

    Well I'm still not sure how to assign the LEDs various tasks, but I can tell you the patch worked

    My middle light is blinking, not sure what that is indicating, but it's blinking… which is better than off :-)


  • Rebel Alliance Developer Netgate

    Various cool things to do:

    On

    echo 1 > /dev/led/led3

    Off

    echo 0 > /dev/led/led3

    Fast blink

    echo f > /dev/led/led3

    Slow blink

    echo f9 > /dev/led/led3

    (Works with any number from 1-9 or blank)

    Morse code

    echo "m…---..." > /dev/led/led3

    I use led3 in this example but it works with 1-3.

    Still not sure how I'll tie them to things or make them generally useful, but I'm open to ideas. (I don't know if they can be tied to network activity or not, doesn't look like it, but we'll see)


  • Rebel Alliance Developer Netgate



  • Jimp,

    Maybe you can add what dotdash did which was add RSW's blinkled-…

    That would work! :)


  • Rebel Alliance Developer Netgate

    @serialdie:

    Jimp,

    Maybe you can add what dotdash did which was add RSW's blinkled-…

    That would work! :)

    If I can get a link to the source, perhaps. I couldn't find it with a quick Google search.



  • jimp,

    I PM dotdash to see if he shares the source code…
    Lets see how it goes.

    TIA!


  • Rebel Alliance Developer Netgate

    I found it here on the forum:
    http://forum.pfsense.org/index.php/topic,3454.msg21194.html#msg21194

    I'll keep experimenting.


  • Rebel Alliance Developer Netgate

    It still compiles and runs for me, I've got LED2 showing my WAN activity and LED3 showing my ath0 activity.

    It would still need some kind of a user interface to configure, I'll have to see if I can whip something up.



  • jimp,

    Thats great!!!!

    Lets see how it works out!

    Thanks!



  • Just grabbed a new image and loaded it on an Alix. The /dev/led devices are there and working- thank you Jim. I couldn't find blinkled, but that may not be in the build yet. Anyway, here are my two cents as to some handy options for the LEDs.

    1. Use an LED as a 'ready' or 'armed' light. Helpful when you are working with a remote end user. I did something like this by putting a script to light LED2 in  /usr/local/etc/rc.d/ and appending a command to turn it off in /etc/rc.shutdown (kind of a hack).
    2. Activity for an interface. RSW's blinkled works well for this eg- blinkled -i ath0 -l /dev/led/led3
    3. VPN linkup. I'd like to be able to do this with IPSec (like on a PIX or something), but I'm not sure how to go about it. Just putting it out there.
    4. Blink an LED on active alert. I believe this was done with WRAPs at some point, but I never had a WRAP to test with.
    5. A simple gui would be cool, enumerate the led devices and provide a menu with some stock options or a custom script.
      These are only suggestions, I'm happy just to have the led devices now. I can do more testing on this if you need it.

  • Rebel Alliance Developer Netgate

    dotdash,

    Good to hear it's working for you, too. I have locally compiled blinkled and have it working, though it will take a little time before I can get any kind of gui going. blinkled is not currently in pfSense anywhere, but if I can get it working with a UI I'm sure it will find its way in.

    I doubt it would be a good candidate for a change that would make it into 1.2.3, but 2.0 may only be a couple months away at this point, depending on progress.

    I think LED2 already does blink on an active alert, but a slow blink. I'd like something more like you see with: echo 'm…---...' > /dev/led/led3

    As long as I know blinkled works for people and doesn't cause any undue load issues, I'll carry on. It seems to work fine on my ALIX and I have yet to see top say it uses more than 0.00% cpu :)



  • @jimp:

    I think LED2 already does blink on an active alert, but a slow blink. I'd like something more like you see with: echo 'm…---...' > /dev/led/led3

    Ah, yes it does. I probably should have tested that first. Enabling ssh is an easy way to trigger an alert.
    This appears to be defined in /etc/inc/notices.inc:
    function close_notice($id) {
           global $notice_path;
           require_once("util.inc");
           /* soekris /
           if(file_exists("/dev/led/error"))
                   exec("/bin/echo 0 > /dev/led/error");
           /
    wrap */
           if(file_exists("/dev/led/led2"))
                   exec("/bin/echo 0 > /dev/led/led2");
           $ids = array();
           if(!$notices = get_notices()) return;
           if($id == "all") {
                   unlink_if_exists($notice_path);
                   return;
           }
           foreach(array_keys($notices) as $time) {

    (Oops, that's the off stanza. The on is sending /bin/echo f5 > /dev/led/led2)

    Just verified /dev/led/error on a net5501 blinks the same as the Alix on an echo f5, so I'm not sure why the Soekris just gets a solid light and the Alix gets a blink.



  • I try to compile it my self in my pfsense box and it error out with a bunch of errors….

    
    # gcc blinkled.c -lkvm -o blinkled
    blinkled.c:9:23: error: no include path in which to search for sys/types.h
    blinkled.c:10:24: error: no include path in which to search for sys/socket.h
    blinkled.c:11:20: error: no include path in which to search for net/if.h
    blinkled.c:12:23: error: no include path in which to search for arpa/inet.h
    blinkled.c:13:24: error: no include path in which to search for netinet/in.h
    blinkled.c:15:24: error: no include path in which to search for net/if_var.h
    blinkled.c:17:23: error: no include path in which to search for net/pfvar.h
    blinkled.c:18:17: error: no include path in which to search for kvm.h
    blinkled.c:19:19: error: no include path in which to search for fcntl.h
    blinkled.c:20:19: error: no include path in which to search for nlist.h
    blinkled.c:21:23: error: no include path in which to search for sys/queue.h
    blinkled.c:22:19: error: no include path in which to search for stdio.h
    blinkled.c:23:20: error: no include path in which to search for string.h
    blinkled.c:24:20: error: no include path in which to search for limits.h
    blinkled.c:25:20: error: no include path in which to search for unistd.h
    blinkled.c:27: error: array type has incomplete element type
    blinkled.c:29: error: 'NULL' undeclared here (not in a function)
    blinkled.c: In function 'main':
    blinkled.c:52: error: storage size of 'sa' isn't known
    blinkled.c:58: warning: incompatible implicit declaration of built-in function 'fprintf'
    blinkled.c:58: error: 'stderr' undeclared (first use in this function)
    blinkled.c:58: error: (Each undeclared identifier is reported only once
    blinkled.c:58: error: for each function it appears in.)
    blinkled.c:72: warning: incompatible implicit declaration of built-in function 'fprintf'
    blinkled.c:78: warning: incompatible implicit declaration of built-in function 'fprintf'
    blinkled.c:82: error: 'F_OK' undeclared (first use in this function)
    blinkled.c:84: warning: incompatible implicit declaration of built-in function 'fprintf'
    blinkled.c:93: error: 'O_WRONLY' undeclared (first use in this function)
    blinkled.c:95: warning: incompatible implicit declaration of built-in function 'fprintf'
    blinkled.c:98: error: 'STDIN_FILENO' undeclared (first use in this function)
    blinkled.c:99: error: 'STDOUT_FILENO' undeclared (first use in this function)
    blinkled.c:100: error: 'STDERR_FILENO' undeclared (first use in this function)
    blinkled.c:110: warning: incompatible implicit declaration of built-in function 'memset'
    blinkled.c:110: error: invalid application of 'sizeof' to incomplete type 'struct sigaction' 
    blinkled.c:113: error: 'SIGTERM' undeclared (first use in this function)
    blinkled.c:115: warning: incompatible implicit declaration of built-in function 'fprintf'
    blinkled.c:118: error: 'SIGINT' undeclared (first use in this function)
    blinkled.c:120: warning: incompatible implicit declaration of built-in function 'fprintf'
    blinkled.c:126: warning: incompatible implicit declaration of built-in function 'fprintf'
    blinkled.c:136: warning: incompatible implicit declaration of built-in function 'fprintf'
    blinkled.c:142: warning: incompatible implicit declaration of built-in function 'sprintf'
    blinkled.c:147: warning: incompatible implicit declaration of built-in function 'sprintf'
    blinkled.c:155: warning: incompatible implicit declaration of built-in function 'sprintf'
    blinkled.c:160: warning: incompatible implicit declaration of built-in function 'printf'
    blinkled.c: In function 'sigterm':
    blinkled.c:167: error: 'SIG_IGN' undeclared (first use in this function)
    blinkled.c: In function 'getifstats':
    blinkled.c:174: error: storage size of 'ifh' isn't known
    blinkled.c:180: error: storage size of 'ifc' isn't known
    blinkled.c:182: error: 'kvm_t' undeclared (first use in this function)
    blinkled.c:182: error: 'kd' undeclared (first use in this function)
    blinkled.c:183: error: 'ssize_t' undeclared (first use in this function)
    blinkled.c:183: error: expected ';' before 'n'
    blinkled.c:184: error: '_POSIX2_LINE_MAX' undeclared (first use in this function)
    blinkled.c:186: error: 'O_RDONLY' undeclared (first use in this function)
    blinkled.c:189: warning: incompatible implicit declaration of built-in function 'fprintf'
    blinkled.c:189: error: 'stderr' undeclared (first use in this function)
    blinkled.c:194: warning: incompatible implicit declaration of built-in function 'fprintf'
    blinkled.c:200: warning: incompatible implicit declaration of built-in function 'fprintf'
    blinkled.c:204: error: 'n' undeclared (first use in this function)
    blinkled.c:207: warning: incompatible implicit declaration of built-in function 'fprintf'
    blinkled.c:211: warning: assignment makes pointer from integer without a cast
    blinkled.c:211: error: 'if_list' undeclared (first use in this function)
    blinkled.c:211: warning: assignment makes pointer from integer without a cast
    blinkled.c:213: error: 'u_long' undeclared (first use in this function)
    blinkled.c:213: error: expected ')' before 'ifp'
    blinkled.c:216: warning: incompatible implicit declaration of built-in function 'fprintf'
    
    

    Any pointers will be greatly appreciated!

    Thank You.


  • Rebel Alliance Developer Netgate

    Does that FreeBSD box have all of the FreeBSD sources and includes present?

    Seems weird that it wouldn't work. I compiled it from my pfSense builder box (RELENG_7_2) and it worked fine.



  • ooo mhhhh I dont think so… This is a production pfsense box... Is there a VMware image of the builders image?

    Thank you!


  • Rebel Alliance Developer Netgate

    This is easier:

    /etc/rc.conf_mount_rw
    fetch -o /usr/local/bin/blinkled http://the-ori.org/pfs/blinkled
    chmod a+x /usr/local/bin/blinkled
    /etc/rc.conf_mount_ro
    rehash
    

    I'll see about getting a package or something built, but it will be a couple days unless things clear up. Things are have been a little busy at work/home.



  • jimp,

    Thank you very much!


  • Rebel Alliance Developer Netgate

    I know it's been a while but I do have some updates:

    #1: I'm going to be adding some LED stuff to 2.0. Stuff that won't/can't make it into 1.2.3 because it will have to be in system files and not in a package.

    #2: I did just add a blinkled package that will work on the 1.2.3-RC nanobsd images. It works for me, so give it a try. After installing the package, go to Interfaces -> Assign LEDs. Should be self-explanatory from there.



  • Hmm, just installed and not working here.
    Nothing blinks and service remains stopped after I attempt to start it.
    I have 1.2.3RC2 build from Jun 16.
    The configuration is : enable both leds and assign led2 to wan and led3 to wifi.
    Where should I look for logs?


  • Rebel Alliance Developer Netgate

    @matrix200:

    Hmm, just installed and not working here.
    Nothing blinks and service remains stopped after I attempt to start it.
    I have 1.2.3RC2 build from Jun 16.
    The configuration is : enable both leds and assign led2 to wan and led3 to wifi.
    Where should I look for logs?

    There are no logs, not yet. It's only the first attempt at getting the package working. I'll polish it up some more over the next few days as I get time.

    I only tested it on a nanobsd 2.0 snapshot from this past week.

    So you checked the main enable box, the box for each led, and assigned them both?

    I'm not sure if the service status works yet, it errors out for me so far. Try going to Diagnostics > Command, and type:

    ps xa | grep blinkled
    

    It works for me, and even starts back up after a reboot.



  • Yes, I have enabled both leds and checked the main enable box.
    The process doesn't seem to be running when I try using ps aux | grep blink
    Is there a way to run it manually from ssh shell?
    Also I don't have led device in the dev folder.
    Maybe 1.2.3RC2 from jun16 doesn't have the drivers for that?

    Just one  more thing I forgot to mention :
    I am running a regular full version (not nanobsd or embedded).

    Ok one more update :)
    I was able to run the blinkled from the ssh and here is an error message that I got :
    Error: Unable to access led


  • Rebel Alliance Developer Netgate

    You may not have a new enough build. I added the patch on about June 22nd to add support for ALIX LEDs.



  • Yeah looks like it,
    Can you recommend a specific build known not to cause too many problem but is recent enough?
    I am kinda hestitant to install a new snapshot with all those horror stories about the latest build breaking everything etc :)

    Ok nevermind I went ahead and installed the latest snapshot and the led package works now:)
    One thing I don't understand though.
    When I do pinging say my wireless client from the pfsense nothing blinks.
    When I start browsing from the wireless client it does blink.
    Is pinging not enough for the light to start blinking?


  • Rebel Alliance Developer Netgate

    I haven't really looked at the source code for the blinkled program itself. It may ignore traffic until it passes a certain threshold.



  • Very nice, thanks Jimp. It's working fine on my test rig. One thought- maybe move the alert to LED1 and return the state to on, instead of using LED2, then turning it off when the alert is cleared? This would leave LED2 and LED3 free for blinkled.


  • Rebel Alliance Developer Netgate

    @dotdash:

    Very nice, thanks Jimp. It's working fine on my test rig. One thought- maybe move the alert to LED1 and return the state to on, instead of using LED2, then turning it off when the alert is cleared? This would leave LED2 and LED3 free for blinkled.

    That's my intent after the code settles for a bit.


Log in to reply