Jump to content

BPI M2 how gpio programming


helfis

Recommended Posts

hello, im use ARMbian on bpi m2 and will programming the gpio with python.

 

Quote

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)

GPIO.setup(23, GPIO.OUT)
GPIO.setup(24, GPIO.IN)

for i in range(5):
    GPIO.output(23, GPIO.HIGH)
    time.sleep(0.5)
    GPIO.output(23, GPIO.LOW)
    time.sleep(0.5)


Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import RPi.GPIO as GPIO
  File "/usr/local/lib/python2.7/dist-packages/RPi/GPIO/__init__.py", line 23, in <module>
    from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!

i have tested with this little script, but i become a runtimeerror.

i can not use the RPI.GPO. What can i used to programming GPO with Python under bpi m2?

 

Link to comment
Share on other sites

4 hours ago, martinayotte said:

Where did you took this python library ?

If you took it from Raspberry sites, it won't work ...

Maybe this one will, but I'm not sure since I don't own BPI M2 :

http://wiki.lemaker.org/BananaPro/Pi:GPIO_library

 

It is true ... my libary is from Raspberry site and do not work

how uninstall this wrong libary?

than i will test the GPIO libary from Lemaker

Link to comment
Share on other sites

On 8/2/2018 at 10:12 PM, martinayotte said:

No needs to uninstall, the Lemaker one will overwrite the previous ...

Now i have install RPI-GPIO from Lemarker 

i used the version bananapi (not bananapipro)

 

Quote

helmut@bananapim2:~$ git clone https://github.com/LeMaker/RPi.GPIO_BP -b bananapi
Klone nach 'RPi.GPIO_BP' ...
remote: Counting objects: 139, done.
remote: Total 139 (delta 0), reused 0 (delta 0), pack-reused 139
Empfange Objekte: 100% (139/139), 68.40 KiB | 0 bytes/s, Fertig.
Löse Unterschiede auf: 100% (61/61), Fertig.
Prüfe Konnektivität ... Fertig.

helmut@bananapim2:~$ sudo apt-get update
OK:1 http://ports.ubuntu.com xenial InRelease
Holen:2 http://ports.ubuntu.com xenial-security InRelease [107 kB]          
OK:3 http://apt.armbian.com xenial InRelease                                   
Holen:4 http://ports.ubuntu.com xenial-updates InRelease [109 kB]              
Holen:5 http://ports.ubuntu.com xenial-backports InRelease [107 kB]
Es wurden 323 kB in 4 s geholt (67,2 kB/s).                 
Paketlisten werden gelesen... Fertig

here are no errors

 

Quote

helmut@bananapim2:~$ sudo apt-get install python-dev
Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut.       
Statusinformationen werden eingelesen.... Fertig
»python-dev« ist bereits die neuste Version (2.7.12-1~16.04).
0 aktualisiert, 0 neu installiert, 0 zu entfernen und 3 nicht aktualisiert.
helmut@bananapim2:~$ 

 

installing python dev  - no errors

 

Quote

helmut@bananapim2:~$ cd RPi.GPIO_BP
helmut@bananapim2:~/RPi.GPIO_BP$ python setup.py install
running install
running build
running build_py
creating build
creating build/lib.linux-armv7l-2.7
creating build/lib.linux-armv7l-2.7/RPi
copying RPi/__init__.py -> build/lib.linux-armv7l-2.7/RPi
running build_ext
building 'RPi.GPIO' extension
creating build/temp.linux-armv7l-2.7
creating build/temp.linux-armv7l-2.7/source
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c source/py_gpio.c -o build/temp.linux-armv7l-2.7/source/py_gpio.o
source/py_gpio.c: In function ‘py_setup_channel’:
source/py_gpio.c:124:8: warning: variable ‘func’ set but not used [-Wunused-but-set-variable]
    int func;
        ^
source/py_gpio.c: In function ‘py_cleanup’:
source/py_gpio.c:102:31: warning: ‘i’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             gpio_direction = -1;
                               ^
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c source/c_gpio.c -o build/temp.linux-armv7l-2.7/source/c_gpio.o
source/c_gpio.c: In function ‘setup’:
source/c_gpio.c:87:3: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
   printf("gpio_mem = 0x%x\t gpio_map = 0x%x\n",gpio_mem,gpio_map);
   ^
source/c_gpio.c:87:3: warning: incompatible implicit declaration of built-in function ‘printf’
source/c_gpio.c:87:3: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
source/c_gpio.c:87:10: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘uint8_t * {aka unsigned char *}’ [-Wformat=]
   printf("gpio_mem = 0x%x\t gpio_map = 0x%x\n",gpio_mem,gpio_map);
          ^
