Power on button and usage of status LEDs

2,686 views
Skip to first unread message

Laszlo Vagasi

unread,
Dec 20, 2012, 7:24:14 PM12/20/12
to cubie...@googlegroups.com
Hi All,

I try to make use of the status LEDs on Cubieboard.
I added the following lines to my script.fex/script.bin file:
[gpio_para]
gpio_used = 1
gpio_num = 2
gpio_pin_1 = port:PH21<1><default><default><1>
gpio_pin_2 = port:PH20<1><default><default><0>

[gpio_init]
pin_1 = port:PH21<1><default><default><1>
pin_2 = port:PH20<1><default><default><0>

According to the information I currently have the above lines should set the port  pins where the LEDs are connected to output and light one of them. Unfortunately none of the  LEDs are lit.
What is missing?

It would also be nice to make use of these LEDs by the kernel (ie. Heartbeat, storage access, etc). Can it be done?

On the schematic I see that the power on button is connected to the poweron input of the PMIC. What is the use of it? My board starts right after the power cord is connected.

Thanks for your kind help in advance.

Best regards,
Laszlo

Henrik Nordström

unread,
Dec 21, 2012, 5:01:19 PM12/21/12
to cubie...@googlegroups.com
tor 2012-12-20 klockan 16:24 -0800 skrev Laszlo Vagasi:

> According to the information I currently have the above lines should
> set the port pins where the LEDs are connected to output and light
> one of them. Unfortunately none of the LEDs are lit.
> What is missing?

Have you loaded the gpio driver?

> It would also be nice to make use of these LEDs by the kernel (ie.
> Heartbeat, storage access, etc). Can it be done?

Yes, with some coding.

> On the schematic I see that the power on button is connected to the
> poweron input of the PMIC. What is the use of it? My board starts
> right after the power cord is connected.

You can shut down the board with the power button, and power it back on
later.

You can also use the button to resume from suspend.

It is also possinble that in future we add a flag to u-boot to act
differently if booted by poweron or booted by power button.

Regards
Henrik

Jose Angel López Otero

unread,
Dec 23, 2012, 1:25:41 PM12/23/12
to cubie...@googlegroups.com
You must compile kernel with "CONFIG_SUN4I_GPIO_UGLY=m" option. This compilation will generate a module named sun4i_gpio.ko
With those lines you described in script.bin and module loaded you can set/clear leds by invoking

Set:
echo 1 >  /sys/devices/virtual/misc/sun4i-gpio/pin/ph20
echo 1 >  /sys/devices/virtual/misc/sun4i-gpio/pin/ph21

Clear:
echo 0 >  /sys/devices/virtual/misc/sun4i-gpio/pin/ph20
echo 0 >  /sys/devices/virtual/misc/sun4i-gpio/pin/ph21

Regards

regr...@shutko.ru

