How to use GPIO with Lubuntu For BananaPi v2.0

9 7253
Post Last Edited by tony_zhang at 2014-6-12 00:12


I try to use GPIO with this new release, but no result.
I try :
  1. root@Bananapi:~# gpio
  2. Which pin do you want to use (PD?) :11
  3. OK,please enter "open" or "close" to open or close this pin:open
  4. Open successed!
  5. root@Bananapi:~#
Copy the Code
but the pin 11 (IO-0) doesn't go to a high state.
I don't find a help or man for gpio.
So how can I use gpio ?

Reply 1# Phi___

I just open the PH21 and PH24 in script.bin... You can add another PIN into the script.bin.  And we just now test gpio through /sys/class/gpio...
You can refer to
And the gpio command you use is ???

Perfect, I modify the script.bin file to enable the other IO.
Here the script.bin file :
the mod near the line 295 in the .fex file :
  1. [gpio_para]
  2. gpio_used = 1
  3. gpio_num = 8
  4. gpio_pin_1 = port:PH20<1><default><default><1>
  5. gpio_pin_2 = port:PH24<1><default><default><1>
  6. gpio_pin_3 = port:PI19<1><default><default><1>
  7. gpio_pin_4 = port:PH2<1><default><default><1>
  8. gpio_pin_5 = port:PI18<1><default><default><1>
  9. gpio_pin_6 = port:PI17<1><default><default><1>
  10. gpio_pin_7 = port:PH21<1><default><default><1>
  11. gpio_pin_8 = port:PI16<1><default><default><1>
Copy the Code

In use :

I use the pin 11 => PI19 to light the red led on the breadboard.

  1. root@Bananapi:~# cd /sys/class/gpio/
  2. root@Bananapi:/sys/class/gpio# echo 3 > export
  3. root@Bananapi:/sys/class/gpio# echo out > gpio3_pi19/direction
  4. root@Bananapi:/sys/class/gpio# echo 1 > gpio3_pi19/value
  5. root@Bananapi:/sys/class/gpio# echo 0 > gpio3_pi19/value
  6. root@Bananapi:/sys/class/gpio# echo 1 > gpio3_pi19/value
Copy the Code

and, to use GPIO in input mode with the pin 12 => PH2 for example :

  1. echo 4 > export
  2. echo in > gpio4_ph2/direction
  3. cat gpio4_ph2/value
Copy the Code

Yeah... It is so easy Yeah?

You can write a script to control all the pins

Post Last Edited by kryp-alkora at 2014-5-22 01:13


I know that this question does not fit into this thread, but on the picture the connected drive hdd. I would like to ask you to answer from Mr. Phi___. Is the SATA port is working correctly? What are the transfers to the port sata? (2 Cubieboard worked with ssd 100-104 MB / s but with ethernet 10/100 it was impossible to do anything).
Can I use Sata multipler? Cubieboard2 tested did not work.
Can I use an external RAID card? 5 sata in and 1 out. What operating systems running sata?

I'll be very grateful for your reply.

echo 3 >/sys/class/gpio/export
-bash: echo: write error: Invalid argument

kernel is 3.4.61.A20.bananapi.v02

Reply 9# past

I just open 2 pins in script.bin. You can add more setting in script.bin [gpio_para]

You have to log in before you can reply Login | Sign Up

Points Rules