blink leds, use serial , header pins

2,736 views
Skip to first unread message

ludo...@gmail.com

unread,
Jan 19, 2013, 12:04:14 PM1/19/13
to cubie...@googlegroups.com
Hello
is someone have a exemple to do this stuff

-bliking leds
-use serial ... with header pins

I known the arduino environment and would like to do the same things

programming this in java is possible or not?



Laurent Pastor

unread,
Jan 31, 2013, 6:26:01 PM1/31/13
to cubie...@googlegroups.com
Hello,

I am interesting too.

Is there a howto to blink one of the status led on the board or to use the gpio ?

Regards

Simos Xenitellis

unread,
Jan 31, 2013, 6:53:12 PM1/31/13
to cubie...@googlegroups.com
The Wiki has some details specific to the A10,
http://linux-sunxi.org/GPIO

Then, you can read the tutorial for the RPi at
http://elinux.org/RPi_Tutorial_EGHS:LED_output

It mentions two things
1. It is very important to be careful, because the direct access to
the GPIO pins with the wrong power can damage your Cubieboard.
Normally you get a baseboard (like the one that George is creating?)
that provides some protection if you send excessive current.

2. When you attach an LED, one part goes to the GND, the other to the
GPIO. However, you must put a resistor (as shown in the above URL) in
between, so that the current does not damage the board. The page also
shows how to calculate the transistor resistance.

Now, regarding the programming, there is a Python module for GPIO and
the RPi. It might work with the Cubieboard.
Or, you can try with C. I think that with Java you would need to
investigate what it says at
http://en.wikibooks.org/wiki/Serial_Programming/Serial_Java

If someone is more knowledgable for this stuff, they can provide
instructions for a simply blink app.

Simos

Floris Bos

unread,
Jan 31, 2013, 7:05:52 PM1/31/13
to cubie...@googlegroups.com
On 02/01/2013 12:26 AM, Laurent Pastor wrote:
>Is there a howto to blink one of the status led on the board


With a recent kernel, and this added to your script.bin

==
[leds_para]
leds_used = 1
leds_num = 2
leds_pin_1 = port:PH20<1><default><default><0>
leds_name_1 = "ph20:green:led1"
leds_pin_2 = port:PH21<1><default><default><0>
leds_name_2 = "ph21:blue:led2"
==


Enable led:

echo 255 > /sys/class/leds/ph21:blue:led2/brightness

Disable led:

echo 0 > /sys/class/leds/ph21:blue:led2/brightness

Blinking led:

echo timer > /sys/class/leds/ph21:blue:led2/trigger

Use led to show SD card activity

echo mmc0 > /sys/class/leds/ph21:blue:led2/trigger

For others triggers see: cat /sys/class/leds/ph21:blue:led2/trigger

--

Yours sincerely,

Floris Bos

Simos Xenitellis

unread,
Feb 1, 2013, 4:54:54 AM2/1/13
to cubie...@googlegroups.com
This is useful for a list of first-things-to-try.
I've put this for now at
http://linux-sunxi.org/Cubieboard/Programming/StatusLEDs

Thanks,
Simos

Laurent Pastor

unread,
Feb 1, 2013, 8:17:25 AM2/1/13
to cubie...@googlegroups.com
Thank you very much for your answers Simos and Floris,

Do you know the max current per pin ?

Laurent

Laurent Pastor

unread,
Feb 1, 2013, 6:41:03 PM2/1/13
to cubie...@googlegroups.com
It's hard to start for me.

