Home > Alix > LEDs on ALIX.3D3

LEDs on ALIX.3D3

LEDs on ALIX.3D3

LEDs on ALIX.3D3

As most of the ALIX boards, the ALIX.3D3 has 3 general purpose LEDs. There is kernel support for them, but there are problems when the board has a Award BUIS as the ALIX.3D3. After reading the datasheet of the AMD CS5536 Geode companion about initialisation and use of the general purpose pins I got it finally running!

There are 2 problems with Award BIOS. On the one hand it contains no parseable string referring to the board, so the auto detection of the board in driver doesn’t work and the initialisation of at least 1 LEDs is wrong. The first problem is easy to solve, by forcing the kernel to load the driver. For the second problem I wrote a small kernel patch (see Update at the end of the post): leds-alix2 kernel patch for 2.6.29

So how to get them running? First of all we need to patch the Linux kernel and then active support. Download the patch to your box and run

wget http://www.twam.info/wp-content/uploads/2009/05/led.patch -O /root/leds-alix2.patch
cd /usr/src/linux
patch -p1 < /root/leds-alix2.patch

Now run kernel configuration and select

Device Drivers  --->
   [*] LED Support  --->
      <*>   LED Class Support
            *** LED drivers ***
      <*>   LED Support for ALIX.2 and ALIX.3 series
            *** LED Triggers ***
      [*]   LED Trigger support
      <*>     LED Timer Trigger
      <*>     LED Heartbeat Trigger
      <*>     LED Default ON Trigger

compile the kernel and adjust the kernel boot line by adding leds-alix2.force=1 to force the kernel to load the driver. If you use GRUB append it to the kernel line in /boot/grub.menu.lst:

kernel /boot/vmlinuz root=/dev/sda2 lxfb.mode_option=1280x1024@60 leds-alix2.force=1

After rebooting, dmesg should show something like

[    2.819802] leds_alix2: forced to skip BIOS test, assume system has ALIX.2 style LEDs
[    2.833003] Registered led device: alix:1
[    2.845860] Registered led device: alix:2
[    2.858804] Registered led device: alix:3

and you should be able to able to switch on/off the LEDs for example by

echo 1 > /sys/class/leds/alix\:3/brightness
sleep 5
echo 0 > /sys/class/leds/alix\:3/brightness

LED 3 should lit up for 5 seconds. If it’s working it’s time to test some triggers. Try

echo heartbeat > /sys/class/leds/alix\:2/trigger

LED 2 should blink like:   pulse – short pause – pulse – long pause – pulse – short pause – …

Another trigger is timer:

echo timer  > /sys/class/leds/alix\:1/trigger
echo 1000 > /sys/class/leds/alix\:1/delay_on
echo 100 > /sys/class/leds/alix\:1/delay_on

should activate the LED for 1000ms and then switch it off for 100ms and start again. I enabled this 2 triggers and made a simple demo video:

Update: In kernel 2.6.31 the patch isn’t required anymore, as it was accepted in the mainline.

Categories: Alix Tags: ,
  1. Anders
    May 8th, 2009 at 20:28 | #1

    Very informative reading. Im trying to configure the 2.6.29-kernel for Alix too. The hardest part I guess will be to enable the hardware encryption part of the geode processor (will be a perfect match with the openvpn service I have). I would be very happy if you could do a similar tutorial about this :)

  2. May 8th, 2009 at 21:46 | #2

    Kernel support for the encryption device is very easy. The problem is that there is no included userspace interface. There are some BSD ports but I haven’t tried them yet, but I’m looking forward to do so.

  3. DevHamster
    July 27th, 2009 at 20:11 | #3

    Hi!
    Great instruction! Unfortunately it doesn’t work with my Mandriva 2007 Kernel 2.6.17-13mdv on an ALIX 3d3. I already tried your patches and from voyage (with led-support) and I also tried to run the leds via gpioctl. Nothing seems to work. When I started I get the leds-alix source and compiled it. Then I did the kernel-config and make. The problem is that I can’t load the leds-alix into the kernel b’cause some symbols found in Led Class Support (kernel config) are unknown. Now I think that the problem could be caused by hardware detection, but I don’t know how to continue.
    Do you have any idea what else I could try? Could it be possible to use this kernel (it has some things I need)?

  4. July 28th, 2009 at 07:08 | #4

    To skip hardware detection you must pass the force=1 parameter either by adding leds-alix2.force=1 to your boot line or by

    modprobe leds-alix2 forge=1

    If this has no success I recommend to update to a recent kernel. Just download the sources from kernel.org, copy your old .config and do an

    make oldconfig

    After this, you can follow the instructions above.

  5. ecraven
    September 13th, 2009 at 20:47 | #5

    works beautifully, except for the fact that led3 can’t be turned off on my alix 3d3. any way to debug this?

  6. September 14th, 2009 at 02:16 | #6

    You either need to apply the patch linked in the article or use kernel 2.6.31 (where this patch is included). Award BIOS doesn’t initialize LED 3 correctly. The patch fixes this.

  7. January 7th, 2010 at 22:35 | #7

    Thanks for this. Good information.

  8. January 27th, 2010 at 03:00 | #8

    Twam, I have built a Bike/Bike camera system using the Alix 3d2/3d3 boards. I have found your page very useful in tuning the kernel and solving some of my problems with the 3d3 LEDs. I have created a small script to control the LEDs using the GPIO interface which I would like to share here:

    #!/bin/sh
    #
    # Author: Matt Judge
    # Date: 25/01/09
    # Script: alix_led
    # Desc: Simple wrapper to the Linux GPIO interface for Alix
    # system boards.
    # Usage: alix_led
    # LED: 1, 2 or 3.
    # switch: 0=off, 1=on
    #
    # Permission is granted to copy, publish and implement this script
    # for non commercial uses provided all comment fields remain intact.
    # No fitness for purpose is implied.
    #

    # Define the LEDs
    leds=(0 6 25 27)

    # Make sure we have enough arguments and they fit the patterns
    [[ ${leds[${1}]} > 0 ]] || exit
    [ ${2:-1} -ne 0 -a ${2:-0} -ne 1 ] && exit

    # Get the value out of the array
    led=${leds[$1]}

    # Make the usage more logical (ie. 0=off, 1=on)
    val=$((($2 * -1) + 1))

    echo $led > /sys/class/gpio/export
    echo out > /sys/class/gpio/GPIO${led}/direction
    echo ${val} > /sys/class/gpio/GPIO${led}/value
    echo $led > /sys/class/gpio/unexport

  9. mykhal
    May 18th, 2010 at 01:45 | #9

    helpful info, thanks. it introduced me into ALIX LEDs..
    did you know ide-disk led trigger ? you can have LED blinking in IDE access:

    echo ide-disk > /sys/class/leds/”alix:1″/trigger

    however, i wanted my leds to blink on disk read/write separately, so i modified the kernel little bit.. more here: http://lkml.org/lkml/2010/5/17/501 (misaligned little bit, my first post there)

  1. May 17th, 2009 at 15:41 | #1