Author Topic: How to turn off cubieboard leds?  (Read 16086 times)

verysofttoiletpaper

  • Guest
How to turn off cubieboard leds?
« on: August 15, 2013, 12:22:44 am »
I'm using the cubieez image with this kernel http://romanrm.ru/en/a10/kernel
This is my script.bin http://ix.io/7ij/fex
Am trying to follow this guide: http://linux-sunxi.org/Cubieboard/Programming/StatusLEDs

However I don't even have this directory: /sys/class/leds

Help appreciated since my sleep is being affected by the bright green led :P

ikeeki

  • Guest
Re: How to turn off cubieboard leds?
« Reply #1 on: August 15, 2013, 05:34:52 am »
Do not know, try deleting /etc/init.d/rc.local ----->
echo mmc0 > /sys/class/leds/blue\:ph21\:led2/trigger
if it exists...

verysofttoiletpaper

  • Guest
Re: How to turn off cubieboard leds?
« Reply #2 on: August 15, 2013, 10:32:22 am »
I don't have "/sys/class/leds" :(

Offline chris

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: How to turn off cubieboard leds?
« Reply #3 on: August 15, 2013, 10:54:10 am »

verysofttoiletpaper

  • Guest
Re: How to turn off cubieboard leds?
« Reply #4 on: August 15, 2013, 11:26:14 am »
Yes, already tried to remove that, rebooted, but the led is still on..

Offline chris

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: How to turn off cubieboard leds?
« Reply #5 on: August 15, 2013, 12:03:21 pm »
Strange. BTW, which kernel exactly are you using?
from
http://romanrm.ru/dl/a10/kernels/server-3.4/3.4.43-20130531.1334-s-rm1%2b/config-3.4.43-20130531.1334-s-rm1%2b.txt
it seems that the led driver is compiled as a module:
Code: [Select]
#
# LED drivers
#
CONFIG_LEDS_SUNXI=m
Can you check whether the driver/module is actually loaded?
A missing driver might also explain why you don't see "/sys/class/leds".
I think that I have the driver compiled into the kernel. Perhaps you can try that.

verysofttoiletpaper

  • Guest
Re: How to turn off cubieboard leds?
« Reply #6 on: August 15, 2013, 12:19:39 pm »
I'm using that exact kernel that the config.txt you mention belongs to:
http://romanrm.ru/dl/a10/kernels/server-3.4/3.4.43-20130531.1334-s-rm1%2b/

I thought script.bin wasn't being read or something, so I remove it and that way Cubieboard doesn't boot (or it boots into android, I am not sure), so the script is being read. By, the way, the green led still lights up..
I also tried setting leds_default_1 = 0 but the led doesn't turn off.


How can I check whether the driver/module is actually loaded?

Thanks

Offline chris

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: How to turn off cubieboard leds?
« Reply #7 on: August 15, 2013, 12:39:34 pm »
You can use the command "lsmod" to list all loaded modules. I think the driver is called "leds-sunxi", but I am not entirely sure. You can use the "insmod" command to manually load a module.

Perhaps you could post the output of lsmod ?
Additionally, you could take a look into the modules directory (found under "/lib/modules") to see if the module is installed at all.

verysofttoiletpaper

  • Guest
Re: How to turn off cubieboard leds?
« Reply #8 on: August 15, 2013, 12:51:33 pm »
THANK YOU!

looking in the modules folder allowed my to find leds-sunxi.ko which no-one had mentioned before

Code: [Select]
$ ll /lib/modules/3.4.43-20130531.1334-s-rm1+/kernel/drivers/leds/
total 32K
-rw-r--r-- 1 root root  11K May 31 15:43 leds-sunxi.ko
-rw-r--r-- 1 root root 6.8K May 31 15:43 leds-gpio.ko
-rw-r--r-- 1 root root 8.8K May 31 15:43 led-class.ko

After loading the module with
Code: [Select]
modprobe leds-sunxi the green led immediately turned off.

Do you know how to auto load the module on boot?

Thanks

Offline chris

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: How to turn off cubieboard leds?
« Reply #9 on: August 15, 2013, 01:18:58 pm »
THANK YOU!
You're welcome  :)
Glad I could help.

Do you know how to auto load the module on boot?

Thanks

You need to edit /etc/modules. Just add a line with the name of the module.
Code: [Select]
echo leds-sunxi >>/etc/modules