I installed : apt-get install libusb-1.0-0-dev ( like describe here : http://linux-sunxi.org/GPIO)

I installed : bin2fex and fex2bin tools from sunxi-tools.

I played fine with /sys/class/leds like describe here : http://linux-sunxi.org/Cubieboard/Programming/StatusLEDs

I edited script.bin :

[gpio_para]
gpio_used = 1
gpio_num = 7
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_pin_4 = port:PD0<0><default><default><0>
gpio_pin_5 = port:PD1<0><default><default><1>
gpio_pin_6 = port:PD2<1><default><default><0>
gpio_pin_7 = port:PD3<1><default><default><1>

[gpio_init]
pin_1 = port:PH10<1><default><default><0>
pin_2 = port:PH20<1><default><default><1>
pin_3 = port:PB03<0><default><default><default>
pin_4 = port:PD0<0><default><default><0>
pin_5 = port:PD1<0><default><default><1>
pin_6 = port:PD2<1><default><default><0>
pin_7 = port:PD3<1><default><default><1>


[leds_para]
leds_used = 1
leds_num = 2
leds_pin_1 = port:PH20<1><default><default><0>
leds_name_1 = "ph20:green:led1"
leds_pin_2 = port:PH21<1><default><default><0>
leds_name_2 = "ph21:blue:led2"

But after reboot, I don't see gpio in /sys/class to play with?

Laurent Pastor

unread,
Feb 1, 2013, 6:49:15 PM2/1/13
to cubie...@googlegroups.com
For information, I started first on Linaro, but I can't do the make for bin2fex, also now I am on Raspian.

Alakon peng

unread,
Mar 14, 2013, 2:48:37 PM3/14/13
to cubie...@googlegroups.com
do you compile the sunxi_gpio.ko ?

在 2013年2月2日星期六UTC+8上午7时41分03秒,Laurent Pastor写道:

Alexandr Shutko

unread,
Mar 15, 2013, 1:09:48 AM3/15/13
to cubie...@googlegroups.com

do you compile the sunxi_gpio.ko ?
 
With recent kernel it compiled automaticaly, but as module and should be loaded to use it.
modprobe gpio-sunxi

Andreas Kahl

unread,
Apr 1, 2013, 2:56:08 AM4/1/13
to cubie...@googlegroups.com
I have a quite similar problem:
usr@cubie:~$ echo 0 > /sys/class/leds/ph21:blue:led2/brightness
-bash: /sys/class/leds/ph21:blue:led2/brightness: No such file or directory

On my Debian ( 3.0.42+ #3 PREEMPT Thu Nov 1 17:16:53 CET 2012 armv7l GNU/Linux ) there is no /sys/class/gpio/ and no /sys/class/leds/

According to lsmod sun4i_gpio is loaded:
usr@cubie:~/linux-sunxi$ lsmod
Module                  Size  Used by
cpufreq_stats           2318  0
sun4i_gpio              2961  0
8192cu                488866  0

I checked my script.bin, too. It contains the needed leds-Section and the pins in the gpio-Section.  

Tom Cubie

unread,
Apr 1, 2013, 4:47:49 AM4/1/13
to cubie...@googlegroups.com
On Mon, Apr 1, 2013 at 2:56 PM, Andreas Kahl <akah...@googlemail.com> wrote:
> I have a quite similar problem:
> usr@cubie:~$ echo 0 > /sys/class/leds/ph21:blue:led2/brightness
> -bash: /sys/class/leds/ph21:blue:led2/brightness: No such file or directory
>
> On my Debian ( 3.0.42+ #3 PREEMPT Thu Nov 1 17:16:53 CET 2012 armv7l
> GNU/Linux ) there is no /sys/class/gpio/ and no /sys/class/leds/
>
> According to lsmod sun4i_gpio is loaded:
> usr@cubie:~/linux-sunxi$ lsmod
> Module Size Used by
> cpufreq_stats 2318 0
> sun4i_gpio 2961 0
> 8192cu 488866 0

As Alexandr posted, you need the gpio_sunxi driver loaded, the driver
name is gpio_sunxi. You can use modprobe gpio-sunxi to load it. The
sun4i_gpio is the old ugly gpio driver, not recommend to use it now.

>
> I checked my script.bin, too. It contains the needed leds-Section and the
> pins in the gpio-Section.
>
> Am Freitag, 15. März 2013 06:09:48 UTC+1 schrieb Alexandr Shutko:
>>
>>
>>> do you compile the sunxi_gpio.ko ?
>>
>>

With recent kernel it compiled automaticaly, but as module and should be
loaded to use it.
modprobe gpio-sunxi

>>
> --
> You received this message because you are subscribed to the Google Groups
> "Cubieboard" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cubieboard+...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cubieboard?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Keep simple, stay foolish.

Andreas Kahl

unread,
Apr 1, 2013, 9:30:02 AM4/1/13
to cubie...@googlegroups.com
Tom,
Thank you very much for your hints. This module seems not to be present in my Linux. Is there any documentation how to obtain/compile the module?
Is that possible without compiling the kernel?

This is what I get:
usr@cubie:/# modprobe gpio-sunxi
FATAL: Module gpio-sunxi not found.
usr@cubie:/#  find / -name gpio_sunxi*
... no hits

Puneet B

unread,
Aug 8, 2013, 2:42:50 AM8/8/13
to cubie...@googlegroups.com

I have a simple  doubt ,

If i want gpio (ex PA13 pin) as input with low level , what i need to pass.

and if i want gpio as output pin as low level what i need to pass.


Kindly clear my doubt.

Regards
Punith



Reply all
Reply to author
Forward
0 new messages