source/c_gpio.c:87:10: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 3 has type ‘volatile uint32_t * {aka volatile unsigned int *}’ [-Wformat=]
source/c_gpio.c: In function ‘readl’:
source/c_gpio.c:103:6: warning: incompatible implicit declaration of built-in function ‘printf’
      printf("mmap_base = 0x%x\t mmap_seek = 0x%x\t gpio_map = 0x%x\t total = 0x%x\n",mmap_bas
      ^
source/c_gpio.c:103:6: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
source/c_gpio.c:103:13: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 4 has type ‘volatile uint32_t * {aka volatile unsigned int *}’ [-Wformat=]
      printf("mmap_base = 0x%x\t mmap_seek = 0x%x\t gpio_map = 0x%x\t total = 0x%x\n",mmap_bas
             ^
source/c_gpio.c:103:13: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 5 has type ‘volatile uint32_t * {aka volatile unsigned int *}’ [-Wformat=]
source/c_gpio.c: In function ‘set_pullupdn’:
source/c_gpio.c:227:3: warning: incompatible implicit declaration of built-in function ‘printf’
   printf("func:%s pin:%d,bank:%d index:%d sub:%d phyaddr:0x%x\n",__func__, gpio,bank,index,su
   ^
source/c_gpio.c:227:3: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
source/c_gpio.c:231:3: warning: incompatible implicit declaration of built-in function ‘printf’
   printf("pullUpDn reg:0x%x, pud:0x%x sub_index:%d\n", regval, pud, sub_index);
   ^
source/c_gpio.c:231:3: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
source/c_gpio.c:235:3: warning: incompatible implicit declaration of built-in function ‘printf’
   printf("pullUpDn val ready to set:0x%x\n", regval);
   ^
source/c_gpio.c:235:3: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
source/c_gpio.c:239:3: warning: incompatible implicit declaration of built-in function ‘printf’
   printf("pullUpDn reg after set:0x%x  addr:0x%x\n", regval, phyaddr);
   ^
source/c_gpio.c:239:3: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
source/c_gpio.c: In function ‘setup_gpio’:
source/c_gpio.c:252:3: warning: incompatible implicit declaration of built-in function ‘printf’
   printf("func:%s pin:%d, direction:%d bank:%d index:%d phyaddr:0x%x\n",__func__, gpio , dire
   ^
source/c_gpio.c:252:3: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
source/c_gpio.c:256:3: warning: incompatible implicit declaration of built-in function ‘printf’
   printf("read reg val: 0x%x offset:%d\n",regval,offset);
   ^
source/c_gpio.c:256:3: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
source/c_gpio.c:266:4: warning: incompatible implicit declaration of built-in function ‘printf’
    printf("Input mode set over reg val: 0x%x\n",regval);
    ^
source/c_gpio.c:266:4: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
source/c_gpio.c:273:4: warning: incompatible implicit declaration of built-in function ‘printf’
    printf("Out mode ready set val: 0x%x\n",regval);
    ^
source/c_gpio.c:273:4: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
source/c_gpio.c:277:4: warning: incompatible implicit declaration of built-in function ‘printf’
    printf("Out mode set over reg val: 0x%x\n",regval);
    ^
source/c_gpio.c:277:4: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
source/c_gpio.c:281:3: warning: incompatible implicit declaration of built-in function ‘printf’
   printf("line:%dpin number error\n",__LINE__);
   ^
source/c_gpio.c:281:3: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
source/c_gpio.c: In function ‘gpio_function’:
source/c_gpio.c:296:3: warning: incompatible implicit declaration of built-in function ‘printf’
   printf("read reg val: 0x%x offset:%d\n",regval,offset);
   ^
source/c_gpio.c:296:3: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
source/c_gpio.c:301:3: warning: incompatible implicit declaration of built-in function ‘printf’
   printf("read reg val: 0x%x\n",regval);
   ^
source/c_gpio.c:301:3: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
source/c_gpio.c: In function ‘output_gpio’:
source/c_gpio.c:312:3: warning: incompatible implicit declaration of built-in function ‘printf’
   printf("func:%s pin:%d, value:%d bank:%d index:%d phyaddr:0x%x\n",__func__, gpio , value,ba
   ^
source/c_gpio.c:312:3: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
source/c_gpio.c:316:3: warning: incompatible implicit declaration of built-in function ‘printf’
   printf("before write reg val: 0x%x,index:%d\n",regval,index);
   ^
source/c_gpio.c:316:3: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
source/c_gpio.c:323:4: warning: incompatible implicit declaration of built-in function ‘printf’
    printf("LOW val set over reg val: 0x%x\n",regval);
    ^
source/c_gpio.c:323:4: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
source/c_gpio.c:331:4: warning: incompatible implicit declaration of built-in function ‘printf’
    printf("HIGH val set over reg val: 0x%x\n",regval);
    ^
source/c_gpio.c:331:4: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
source/c_gpio.c: In function ‘input_gpio’:
source/c_gpio.c:343:4: warning: incompatible implicit declaration of built-in function ‘printf’
    printf("func:%s pin:%d,bank:%d index:%d phyaddr:0x%x\n",__func__, gpio,bank,index,phyaddr)
    ^
source/c_gpio.c:343:4: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
source/c_gpio.c:349:4: warning: incompatible implicit declaration of built-in function ‘printf’
    printf("***** read reg val: 0x%x,bank:%d,index:%d,line:%d\n",regval,bank,index,__LINE__);
    ^
source/c_gpio.c:349:4: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c source/cpuinfo.c -o build/temp.linux-armv7l-2.7/source/cpuinfo.o
source/cpuinfo.c: In function ‘get_cpuinfo_revision’:
source/cpuinfo.c:40:7: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
       fgets(buffer, sizeof(buffer) , fp);
       ^
source/cpuinfo.c: In function ‘get_rpi_revision’:
source/cpuinfo.c:66:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c source/event_gpio.c -o build/temp.linux-armv7l-2.7/source/event_gpio.o
source/event_gpio.c: In function ‘gpioToSysPin’:
source/event_gpio.c:79:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
source/event_gpio.c: In function ‘gpio_export’:
source/event_gpio.c:95:5: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
     write(fd, str_gpio, len);
     ^
source/event_gpio.c: In function ‘gpio_unexport’:
source/event_gpio.c:114:5: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
     write(fd, str_gpio, len);
     ^
source/event_gpio.c: In function ‘gpio_set_direction’:
source/event_gpio.c:136:9: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
         write(fd, "in", 3);
         ^
source/event_gpio.c:138:9: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
         write(fd, "out", 4);
         ^
source/event_gpio.c: In function ‘gpio_set_edge’:
source/event_gpio.c:157:5: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
     write(fd, stredge[edge], strlen(stredge[edge]) + 1);
     ^
source/event_gpio.c: In function ‘gpio_set_value’:
source/event_gpio.c:187:9: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
         write(fd, "1", 2);
         ^
source/event_gpio.c:189:9: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
         write(fd, "0", 2);
         ^
source/event_gpio.c: In function ‘gpio_set_pull’:
source/event_gpio.c:228:9: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
         write(fd, "down", 5);
         ^
source/event_gpio.c:230:9: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
         write(fd, "up", 3);
         ^
source/event_gpio.c:232:6: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
      write(fd, "disable", 8);
      ^
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c source/soft_pwm.c -o build/temp.linux-armv7l-2.7/source/soft_pwm.o
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c source/py_pwm.c -o build/temp.linux-armv7l-2.7/source/py_pwm.o
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c source/common.c -o build/temp.linux-armv7l-2.7/source/common.o
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c source/constants.c -o build/temp.linux-armv7l-2.7/source/constants.o
arm-linux-gnueabihf-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security 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
running install_lib
copying build/lib.linux-armv7l-2.7/RPi/GPIO.so -> /usr/local/lib/python2.7/dist-packages/RPi
error: could not delete '/usr/local/lib/python2.7/dist-packages/RPi/GPIO.so': Permission denied

here is an errorcode and warnings

 

Quote

helmut@bananapim2:~/RPi.GPIO_BP$ sudo python setup.py install
running install
running build
running build_py
running build_ext
running install_lib
copying build/lib.linux-armv7l-2.7/RPi/GPIO.so -> /usr/local/lib/python2.7/dist-packages/RPi
copying build/lib.linux-armv7l-2.7/RPi/__init__.py -> /usr/local/lib/python2.7/dist-packages/RPi
byte-compiling /usr/local/lib/python2.7/dist-packages/RPi/__init__.py to __init__.pyc
running install_egg_info
Removing /usr/local/lib/python2.7/dist-packages/RPi.GPIO-0.5.8.egg-info
Writing /usr/local/lib/python2.7/dist-packages/RPi.GPIO-0.5.8.egg-info
helmut@bananapim2:~/RPi.GPIO_BP$ 

step 2 is without errors

 

now the test with Python Shell

 

Quote

Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> import RPi.GPIO as GPIO
>>> import time
>>> GPIO.setup(23, GPIO.OUT)

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    GPIO.setup(23, GPIO.OUT)
RuntimeError: Please set pin numbering mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM) or GPIO.setmode(GPIO.RAW)
>>> GPIO.output(23, GPIO.HIGH)

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    GPIO.output(23, GPIO.HIGH)
RuntimeError: Please set pin numbering mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM) or GPIO.setmode(GPIO.RAW)
>>> 

by import no answer

by GPIO.setup(23, GPIO.OUT) i become an errorcode

is my syntax right?

 

Quote

helmut@bananapim2:~/RPi.GPIO_BP$ gpio readall
+----------+-Rev2-+------+--------+------+-------+
| wiringPi | GPIO | Phys | Name   | Mode | Value |
+----------+------+------+--------+------+-------+
|      0   |  17  |  11  | GPIO 0 | IN   | Low   |
|      1   |  18  |  12  | GPIO 1 | IN   | Low   |
|      2   |  27  |  13  | GPIO 2 | IN   | Low   |
|      3   |  22  |  15  | GPIO 3 | IN   | Low   |
|      4   |  23  |  16  | GPIO 4 | IN   | Low   |
|      5   |  24  |  18  | GPIO 5 | IN   | Low   |
|      6   |  25  |  22  | GPIO 6 | IN   | Low   |
|      7   |   4  |   7  | GPIO 7 | IN   | Low   |
|      8   |   2  |   3  | SDA    | IN   | Low   |
|      9   |   3  |   5  | SCL    | IN   | Low   |
|     10   |   8  |  24  | CE0    | IN   | Low   |
|     11   |   7  |  26  | CE1    | IN   | Low   |
|     12   |  10  |  19  | MOSI   | IN   | Low   |
|     13   |   9  |  21  | MISO   | IN   | Low   |
|     14   |  11  |  23  | SCLK   | IN   | Low   |
|     15   |  14  |   8  | TxD    | IN   | Low   |
|     16   |  15  |  10  | RxD    | IN   | Low   |
|     17   |  28  |   3  | GPIO 8 | IN   | Low   |
|     18   |  29  |   4  | GPIO 9 | IN   | Low   |
|     19   |  30  |   5  | GPIO10 | IN   | Low   |
|     20   |  31  |   6  | GPIO11 | IN   | Low   |
+----------+------+------+--------+------+-------+
helmut@bananapim2:~/RPi.GPIO_BP$ gpio readall
 

GPIO not set 

 

the GPIO is now properly installed?
or do I have a wrong syntax?

Is there a difference in syntax between GPIO.RPI and GPIO.RPI_BP?

where can i find a table with the syntax

 

how can i test this?

where is my mistake?

 

Thanks for your help

 

new attempt with the pythonshell

 

Quote

Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> import RPi.GPIO as GPIO
>>> import time
>>> GPIO.setmode(GPIO.BCM)
>>> GPIO.setup(23, GPIO.OUT)

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    GPIO.setup(23, GPIO.OUT)
RuntimeError: No access to /dev/mem.  Try running as root!
>>> 

why do I have to do this as root?
can I change the rights to the path?

 

Edited by helfis
supplement added
Link to comment
Share on other sites

Quote

Did you succeeded doing "sudo python" ?

Now I started Python with sudo in the terminal and entered the commands one by one.

 

Quote

helmut@bananapim2:~$ sudo python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO as GPIO
>>> import time
>>> GPIO.setmode(GPIO.BCM)
>>> GPIO.setup(23, GPIO.OUT)
>>> GPIO.output(23, GPIO.HIGH)
>>> 
 

now there is no error anymore

but the GPIO is still not set

Quote

helmut@bananapim2:~/RPi.GPIO_BP$ gpio readall
+----------+-Rev2-+------+--------+------+-------+
| wiringPi | GPIO | Phys | Name   | Mode | Value |
+----------+------+------+--------+------+-------+
|      0   |  17  |  11  | GPIO 0 | IN   | Low   |
|      1   |  18  |  12  | GPIO 1 | IN   | Low   |
|      2   |  27  |  13  | GPIO 2 | IN   | Low   |
|      3   |  22  |  15  | GPIO 3 | IN   | Low   |
|      4   |  23  |  16  | GPIO 4 | IN   | Low   |
|      5   |  24  |  18  | GPIO 5 | IN   | Low   |
|      6   |  25  |  22  | GPIO 6 | IN   | Low   |
|      7   |   4  |   7  | GPIO 7 | IN   | Low   |
|      8   |   2  |   3  | SDA    | IN   | Low   |
|      9   |   3  |   5  | SCL    | IN   | Low   |
|     10   |   8  |  24  | CE0    | IN   | Low   |
|     11   |   7  |  26  | CE1    | IN   | Low   |
|     12   |  10  |  19  | MOSI   | IN   | Low   |
|     13   |   9  |  21  | MISO   | IN   | Low   |
|     14   |  11  |  23  | SCLK   | IN   | Low   |
|     15   |  14  |   8  | TxD    | IN   | Low   |
|     16   |  15  |  10  | RxD    | IN   | Low   |
|     17   |  28  |   3  | GPIO 8 | IN   | Low   |
|     18   |  29  |   4  | GPIO 9 | IN   | Low   |
|     19   |  30  |   5  | GPIO10 | IN   | Low   |
|     20   |  31  |   6  | GPIO11 | IN   | Low   |
+----------+------+------+--------+------+-------+
 

I'll check that with an LED

Link to comment
Share on other sites

i used GPIO.setmode(GPIO.BCM)

 

I tried it with WiringPi installed also from lemaker banana pi (not pro)

helmut@bananapim2:/$ sudo gpio -g write 4 1
helmut@bananapim2:/$ sudo gpio -g read 4
0

or:

helmut@bananapim2:/$ sudo gpio write 7 1
helmut@bananapim2:/$ sudo gpio read 7
0
with      helmut@bananapim2:/$ sudo gpio readall    also all pins low 

 

LeMaker Banana Pi support platform with Allwinner A20.

bpi M2 has an platform with Allwinner A31s. can it be that?

or do I have to take the version with banana  pi pro?

 

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(22, GPIO.OUT)
GPIO.output(22, GPIO.HIGH)
#GPIO.cleanup()
it is the same  .. no gpio is set

Link to comment
Share on other sites

1 hour ago, martinayotte said:

Maybe this other one works better :  https://github.com/BPI-SINOVOIP/RPi.GPIO

 

RPi.GPIO-0.6.3 I downloaded from: https://github.com/BPI-SINOVOIP/RPi.GPIO/tree/acee51c1dd299a9bd7b8494a91549b51c89c4f93   

 

BPI-SINOVOIP support RPi all & Banana Pi all (BPI-M1/BPI-M1+/BPI-R1/BPI-M2/BPI-M2+/BPI-M2U/BPI-M2M/BPI-M3/BPI-M64)

 

Quote

If you are using Raspbian, all you need to do to install the latest release is:
$ sudo apt-get update
$ sudo apt-get install python-rpi.gpio python3-rpi.gpio

------------

If you are not using Raspbian, it is recommended that you install this module using pip:
$  sudo pip install RPi.GPIO

------------

If you want to build your own version from this downloaded copy, make
sure that you have the Python development source installed first!

On Raspbian:
$ sudo apt-get install python-dev python3-dev

To install the module:

$ sudo python setup.py install
  or
$ sudo python3 setup.py install

that is the install text - I do not have a raspbian

sudo pip install RPi.GPIO is not working

93$ sudo pip install RPi.GPIO
sudo: pip: Befehl nicht gefunden

------------

If you want to build your own version from this downloaded copy, make
sure that you have the Python development source installed first!

 

Quote

helmut@bananapim2:~/BPI-Sinovoip/RPi.GPIO-acee51c1dd299a9bd7b8494a91549b51c89c4f93$ python setup.py install
running install
running build
running build_py
running build_ext
running install_lib
running install_egg_info
Removing /usr/local/lib/python2.7/dist-packages/RPi.GPIO-0.6.3.egg-info
error: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/RPi.GPIO-0.6.3.egg-info'
helmut@bananapim2:~/BPI-Sinovoip/RPi.GPIO-acee51c1dd299a9bd7b8494a91549b51c89c4f93$ python3 setup.py install
running install
running build
running build_py
running build_ext
running install_lib
running install_egg_info
Removing /usr/local/lib/python3.5/dist-packages/RPi.GPIO-0.6.3.egg-info
error: [Errno 13] Permission denied: '/usr/local/lib/python3.5/dist-packages/RPi.GPIO-0.6.3.egg-info'
helmut@bananapim2:~/BPI-Sinovoip/RPi.GPIO-acee51c1dd299a9bd7b8494a91549b51c89c4f93$ 
 

Quote

helmut@bananapim2:~/BPI-Sinovoip/RPi.GPIO-acee51c1dd299a9bd7b8494a91549b51c89c4f93$ sudo python3 setup.py install
running install
running build
running build_py
running build_ext
running install_lib
running install_egg_info
Removing /usr/local/lib/python3.5/dist-packages/RPi.GPIO-0.6.3.egg-info
Writing /usr/local/lib/python3.5/dist-packages/RPi.GPIO-0.6.3.egg-info
helmut@bananapim2:~/BPI-Sinovoip/RPi.GPIO-acee51c1dd299a9bd7b8494a91549b51c89c4f93$ sudo python setup.py install
running install
running build
running build_py
running build_ext
running install_lib
running install_egg_info
Removing /usr/local/lib/python2.7/dist-packages/RPi.GPIO-0.6.3.egg-info
Writing /usr/local/lib/python2.7/dist-packages/RPi.GPIO-0.6.3.egg-info
 

 

test:


$ sudo python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO as GPIO
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "RPi/GPIO/__init__.py", line 23, in <module>
    from RPi._GPIO import *
ImportError: No module named _GPIO
 

what am I doing wrong?

Link to comment
Share on other sites

Hi @martinayotte,

Just out of curiosity, why did you suggest an old LeMaker project and not something closer to armbian like:

 Build libgpiod the "New GPIO Interface for User Space"
https://forum.armbian.com/topic/6249-build-libgpiod-the-new-gpio-interface-for-user-space/


 User Space IO is Python 3 and Java 8 bindings for user space GPIO, SPI, I2C, PWM and Serial interfaces
https://forum.armbian.com/topic/6523-user-space-io-is-python-3-and-java-8-bindings-for-user-space-gpio-spi-i2c-pwm-and-serial-interfaces/


 pyGPIO - A 'more general' python GPIO library based on pyA20
https://forum.armbian.com/topic/5662-pygpio-a-more-general-python-gpio-library/

 

Link to comment
Share on other sites

1 hour ago, Tido said:

Just out of curiosity, why did you suggest an old LeMaker project

I don't own any BPI M2 A31, so I suggested that one after doing some googling, then I've found the other one.

 

Personally, I got pyA20, pyA64 and orangepi_PC_gpio_pyH3 on most of my boards, that satisfied me ...

 

@helfis Why did you took the April 18th commit instead of the HEAD which seems to have 2 more commits ?

If still not working, maybe your out of luck ... (Better having a more supported board ...)

 

Link to comment
Share on other sites

1 hour ago, chwe said:

would at least need a bordconfig.. No idea if it works with A31s.. never tested..

it does not work

 

Quote

helmut@bananapim2:~$ git clone https://github.com/chwe17/pyGPIO.git
Klone nach 'pyGPIO' ...
remote: Counting objects: 264, done.
remote: Total 264 (delta 0), reused 0 (delta 0), pack-reused 264
Empfange Objekte: 100% (264/264), 56.53 KiB | 0 bytes/s, Fertig.
Löse Unterschiede auf: 100% (191/191), Fertig.
Prüfe Konnektivität ... Fertig.
helmut@bananapim2:~$ cd /home/helmut/pyGPIO/
helmut@bananapim2:~/pyGPIO$ sudo python setup.py install
[sudo] Passwort für helmut: 
running install
running build
running build_py
creating build
creating build/lib.linux-armv7l-2.7
creating build/lib.linux-armv7l-2.7/pyGPIO
copying pyGPIO/__init__.py -> build/lib.linux-armv7l-2.7/pyGPIO
creating build/lib.linux-armv7l-2.7/pyGPIO/gpio
copying pyGPIO/gpio/__init__.py -> build/lib.linux-armv7l-2.7/pyGPIO/gpio
running build_ext
Detected processor: unknown
Warning! Detected and target processor mismatch. 
Do you want to continue [Y/n]? y
Unknown board
Automatic board detection failed or your board is not supported (yet). 
You can use a pin mapping from one of our supported boards or abort the 
installation. This is only recommended for experienced users! 
Pin mapping might be false and the library does not work as expected!
[1]  OrangePi Zero
[2]  OrangePi Pc Plus
[3]  OrangePi Plus 2E
[4]  OrangePi Lite
[5]  A20-OLinuXino-MICRO
[6]  A20-OLinuXIno-LIME
[7]  A20-OLinuXIno-LIME2
[8]  NanoPi Duo
[9]  NanoPi Neo
[10] pcDuino3
[11] Abort

Abort.
helmut@bananapim2:~/pyGPIO$ 
 

Thanks for the tip. Unfortunately, the processor A31s is not supported.

Link to comment
Share on other sites

2 hours ago, Tido said:

 User Space IO is Python 3 and Java 8 bindings for user space GPIO, SPI, I2C, PWM and Serial interfaces
https://forum.armbian.com/topic/6523-user-space-io-is-python-3-and-java-8-bindings-for-user-space-gpio-spi-i2c-pwm-and-serial-interfaces/

 I'll test more SBCs as I have time. Also, I have deleted https://github.com/sgjava/libgpiod-extra since User Space IO supersedes it.

 

Link to comment
Share on other sites

9 hours ago, martinayotte said:

@helfis Why did you took the April 18th commit instead of the HEAD which seems to have 2 more commits ?

If still not working, maybe your out of luck ... (Better having a more supported board ...)

 

Now I want to test the GPIO from this site

https://github.com/sgjava/userspaceio

 

Download project

cd ~/

git clone --depth 1 https://github.com/sgjava/userspaceio.git

 

Quote

helmut@bananapim2:~$ cd ~/
helmut@bananapim2:~$ git clone --depth 1 https://github.com/sgjava/userspaceio.git
Klone nach 'userspaceio' ...
remote: Counting objects: 96, done.
remote: Compressing objects: 100% (74/74), done.
remote: Total 96 (delta 8), reused 84 (delta 4), pack-reused 0
Entpacke Objekte: 100% (96/96), Fertig.
Prüfe Konnektivität ... Fertig.

ok

Quote

helmut@bananapim2:~$ cd ~/userspaceio
helmut@bananapim2:~/userspaceio$ ./install.sh
08-07-2018  6:58:43 Installing User Space IO
08-07-2018  6:58:43 Installing CFFI
08-07-2018  6:58:43 Installing pip and cffi
[sudo] Passwort für helmut: 
08-07-2018  7:00:43 Done
08-07-2018  7:00:43 Installing JNAerator
/usr/bin/java
08-07-2018  7:00:43 Download JNAerator
08-07-2018  7:00:49 Building JNAerator dependencies
08-07-2018  7:00:50 Done
08-07-2018  7:00:50 Installing libgpiod
08-07-2018  7:00:50 Armbian detected
linux-headers-next-sunxi - Linux kernel headers for 4.14.18-sunxi on armhf
08-07-2018  7:00:55 linux-headers-next-sunxi found
08-07-2018  7:00:55 Installing Linux headers linux-headers-next-sunxi
08-07-2018  7:04:56 Installing required build packages
08-07-2018  7:05:20 Cloning libgpiod master
08-07-2018  7:05:30 Running autogen
08-07-2018  7:08:49 Running make
08-07-2018  7:09:20 Make install
08-07-2018  7:09:28 Done
08-07-2018  7:09:28 Generate JNA library for libgpiod
08-07-2018  7:09:31 Patching generated source
08-07-2018  7:09:31 Compile library
08-07-2018  7:09:32 Compiling demo code
08-07-2018  7:09:32 Done
08-07-2018  7:09:32 Installing c-periphery
08-07-2018  7:09:32 Cloning c-periphery
08-07-2018  7:09:37 Done
08-07-2018  7:09:37 Installing Python package
08-07-2018  7:09:56 Done
08-07-2018  7:09:56 Generate JNA library for c-periphery
08-07-2018  7:10:04 Patching generated source
08-07-2018  7:10:04 Compile library
08-07-2018  7:10:04 Compiling demo code
08-07-2018  7:10:04 Done
08-07-2018  7:10:04 Installing pwmio
08-07-2018  7:10:05 Done
08-07-2018  7:10:05 Installing Python package
08-07-2018  7:10:18 Done
08-07-2018  7:10:18 Generate JNA library for libpwmio
08-07-2018  7:10:21 Patching generated source
08-07-2018  7:10:21 Compile library
08-07-2018  7:10:21 Compiling demo code
08-07-2018  7:10:21 Done
helmut@bananapim2:~/userspaceio$ 
 

ok  i have no issues

 

now testing

Python bindings

libgpiod 1.1 includes Python bindings, so CFFI is not used.

To run demos:

Quote

helmut@bananapim2:~$ alias python=python3
helmut@bananapim2:~$ export PYTHONPATH=/usr/local/lib/python3.5/site-packages
helmut@bananapim2:~$ cd ~/userspaceio/libgpiod/python/src
helmut@bananapim2:~/userspaceio/libgpiod/python/src$ sudo python ledtest.py --chip 0 --line 203
[sudo] Passwort für helmut: 
Traceback (most recent call last):
  File "ledtest.py", line 17, in <module>
    import sys, time, gpiod
ImportError: No module named gpiod
helmut@bananapim2:~/userspaceio/libgpiod/python/src$ 
 

the test is not ok

what am I doing wrong?

 

Link to comment
Share on other sites

13 hours ago, helfis said:

Unfortunately, the processor A31s is not supported.

avoid this error is a one-liner.. 

 

You need to add a proper mapping.h according to the schematics of your board to get a chance that it works.

 

Here's the template:

https://github.com/chwe17/pyGPIO/blob/master/pyGPIO/gpio/mapping/template40.h

 

and SUNXI_GPX(Z) must be filled in. Replace XZ with the pin which is wired out on this position (e.g. PA10, PG11 etc.). X is the letter, Z the number of this pin. I don't add new SoCs as long as I don't have the board and nobody tests it.. Cause supporting such boards is a nightmare... :P So if you write a proper mapping.h, I may add your board to the supported ones, you then have to test if it works properly and if it does, your board gets support by pyGPIO.

 

 

Link to comment
Share on other sites

3 hours ago, chwe said:

You need to add a proper mapping.h according to the schematics of your board to get a chance that it works.

 

Here's the template:

https://github.com/chwe17/pyGPIO/blob/master/pyGPIO/gpio/mapping/template40.h

 

and SUNXI_GPX(Z) must be filled in. Replace XZ with the pin which is wired out on this position (e.g. PA10, PG11 etc.). X is the letter, Z the number of this pin. I don't add new SoCs as long as I don't have the board and nobody tests it.. Cause supporting such boards is a nightmare... :P So if you write a proper mapping.h, I may add your board to the supported ones, you then have to test if it works properly and if it does, your board gets support by pyGPIO.

 

Banana Pi has a 40-pin GPIO header that matches that of the Model B+ Raspberry Pi. Following is the Banana Pi GPIO Pinout:

https://bananapi.gitbooks.io/bpi-m2/content/en/bpi-m2_gpio_pin_define.html

 

here is my newly created mapping.h for Banana Pi M2

 

 

mapping.h

Link to comment
Share on other sites

21 minutes ago, helfis said:

here is my newly created mapping.h for Banana Pi M2

Should be updated now...  It's 9 months ago since I last touched the library. I hope I didn't messed up something... :rolleyes: As said, untested a short look through the used GPIO-banks didn't show something you should be concerned but you never know.. 

 

Link to comment
Share on other sites

52 minutes ago, chwe said:

As said, untested a short look through the used GPIO-banks didn't show something you should be concerned but you never know.. 

 

i have downloaded the new master GPIO from https://github.com/chwe17/pyGPIO

the installation was successful

Quote

helmut@bananapim2:~$ cd /home/helmut/pyGPIO-master/
helmut@bananapim2:~/pyGPIO-master$ sudo python setup.py install
[sudo] Passwort für helmut: 
running install
running build
running build_py
creating build
creating build/lib.linux-armv7l-2.7
creating build/lib.linux-armv7l-2.7/pyGPIO
copying pyGPIO/__init__.py -> build/lib.linux-armv7l-2.7/pyGPIO
creating build/lib.linux-armv7l-2.7/pyGPIO/gpio
copying pyGPIO/gpio/__init__.py -> build/lib.linux-armv7l-2.7/pyGPIO/gpio
running build_ext
Detected processor: Allwinner sun6i (A31) Family (Probably Allwinner A31s)
Warning! Detected and target processor mismatch. 
Do you want to continue [Y/n]? y
Detected board: Bananapi M2
Correct? [Y/n] y
building 'pyGPIO.gpio.gpio' extension
creating build/temp.linux-armv7l-2.7
creating build/temp.linux-armv7l-2.7/pyGPIO
creating build/temp.linux-armv7l-2.7/pyGPIO/gpio
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c pyGPIO/gpio/gpio_lib.c -o build/temp.linux-armv7l-2.7/pyGPIO/gpio/gpio_lib.o
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c pyGPIO/gpio/gpio.c -o build/temp.linux-armv7l-2.7/pyGPIO/gpio/gpio.o
arm-linux-gnueabihf-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-armv7l-2.7/pyGPIO/gpio/gpio_lib.o build/temp.linux-armv7l-2.7/pyGPIO/gpio/gpio.o -o build/lib.linux-armv7l-2.7/pyGPIO/gpio/gpio.so
building 'pyGPIO.i2c' extension
creating build/temp.linux-armv7l-2.7/pyGPIO/i2c
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c pyGPIO/i2c/i2c_lib.c -o build/temp.linux-armv7l-2.7/pyGPIO/i2c/i2c_lib.o
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c pyGPIO/i2c/i2c.c -o build/temp.linux-armv7l-2.7/pyGPIO/i2c/i2c.o
arm-linux-gnueabihf-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-armv7l-2.7/pyGPIO/i2c/i2c_lib.o build/temp.linux-armv7l-2.7/pyGPIO/i2c/i2c.o -o build/lib.linux-armv7l-2.7/pyGPIO/i2c.so
building 'pyGPIO.spi' extension
creating build/temp.linux-armv7l-2.7/pyGPIO/spi
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c pyGPIO/spi/spi_lib.c -o build/temp.linux-armv7l-2.7/pyGPIO/spi/spi_lib.o
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c pyGPIO/spi/spi.c -o build/temp.linux-armv7l-2.7/pyGPIO/spi/spi.o
arm-linux-gnueabihf-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-armv7l-2.7/pyGPIO/spi/spi_lib.o build/temp.linux-armv7l-2.7/pyGPIO/spi/spi.o -o build/lib.linux-armv7l-2.7/pyGPIO/spi.so
building 'pyGPIO.gpio.connector' extension
creating build/temp.linux-armv7l-2.7/pyGPIO/gpio/connector
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c pyGPIO/gpio/connector/connector.c -o build/temp.linux-armv7l-2.7/pyGPIO/gpio/connector/connector.o
arm-linux-gnueabihf-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-armv7l-2.7/pyGPIO/gpio/connector/connector.o -o build/lib.linux-armv7l-2.7/pyGPIO/gpio/connector.so
building 'pyGPIO.gpio.port' extension
creating build/temp.linux-armv7l-2.7/pyGPIO/gpio/port
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c pyGPIO/gpio/port/port.c -o build/temp.linux-armv7l-2.7/pyGPIO/gpio/port/port.o
arm-linux-gnueabihf-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-armv7l-2.7/pyGPIO/gpio/port/port.o -o build/lib.linux-armv7l-2.7/pyGPIO/gpio/port.so
running install_lib
creating /usr/local/lib/python2.7/dist-packages/pyGPIO
copying build/lib.linux-armv7l-2.7/pyGPIO/spi.so -> /usr/local/lib/python2.7/dist-packages/pyGPIO
copying build/lib.linux-armv7l-2.7/pyGPIO/i2c.so -> /usr/local/lib/python2.7/dist-packages/pyGPIO
copying build/lib.linux-armv7l-2.7/pyGPIO/__init__.py -> /usr/local/lib/python2.7/dist-packages/pyGPIO
creating /usr/local/lib/python2.7/dist-packages/pyGPIO/gpio
copying build/lib.linux-armv7l-2.7/pyGPIO/gpio/connector.so -> /usr/local/lib/python2.7/dist-packages/pyGPIO/gpio
copying build/lib.linux-armv7l-2.7/pyGPIO/gpio/__init__.py -> /usr/local/lib/python2.7/dist-packages/pyGPIO/gpio
copying build/lib.linux-armv7l-2.7/pyGPIO/gpio/gpio.so -> /usr/local/lib/python2.7/dist-packages/pyGPIO/gpio
copying build/lib.linux-armv7l-2.7/pyGPIO/gpio/port.so -> /usr/local/lib/python2.7/dist-packages/pyGPIO/gpio
byte-compiling /usr/local/lib/python2.7/dist-packages/pyGPIO/__init__.py to __init__.pyc
byte-compiling /usr/local/lib/python2.7/dist-packages/pyGPIO/gpio/__init__.py to __init__.pyc
running install_egg_info
Writing /usr/local/lib/python2.7/dist-packages/pyGPIO-0.2.1.egg-info
helmut@bananapim2:~/pyGPIO-master$ 
 

there is still a message

.....

Detected processor: Allwinner sun6i (A31) Family (Probably Allwinner A31s)
Warning! Detected and target processor mismatch. 
Do you want to continue [Y/n]? y
Detected board: Bananapi M2
Correct? [Y/n] y

.....

but when running python comes the following error message:

 

Quote

helmut@bananapim2:~$ sudo python
[sudo] Passwort für helmut: 
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO as GPIO
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/RPi/GPIO/__init__.py", line 23, in <module>
    from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!
>>> 

can it be that my many attempts make something wrong? I do not have to uninstall anything right?
Previously I had https://github.com/sgjava/userspaceio installed

 

 

Link to comment
Share on other sites

it's pyGPIO not RPi.GPIO read again the first thread from:

pyGPIO isn't based on RPI.GPIO. It's basically a pyA20 fork for multiple boards. So examples for pyA20 need some changes in naming (e.g. replace 'from pyA20.gpio import gpio' with 'from pyGPIO.gpio import gpio'). 

Compared to ArmbianIO (sysFS) or userspaceIO (Libgpiod), pyGPIO accesses 'pins' directly through /dev/mem which can increase speed but on the other side may be a bit risky in case something gets messed up.. 

 

Link to comment
Share on other sites

1 hour ago, helfis said:

Detected processor: Allwinner sun6i (A31) Family (Probably Allwinner A31s)
Warning! Detected and target processor mismatch. 
Do you want to continue [Y/n]? y
Detected board: Bananapi M2
Correct? [Y/n] y

 

please send the output from:

grep -i "hardware" /proc/cpuinfo

 

Link to comment
Share on other sites

52 minutes ago, chwe said:

grep -i "hardware" /proc/cpuinfo

helmut@bananapim2:~$ sudo grep -i "hardware" /proc/cpuinfo
Hardware    : Allwinner sun6i (A31) Family
 

helmut@bananapim2:~$ cat /etc/os-release
NAME="Ubuntu"
VERSION="16.04.5 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.5 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
 

helmut@bananapim2:~$ neofetch
            .-/+oossssoo+/-.               helmut@bananapim2 
        `:+ssssssssssssssssss+:`           ----------------- 
      -+ssssssssssssssssssyyssss+-         OS: Ubuntu 16.04.5 LTS armv7l 
    .ossssssssssssssssssdMMMNysssso.       Host: Sinovoip BPI-M2 
   /ssssssssssshdmmNNmmyNMMMMhssssss/      Kernel: 4.14.18-sunxi 
  +ssssssssshmydMMMMMMMNddddyssssssss+     Uptime: 28 mins 
 /sssssssshNMMMyhhyyyyhmNMMMNhssssssss/    Packages: 1405 (dpkg) 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Shell: bash 4.3.48 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   Resolution: 1920x1080 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   DE: Xfce 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   WM: Xfwm4 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   WM Theme: Numix 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Theme: Numix [GTK2], Adwaita [GTK3] 
 /sssssssshNMMMyhhyyyyhdNMMMNhssssssss/    Icons: gnome [GTK2], Adwaita [GTK3] 
  +sssssssssdmydMMMMMMMMddddyssssssss+     Terminal: x-terminal-emul 
   /ssssssssssshdmNNNNmyNMMMMhssssss/      CPU: Allwinner sun6i (A31) Family (4 
    .ossssssssssssssssssdMMMNysssso.       Memory: 550MiB / 992MiB 
      -+sssssssssssssssssyyyssss+-
        `:+ssssssssssssssssss+:`                                   
            .-/+oossssoo+/-.

Link to comment
Share on other sites

1 hour ago, chwe said:

pyGPIO isn't based on RPI.GPIO. It's basically a pyA20 fork for multiple boards. So examples for pyA20 need some changes in naming (e.g. replace 'from pyA20.gpio import gpio' with 'from pyGPIO.gpio import gpio'). 

i have run your python skript with the blinking LED 

it works!

 

where can I get an overview of the commands that change with pyGPIO compared to RPI.GPIO.

Link to comment
Share on other sites

2 hours ago, helfis said:

Detected processor: Allwinner sun6i (A31) Family (Probably Allwinner A31s)
Warning! Detected and target processor mismatch. 

should be fixed.. 

 

16 minutes ago, helfis said:

i have run your python skript with the blinking LED 

it works!

nice... you may test some other GPIOs to ensure they are all correct in the mapping.. 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines