Interfacing

How to use RPi.GPIO on Banana Pro/Pi

9 5721
The RPi.GPIO has been ported into Banana Pro. Everyone who want to have a try can follow the install guide:
http://wiki.lemaker.org/RPi.GPIO
Great!

perfect timing!

carlito  
Edited by carlito at Tue Jan 27, 2015 14:17

I am on the Banana Pi (not Banana Pro) and I am running Bananian 15.01.01.
Trying to run python  with import RPi.GPIO as GPIO I found that there is no GPIO library included in Bananian.
So I googled and found I had to install python-dev
and   git clone https://github.com/LeMaker/RPi.GPIO_BP.git
After that I went to the RPi.GPIO directory and ran:  python setup.py install
This installed the GPIO.so in /usr/local/lib/python2.7.
When I now try to import RPi.GPIO as GPIO  in my python program I get:
  This module can only be run on a Raspberry Pi!

Does the RPi.GPIO only run on the Banana Pro?
Is there a RPi.GPIO available for Bananian?

Sorry for not reading correctly:
I had found another forum entry where it directed me to the git file above.
In this post here the link points to another page which says I have to do
git clone https://github.com/LeMaker/RPi.GPIO_BP -b bananapi

After I did this the installation went well.


evolvox  
Hello everyone,

I followed all the steps listed in the wiki but gcc cannot compile at the steps:

python setup.py install                 
sudo python setup.py install

Thank you for your help!
  1. bananapi@lemaker ~/RPi.GPIO_BP $ sudo python setup.py install
  2. running install
  3. running build
  4. running build_py
  5. running build_ext
  6. building 'RPi.GPIO' extension
  7. gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c source/py_gpio.c -o build/temp.linux-armv7l-2.7/source/py_gpio.o
  8. source/py_gpio.c: In function ‘py_setup_channel’:
  9. source/py_gpio.c:124:8: warning: variable ‘func’ set but not used [-Wunused-but-set-variable]
  10. gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c source/c_gpio.c -o build/temp.linux-armv7l-2.7/source/c_gpio.o
  11. source/c_gpio.c: In function ‘setup’:
  12. source/c_gpio.c:87:3: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
  13. source/c_gpio.c:87:3: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
  14. source/c_gpio.c:87:3: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘uint8_t *’ [-Wformat]
  15. source/c_gpio.c:87:3: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 3 has type ‘volatile uint32_t *’ [-Wformat]
  16. source/c_gpio.c: In function ‘readl’:
  17. source/c_gpio.c:103:6: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
  18. source/c_gpio.c:103:6: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 4 has type ‘volatile uint32_t *’ [-Wformat]
  19. source/c_gpio.c:103:6: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 5 has type ‘volatile uint32_t *’ [-Wformat]
  20. source/c_gpio.c: In function ‘set_pullupdn’:
  21. source/c_gpio.c:227:3: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
  22. source/c_gpio.c: In function ‘setup_gpio’:
  23. source/c_gpio.c:252:3: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
  24. source/c_gpio.c: In function ‘gpio_function’:
  25. source/c_gpio.c:296:3: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
  26. source/c_gpio.c: In function ‘output_gpio’:
  27. source/c_gpio.c:312:3: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
  28. source/c_gpio.c: In function ‘input_gpio’:
  29. source/c_gpio.c:343:4: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
  30. gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c source/cpuinfo.c -o build/temp.linux-armv7l-2.7/source/cpuinfo.o
  31. source/cpuinfo.c: In function ‘get_rpi_revision’:
  32. source/cpuinfo.c:66:1: warning: control reaches end of non-void function [-Wreturn-type]
  33. gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c source/event_gpio.c -o build/temp.linux-armv7l-2.7/source/event_gpio.o
  34. source/event_gpio.c: In function ‘gpioToSysPin’:
  35. source/event_gpio.c:79:1: warning: control reaches end of non-void function [-Wreturn-type]
  36. gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c source/soft_pwm.c -o build/temp.linux-armv7l-2.7/source/soft_pwm.o
  37. gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c source/py_pwm.c -o build/temp.linux-armv7l-2.7/source/py_pwm.o
  38. gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c source/common.c -o build/temp.linux-armv7l-2.7/source/common.o
  39. gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c source/constants.c -o build/temp.linux-armv7l-2.7/source/constants.o
  40. gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-armv7l-2.7/source/py_gpio.o build/temp.linux-armv7l-2.7/source/c_gpio.o build/temp.linux-armv7l-2.7/source/cpuinfo.o build/temp.linux-armv7l-2.7/source/event_gpio.o build/temp.linux-armv7l-2.7/source/soft_pwm.o build/temp.linux-armv7l-2.7/source/py_pwm.o build/temp.linux-armv7l-2.7/source/common.o build/temp.linux-armv7l-2.7/source/constants.o -o build/lib.linux-armv7l-2.7/RPi/GPIO.so
  41. /usr/lib/arm-linux-gnueabihf/libpthread_nonshared.a: file not recognized: File format not recognized
  42. collect2: ld returned 1 exit status
  43. error: command 'gcc' failed with exit status 1
Copy the Code

z00m  
thank you
all have done

gpio readall - works normally, but it wrote ==Banana PRO=== but i have only PI

is it normal?
  1. bananapi@lemaker ~/RPi.GPIO_BP $ gpio readall
  2. +-----+-----+---------+------+---+--Banana Pro--+---+------+---------+-----+-----+
  3. | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
  4. +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
  5. |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
  6. |   2 |   8 |   SDA.1 | ALT5 | 1 |  3 || 4  |   |      | 5V      |     |     |
  7. |   3 |   9 |   SCL.1 | ALT5 | 1 |  5 || 6  |   |      | 0v      |     |     |
  8. |   4 |   7 | GPIO. 7 |   IN | 0 |  7 || 8  | 1 | IN   | TxD     | 15  | 14  |
  9. |     |     |      0v |      |   |  9 || 10 | 0 | IN   | RxD     | 16  | 15  |
  10. |  17 |   0 | GPIO. 0 | ALT4 | 0 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |
  11. |  27 |   2 | GPIO. 2 | ALT4 | 0 | 13 || 14 |   |      | 0v      |     |     |
  12. |  22 |   3 | GPIO. 3 | ALT4 | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |
  13. |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |
  14. |  10 |  12 |    MOSI |   IN | 0 | 19 || 20 |   |      | 0v      |     |     |
  15. |   9 |  13 |    MISO |   IN | 0 | 21 || 22 | 0 | ALT4 | GPIO. 6 | 6   | 25  |
  16. |  11 |  14 |    SCLK |   IN | 0 | 23 || 24 | 0 | IN   | CE0     | 10  | 8   |
  17. |     |     |      0v |      |   | 25 || 26 | 0 | IN   | CE1     | 11  | 7   |
  18. |   0 |  30 |   SDA.0 | ALT4 | 0 | 27 || 28 | 0 | ALT4 | SCL.0   | 31  | 1   |
  19. |   5 |  21 | GPIO.21 |   IN | 0 | 29 || 30 |   |      | 0v      |     |     |
  20. |   6 |  22 | GPIO.22 | ALT4 | 0 | 31 || 32 | 0 | ALT4 | GPIO.26 | 26  | 12  |
  21. |  13 |  23 | GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v      |     |     |
  22. |  19 |  24 | GPIO.24 |   IN | 0 | 35 || 36 | 0 | IN   | GPIO.27 | 27  | 16  |
  23. |  26 |  25 | GPIO.25 |   IN | 0 | 37 || 38 | 0 | IN   | GPIO.28 | 28  | 20  |
  24. |     |     |      0v |      |   | 39 || 40 | 0 | IN   | GPIO.29 | 29  | 21  |
  25. +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
  26. | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
  27. +-----+-----+---------+------+---+--Banana Pro--+---+------+---------+-----+-----+
Copy the Code

Thakao  
evolvox replied at Sat Feb 14, 2015 06:22
Hello everyone,

I followed all the steps listed in the wiki but gcc cannot compile at the steps:

Have you found a solution for your problem, have the same issue.

I was facing the same problem, but I solved.
You need to edit before you do 'sudo pyhton (or python3) setup.py install' in the source code directory the file 'cpuinfo.c'. Over there is a line where in the file '/proc/cpuinfo' they search for the string with "Hardware :". They then assume that the rest of the string only is 'sun7i' but is is not. The rest string is much longer.
The line sound like:

                 if (strcmp(hardware, "sun7i") == 0)

but it should be

                if (strstr(hardware, "sun7i") == 0)

what means 'is the substring in or not. If you have done that then setup and you will see it is running.

I do use a banana pro with debian and kernel 4.3.3 with xfce4
I had to face that the xfce-plugin 'WaveLan' is not anymore running (but the wlan0 is fine)
and according to GPIO I am up to now not able to get access to /dev/ttyS0..S3... They are opened but I do get no signal when I read. Maybe You are more succesfull.

cprior  
DerOptiker replied at Feb 09, 2016 16:01
I was facing the same problem, but I solved.
You need to edit before you do 'sudo pyhton (or python3 ...

I opened this as a pull request:https://github.com/LeMaker/RPi.GPIO_BP/pull/12

I have a Banana BPI R1 and want to use the gpio with ROHS SIM800L and Adafruit PCF8523 RTC modules.
I am wondering if I need the RPi.GPIO libraries (I am running kernel Linux 3.4.113-bananian on armv7l  -- Jessie).

Can I run a command such as;
git clone https://github.com/LeMaker/RPi.GPIO_BP -b bananrbi

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

Points Rules