unread,
Dec 23, 2012, 8:50:24 PM12/23/12
to cubie...@googlegroups.com
I got cubie two day ago, installed lunaro (network speed was 12.5Kb/sec), updated hwpack and got normal network speed (latest hwpack doesn't work - stopped after "<6>Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled" line so I used 20121204-1829

I tried to git source/compile hwpack and got bunch of errors like 
"/u-boot-sunxi/common/stdio.c:244: undefined reference to `serial_putc'"

Is there another way to download and insmod gpio driver ?

Laszlo Vagasi

unread,
Dec 24, 2012, 5:22:54 AM12/24/12
to cubie...@googlegroups.com
Hi Jose,

Thanks for your kind help.
This way I could make my LEDs working.
(The A10 GPIO driver seems to be on a different place that I expected.)

Thanks and regards,
Laszlo

regr...@shutko.ru

unread,
Dec 27, 2012, 9:39:20 PM12/27/12
to cubie...@googlegroups.com
Ok, I compiled kernel with sun4i_gpio module but can't modprobe it because of:
"sun4i_gpio_init script_parser_fetch "gpio_para" "gpio_used" error"

I mounted /dev/nanda, uncompiled script.bin and found this:

[gpio_para]
gpio_used = 1
gpio_num = 3
gpio_pin_1 = port:PH10<1><default><default><0>
gpio_pin_2 = port:PH20<1><default><default><1>
gpio_pin_3 = port:PB03<0><default><default><default>

[gpio_init]
pin_1 = port:PH10<1><default><default><0>
pin_2 = port:PH20<1><default><default><1>

So script.bin contains gpio defines, but driver complains about it. What I'm doing wrong ? Should I place script.bin on sd card ?

Laszlo Vagasi

unread,
Dec 28, 2012, 1:16:41 AM12/28/12
to cubie...@googlegroups.com
Hi,

You should modify that lines in script.bin, since they are for a different board and those GPIO pins are used for different purposes on Cubieboard. Please have a look at my previous post for the pins for the two LEDs.
If you need additional pins for other purposes please cross check the scematic as a reference.

I hope it help.
Best regards,
Laszlo

regr...@shutko.ru

unread,
Dec 28, 2012, 8:09:00 AM12/28/12
to cubie...@googlegroups.com
[Solved] Finally I found a bug. I changed script.bin at /dev/nanda, but linux kernel use script.bin from /dev/mmcblk0p1 partition. I changed it and both leds (blue and green) works... :)


You should modify that lines in script.bin, since they are for a different board and those GPIO pins are used for different purposes on Cubieboard. Please have a look at my previous post for the pins for the two LEDs.
If you need additional pins for other purposes please cross check the scematic as a reference.

Anton Bondar

unread,
Jan 5, 2013, 4:51:31 AM1/5/13
to cubie...@googlegroups.com
Hi Jose!

You must compile kernel with "CONFIG_SUN4I_GPIO_UGLY=m" option. This compilation will generate a module named sun4i_gpio.ko
With those lines you described in script.bin and module loaded you can set/clear leds by invoking...

Am I right, that kernel is "uImage" file located on first partition?
How to compile it ? (where to take source files and what command to use to compile it)?
I'm using debian wheezy and want thouse led to be controlled too. (one for successfull boot, the other when device is accessed via HTTP)

Anton Bondar

unread,
Jan 6, 2013, 2:58:29 AM1/6/13
to cubie...@googlegroups.com
Okay!
I have figured out how to do it myself :)
A lot of googling and some instructions for A13 helped me.
Compiled kernel for the first time in my life, and it works!

Thx

Michal Suchanek

unread,
Jan 6, 2013, 1:07:49 PM1/6/13
to cubie...@googlegroups.com
Hello,
This works just fine.

Is there some place to look for info how to make these pins recognized
as leds by kernel so that they can be used as hdd trigger sink or
such?

Thanks

Michal

Michal Suchanek

unread,
Jan 6, 2013, 7:58:01 PM1/6/13
to cubie...@googlegroups.com
On 21 December 2012 23:01, Henrik Nordström <hen...@henriknordstrom.net> wrote:

>> On the schematic I see that the power on button is connected to the
>> poweron input of the PMIC. What is the use of it? My board starts
>> right after the power cord is connected.
>
> You can shut down the board with the power button, and power it back on
> later.

No, the power button does nothing in Linux.

It does power down the pre-installed image, though.

Thanks

Michal

István Nagy

unread,
Jan 7, 2013, 4:37:34 AM1/7/13
to cubie...@googlegroups.com
Sorry for hijacking the thread but speaking about GPIO. How fast i can toogle a GPIO pin? Is it possible to generate a 100Mhz signal with just software toggling a PIN? :D

Anton Bondar

unread,
Jan 7, 2013, 5:48:20 AM1/7/13
to cubie...@googlegroups.com


No, the power button does nothing in Linux.

It does. At least on debian. I can power off board with holding this button for several seconds.
But yes, it will be just power cut, not correct signal for linux kernel, that I would like to suspend 

Ulisses Montenegro

