PINE64
Python GPIO Library for the Rock64 (R64.GPIO) - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: ROCK64 (https://forum.pine64.org/forumdisplay.php?fid=85)
+--- Forum: General Discussion on ROCK64 (https://forum.pine64.org/forumdisplay.php?fid=86)
+--- Thread: Python GPIO Library for the Rock64 (R64.GPIO) (/showthread.php?tid=5902)

Pages: 1 2 3 4


RE: Python GPIO Library for the Rock64 (R64.GPIO) - ElRobbo - 05-17-2018

Hey all -

I was referred here by lukasz after posting this thread wondering about using an RPi GPIO-based LCD screen.

Would installing the python GPIO library help with their drivers, which seem to be RPi-specific binaries?  

It seems to me they're apples and oranges, but I'm not a low-level h/w or s/w guy, so...

I just want a small display to show me what's happening during boot of an otherwise headless system.


RE: Python GPIO Library for the Rock64 (R64.GPIO) - ubidots - 07-04-2018

(04-08-2018, 04:11 AM)i69fstop Wrote: Hi @Leapo

I have this error..running
Code:
R64-GPIO-test.py



Code:
root@rock64:/home/Rock64-R64.GPIO# sudo python R64-GPIO-test.py
Testing R64.GPIO Module...

Module Variables:
Name           Value
----           -----
GPIO.ROCK      ROCK
GPIO.BOARD     BOARD
GPIO.BCM       BCM
GPIO.OUT       out
GPIO.IN        in
GPIO.HIGH      1
GPIO.LOW       0
GPIO.PUD_UP    0
GPIO.PUD_DOWN  1
GPIO.VERSION   0.6.3
GPIO.RPI_INFO  {'P1_REVISION': 3, 'RAM': '1024M', 'REVISION': 'a22082', 'TYPE': 'Pi 3 Model B', 'PROCESSOR': 'BCM2837', 'MANUFACTURER': 'Embest'}
Error: Unable to export GPIO
Error: Unable to set GPIO direction
Error: Unable to export GPIO
Error: Unable to set GPIO direction

Testing GPIO Input/Output:
You must setup() the GPIO channel first
Output State : None
You must setup() the GPIO channel as an output first
You must setup() the GPIO channel first
Input State  : None
You must setup() the GPIO channel as an output first

Testing PWM Output - DutyCycle - High Precision:
60Hz at 50% duty cycle for 1 second
Traceback (most recent call last):
  File "R64-GPIO-test.py", line 58, in <module>
    p.start(50)
  File "/home/Rock64-R64.GPIO/R64/_GPIO.py", line 333, in start
    self.pwm_calc()
  File "/home/Rock64-R64.GPIO/R64/_GPIO.py", line 350, in pwm_calc
    self.sleep_low = (1.0 / self.freq) * ((100 - self.dutycycle) / 100.0)
AttributeError: PWM instance has no attribute 'freq'
root@rock64:/home/Rock64-R64.GPIO# uname -a
Linux rock64 4.4.114-rockchip-ayufan-193 #1 SMP Sun Mar 4 20:24:21 UTC 2018 aarch64 GNU/Linux

@Leapo

I update to 4.4.120, it fixed the issue with IO  error


Code:
Linux rock64 4.4.120-rockchip-ayufan-209 #1 SMP Mon Apr 2 16:05:07 UTC 2018 aarch64 GNU/Linux

Hi,

I had rock64 4.4.77 image. I faced the same issue with python GPIO lib. So I tried upgrading with "sudo apt-get upgrade" and sudo apt-get dist-upgrade".
After when I tried to reboot, it wasn't booting up.

Can you please share the link of the OS which is working for python GPIO library.


Regards


RE: Python GPIO Library for the Rock64 (R64.GPIO) - gaggleoxfoggy - 08-06-2018

Add me to the "interested but not working" list. Debian Stretch 4.4.124, tried the original and the AnythingIsFine version that was edited for newer kernels. Still the same errors, unable to export GPIO and unable to set GPIO direction.


RE: Python GPIO Library for the Rock64 (R64.GPIO) - gaggleoxfoggy - 08-06-2018

Actually, I just got it working using AnythingIsFine's modified version. For anyone else having issues (and maybe this was mentioned and I just missed it), try running it as root.


RE: Python GPIO Library for the Rock64 (R64.GPIO) - pas059 - 08-08-2018

Hi,
using informations found on this forum, i made a little app in C++ to use gpio lines. This works, but root is required, which is embarrassing.
I tried to add my user (rock64) on the sudo group as i've read elsewhere (§sudo usermod -a -G sudo rock64 ), but this has no effect.

Someone knows a solution to use gpio app (that uses sysfs) outside root? or another method to use gpio lines than sysfs which does not requires root?

regards


RE: Python GPIO Library for the Rock64 (R64.GPIO) - mcerveny - 08-22-2018

Can you enhance and register package to "pypi" ?

Like:
https://pypi.org/project/RPi.GPIO/
https://pypi.org/project/Adafruit-GPIO/
https://pypi.org/project/OPi.GPIO/
https://pypi.org/project/OrangePi.GPIO/

Can you enhance build to debian binary package and distribute over ayufan ppa ?

Like:
https://packages.debian.org/buster/python-rpi.gpio
https://packages.debian.org/buster/python3-rpi.gpio
https://packages.debian.org/buster/rpi.gpio-common



(08-08-2018, 09:10 AM)pas059 Wrote: Someone knows a solution to use gpio app (that uses sysfs) outside root? or another method to use gpio lines than sysfs which does not requires root?

Yes, possible. First, choose the group, "dialout" is recommended not "sudo".
Code:
$ ### test default situation
$ id -a
uid=1000(rock64) gid=1000(rock64) groups=1000(rock64),4(adm),27(sudo),29(audio),44(video),46(plugdev),104(input),109(ssh)
$ ls -la /sys/class/gpio/export
--w-------  1 root root 4096 Aug 22 19:51 export
$ echo 102 > /sys/class/gpio/export
-bash: /sys/class/gpio/export: Permission denied

$ ### modify system
$ sudo bash
# cat >  /etc/udev/rules.d/gpio.rules <<'EOF'
SUBSYSTEM=="gpio", KERNEL=="gpiochip*", ACTION=="add", PROGRAM="/bin/sh -c 'chown root:dialout /sys/class/gpio/export /sys/class/gpio/unexport ; chmod 220 /sys/class/gpio/export /sys/class/gpio/unexport'"
SUBSYSTEM=="gpio", KERNEL=="gpio*", ACTION=="add", PROGRAM="/bin/sh -c 'chown root:dialout /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value ; chmod 660 /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value'"
EOF
# usermod -a -G dialout rock64
# reboot

$ ### now working access over "dialout" group
$ id -a
uid=1000(rock64) gid=1000(rock64) groups=1000(rock64),4(adm),20(dialout),27(sudo),29(audio),44(video),46(plugdev),104(input),109(ssh)
$ ls -la /sys/class/gpio/export
--w--w---- 1 root dialout 4096 Aug 22 20:48 /sys/class/gpio/export
$ ### cpu pin 102 == GPIO3_A6 == pinheader pin 18
$ echo 102 > /sys/class/gpio/export
$ ls -l /sys/class/gpio/gpio102/
total 0
-rw-rw---- 1 root dialout 4096 Aug 22 20:50 active_low
lrwxrwxrwx 1 root root       0 Aug 22 20:51 device -> ../../../pinctrl
-rw-rw---- 1 root dialout 4096 Aug 22 20:50 direction
-rw-rw---- 1 root dialout 4096 Aug 22 20:50 edge
drwxr-xr-x 2 root root       0 Aug 22 20:51 power
lrwxrwxrwx 1 root root       0 Aug 22 20:51 subsystem -> ../../../../../class/gpio
-rw-r--r-- 1 root root    4096 Aug 22 20:50 uevent
-rw-rw---- 1 root dialout 4096 Aug 22 20:50 value
$ echo out > /sys/class/gpio/gpio102/direction
$ echo 0 > /sys/class/gpio/gpio102/value
$ echo 1 > /sys/class/gpio/gpio102/value
$ echo in > /sys/class/gpio/gpio102/direction
$ cat /sys/class/gpio/gpio102/value
1
$ echo 102 > /sys/class/gpio/unexport



RE: Python GPIO Library for the Rock64 (R64.GPIO) - fadedreamz - 09-19-2018

Hi everyone,
I came across the library while trying to work with gpio on rock64 in python.
However, I couldn't use the library due to licensing issue (yes, it is a commercial prototype) and the add_event_detect()
feature was missing (to easily detect button press).

So, I reimplemented the R64.GPIO as a seperate repo in github (https://github.com/fadedreamz). In my testing the initial results are good enough as it consumes very little cpu cycle to detect the key press event (no busy wait).

Right now if you want to do GPIO input output with event_detect() the library is able to handle them pretty good. I am still missing many feature as I never used RPi.GPIO (as my C skills >>>> my python skills).

Right now, PWM is not implemented.
For Pull Up/Down, right now the default settings are used (whatever it is initialized to) and will fix it as soon as I can enable it in the hardware.

Any feedback from you guys are appreciated and will be used to improve the library (as I will have the rock64 for quite some time).


RE: Python GPIO Library for the Rock64 (R64.GPIO) - mcerveny - 09-20-2018

(09-19-2018, 11:37 PM)fadedreamz Wrote: However, I couldn't use the library due to licensing issue (yes, it is a commercial prototype) ...
Why ? It is LGPLv3 (not GPL).


RE: Python GPIO Library for the Rock64 (R64.GPIO) - fadedreamz - 10-09-2018

(09-20-2018, 12:58 PM)mcerveny Wrote:
(09-19-2018, 11:37 PM)fadedreamz Wrote: However, I couldn't use the library due to licensing issue (yes, it is a commercial prototype) ...
Why ? It is LGPLv3 (not GPL).

Hmmm, maybe I could have used it. However, I didn't know how it play with Python (library linking and other stuff). But, I am guessing based on your response, that it might be possible.
Maybe should have read more carefully.


RE: Python GPIO Library for the Rock64 (R64.GPIO) - pantera - 10-24-2018

is there still no support for interrupts? does the OS not support this? polling for GPIO is extremely inefficient.