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.

This entry was posted in Alix and tagged , by twam. Bookmark the permalink.

About the author

My name is Tobias Müller. I'm interested in com­puters, physics, elec­tronics and photo­graphy. more …

27 thoughts on “LEDs on ALIX.3D3

  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. 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. 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. 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. 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.

  6. 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

  7. 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)

  8. I'm having a similar problem, except I am using OpenBSD. I can initialize the GPIO pins that the 1st and the 3rd LED's use (pins 6 and 27), but the second LED (on pin 25) is giving me grief. More specifically, as soon as I attempt to initialize it, it causes the OS to crash - no warning, no longs, no dump, just a reboot. Can you explain what your patch fixed, maybe I can try the same with my OS...

  9. Kernel kompilieren ist für mich noch alles sehr neu. Nun ich versuche mit Debian Squeeze denn auf Kernel.org - linux-2.6.38 zu patchen. Beim Patch kommt dann folgende Meldung:

    root@alix3d3:/usr/src/linux# patch -p1 < /root/leds-alix2.patch
    patching file drivers/leds/leds-alix2.c
    Hunk #1 FAILED at 14.
    Hunk #2 succeeded at 213 with fuzz 2 (offset 58 lines).
    1 out of 2 hunks FAILED -- saving rejects to file drivers/leds/leds-alix2.c.re

    Bitte um Hilfe. 🙂

  10. @sel
    Das heißt das der Patch für die aktuelle Version nicht mehr automatisch funktioniert. Du musst die Datei leds-alix2.c.re bearbeiten. Dort solltest du irgendwo zwischen <<<<>>>>> die Unterschiede zwischen den Versionen sehen. Die musst du von Hand anpassen und es dann als leds-alix2.c speichern.

  11. bei der Datei leds-alix2.c.re steht nur folgendes drin:
    --- drivers/leds/leds-alix2.c
    +++ drivers/leds/leds-alix2.c
    @@ -14,7 +14,7 @@

    static int force = 0;
    module_param(force, bool, 0444);
    -MODULE_PARM_DESC(force, "Assume system has ALIX.2 style LEDs");
    +MODULE_PARM_DESC(force, "Assume system has ALIX.2/ALIX.3 style LEDs (Needed for boards with Award BIOS)");

    struct alix_led {
    struct led_classdev cdev;

  12. Ok, dann ist der patch doch richtig?
    denn ich habe nach dem patchen 3 Datei erhalten:
    -leds-alix2.c.orig
    -leds-alix2.c
    -leds-alix2.c.re (siehe Post 16)

    In der Datei "leds-alix2.c" ist, so weit ich das gesehen habe die änderungen vorhanden.
    Ich danke dir "twam"

  13. @sel
    Ja. Er konnte die Änderung nur nicht automatisch machen, weil eben im Patch eine Änderungen an MODUL_PARM_DESC war und in der neuen Kernelversion. Daher fragt er halt.

  14. Gday Twam,

    I am a newbie, am running mpdpup on an Alix 2d2 and would like to get at least one of the leds to indicate that the alix is booted and ready to go.
    I currently have all three flash up at power on, then what is marked as D6 stays on solid. Is there a way to show when
    1, Power on
    2, System booted and ready
    3, System is streaming or active?

    I really haven't followed alot of what you said, I am new to this, but would like it to work.
    The thread is here, http://murga-linux.com/puppy/viewtopic.php?t=70052

    Thanks in advance for your assist!

    Regards,

    Drew.

  15. @Drew
    First, try to get the LEDs working with the code above. If you can manage to switch them on/off you can write simple scripts to do the job, e.g. a script which enables LED1 after boot up.

  16. Shall do, just noted that it mentions award bios, will the same code work on the tiny bios the 2d2 runs you think?

  17. twam...
    will your patch work with the 3.5.4 kernel? Also, do you have a solution for displaying lan usage as well as disk usage?

  18. @John
    I haven't tried it with a recent kernel, as I don't have the board anymore. I also don't have a tool for network usage, but this shouldn't be too problematic. Look at the source of these desktop widget providing this information and adapt it to your needs.

  19. I have a problem in my ALIX 3d3 board
    it asks me to select the file and since I am new to linux and voyage I do not know how to do at this stage

    by the way I install voyage 0.9.5
    ========================
    root@voyage:/sys/class/leds# patch -p1 < /root/leds-alix2.patch can't find file to patch at input line 5
    Perhaps you used the wrong -p or --strip option?
    The text leading up to this was:
    --------------------------
    |diff --git a/drivers/leds/leds-alix2.c b/drivers/leds/leds-alix2.c
    |index ddbd773..bda9403 100644
    |--- a/drivers/leds/leds-alix2.c
    |+++ b/drivers/leds/leds-alix2.c
    --------------------------
    File to patch:

    ======================

    • You're in the wrong directory. You have to apply the patch to the kernel sources, most likely in /usr/src/linux. Remember that this patch is for kernel 2.6.29 and might not work for more recent ones!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.