unread,
Jan 7, 2013, 6:03:58 AM1/7/13
to cubie...@googlegroups.com
If the button state is avaiable through GPIO then writing a driver or even a userland polling daemon to perform a graceful shutdown should be pretty straightforward.


--
You received this message because you are subscribed to the Google Groups "Cubieboard" group.
To unsubscribe from this group, send email to cubieboard+...@googlegroups.com.
Visit this group at http://groups.google.com/group/cubieboard?hl=en.
 
 



--
“If debugging is the process of removing software bugs, then programming must be the process of putting them in.” - Edsger Dijkstra

Michal Suchanek

unread,
Jan 7, 2013, 6:59:39 AM1/7/13
to cubie...@googlegroups.com
I am runnning Debian and holding the power button does nothing at all.

Perhaps there is some non-default configuration required or an
userspace component.

I just built a kernel and put a system to SD card with deboootstrap.

In the preinstalled image it triggers SysRq so it is definitely
something non-standard.

Thanks

Michal

Michal Suchanek

unread,
Jan 7, 2013, 5:30:10 PM1/7/13
to cubie...@googlegroups.com
On 7 January 2013 12:59, Michal Suchanek <hram...@gmail.com> wrote:
> On 7 January 2013 11:48, Anton Bondar <an...@zebooka.com> wrote:
>>
>>
>>> No, the power button does nothing in Linux.
>>
>>
>> It does. At least on debian. I can power off board with holding this button
>> for several seconds.
>> But yes, it will be just power cut, not correct signal for linux kernel,
>> that I would like to suspend
>
> I am runnning Debian and holding the power button does nothing at all.
>

OK, it does.

It takes about 2-3s to power on the board, about twice as long to
power down the pre-installed image and about half as long again to
power down recent sunxi Linux kernel with the button.

So when expecting reaction within the timeframe there is response from
the previous kernel - it does nothing.

Thanks

Michal

regr...@shutko.ru

unread,
Jan 7, 2013, 8:51:46 PM1/7/13
to cubie...@googlegroups.com
Browsing a git I found a "not ugly" GPIO driver located at https://github.com/linux-sunxi/linux-sunxi/tree/babd66aa16e09942ac4c92ecc7cf740df92b905b/drivers/misc/sunxi_gpio

I tested it and found it "ugly" again :( Interface is not linux standart /dev/class/gpio - they put it under /dev/class/gpio_aw (why ?????)
it use script.bin section [gpio] and two (fixed) records gpio_aw_first = port:XXXXxxxxxxxxx/gpio_aw_second = port:XXXXxxxxxxxxx

Code commented badly - partly english, partly chinese. :((

Ershov Sergey

unread,
Jan 15, 2013, 6:15:41 AM1/15/13
to cubie...@googlegroups.com
Good day,
prompt schematic diagram for connection LED on Cubieboard (resistor, GPIO number and the rest).

--
You received this message because you are subscribed to the Google Groups "Cubieboard" group.
To unsubscribe from this group, send email to cubieboard+...@googlegroups.com.
Visit this group at http://groups.google.com/group/cubieboard?hl=en.
 
 



--
Ershov Sergey

wiwat arun

unread,
Feb 12, 2013, 10:03:23 AM2/12/13
to cubie...@googlegroups.com
Hi Jose Angel Lo'pez Otero:

     Could you please explain how to generate sun4i_gpio.ko 

thank 
Wiwat A.

Clinton Lee Taylor

unread,
Feb 13, 2013, 12:17:54 PM2/13/13
to cubie...@googlegroups.com
Greetings ...


On Tuesday, February 12, 2013 5:03:23 PM UTC+2, wiwat arun wrote:
     Could you please explain how to generate sun4i_gpio.ko 
Short answer, use a Distro that has this build into the kernel already.  I have build my Cubie Distro form basic Debian with plenty of instructions from 


There is also details on how to compile your own kernel. Or for Debian, just use the kernel that Roman has compiled and put up.

Thanks
Mailed
LeeT
Reply all
Reply to author
Forward
0 new messages