rajiv7374

  • Guest
Re: How to turn off cubieboard leds?
« Reply #10 on: November 10, 2013, 01:20:31 pm »
Hi,

I think there is a simpler way.

Check what is the current trigger for the led using the command
Code: [Select]
cat /sys/class/leds/blue:ph21:led2/triggerThe output should be similar to

none battery-charging-or-full battery-charging battery-full battery-charging-blink-full-solid ac-online usb-online mmc0 timer [heartbeat] cpu0 cpu1 default-on


Notice the brackets around the heartbeat, this is the current trigger for the led.

  • Locate the script.bin on your micro sd card. You will need to convert this into a fex file using fex2bin
  • Once you have the fex file which is an editable file. Locate the line leds_trigger_2 = "heartbeat". It maybe "mmc0" in your case.
  • You have to change the string "heartbeat" to "none". Save the file.
  • Then you have to replace the script.bin using the command fex2bin script.fex > script.bin

This way you are only changing what needs to be changed. You can turn the led back on easily with the command
Code: [Select]
echo [[trigger]] > /sys/class/leds/blue:ph21:led2/trigger
Where [[trigger]] is one of the below :-
none battery-charging-or-full battery-charging battery-full battery-charging-blink-full-solid ac-online usb-online mmc0 timer heartbeat cpu0 cpu1 default-on

Cheers!
Rajiv

Offline chris

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: How to turn off cubieboard leds?
« Reply #11 on: November 11, 2013, 06:38:40 pm »
Hi,

I think there is a simpler way ...

Cheers!
Rajiv
Dear Rajiv,
thanks for reviving this old thread.

But I think you are missing the point:
Without the the driver being loaded, there will be no  "/sys/class/leds/" directory.

Best,
Christian


verysofttoiletpaper

  • Guest
Re: How to turn off cubieboard leds?
« Reply #12 on: November 13, 2013, 03:15:33 am »
I managed to solve this a while ago. I don't remember the specifics but remember the problem was the module wasn't loaded. I don't remember how I loaded it, but I think it was a different name or something..

Offline jwzumwalt

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: How to turn off cubieboard leds?
« Reply #13 on: July 14, 2015, 08:17:28 am »
Code: [Select]
#!/bin/bash
# The following needs to be in the script.bin file
# Debian /media/zero/script.bin
# Cubian    /boot/script.bin
#
# [leds_para]
# leds_used = 1
# leds_num = 2
# leds_pin_1 = port:PH20<1><default><default><0>
# leds_name_1 = "green:ph20:led1"
# leds_pin_2 = port:PH21<1><default><default><0>
# leds_name_2 = "blue:ph21:led2"

# a module may be needed. To load...
# modprobe leds-sunxi
#
# To auto load the module just add a line with the name of the module....
# edit /etc/modules.
# or execute the following line in the /etc/modules directory
# echo leds-sunxi >>/etc/modules

# setup
echo off
clear
echo 0 > /sys/class/leds/blue\:ph21\:led2/brightness # Blue led off
echo 0 > /sys/class/leds/green\:ph20\:led1/brightness # GREEN led off

# blue on
echo 255 > /sys/class/leds/blue\:ph21\:led2/brightness # Blue led on
sleep 3
echo 0 > /sys/class/leds/blue\:ph21\:led2/brightness # Blue led off

# green on
echo 255 > /sys/class/leds/green\:ph20\:led1/brightness # GREEN led on
sleep 3
echo 0 > /sys/class/leds/green\:ph20\:led1/brightness # GREEN led off

#blue blink
echo timer > /sys/class/leds/blue\:ph21\:led2/trigger # BLUE led blink
sleep 3
echo 0 > /sys/class/leds/blue\:ph21\:led2/brightness # BLUE led off:

# green blink
echo timer > /sys/class/leds/green\:ph20\:led1/trigger # GREEN led blink
sleep 3
echo 0 > /sys/class/leds/green\:ph20\:led1/brightness # GREEN led off


echo mmc0 > /sys/class/leds/blue\:ph21\:led2/trigger # blue sd card status
echo none > /sys/class/leds/green\:ph20\:led1/trigger # GREEN led

# list triggers
cat /sys/class/leds/blue\:ph21\:led2/trigger

[/font]
« Last Edit: July 14, 2015, 08:19:44 am by jwzumwalt »