Python GPIO Library for the Rock64 (R64.GPIO)
#21
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.
  Reply
#22
(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
  Reply
#23
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.
  Reply
#24
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.
  Reply
#25
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
  Reply
#26
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
I left this community in Aug 2019 due to PINE64 refusal to produce/deliver ROCK64-1G version 3 after more than one year of changing statuses to "planning", "evaluating", "releasing", "availability", "estimated availability" and finally "no schedule" Angry. ROCK64 is dead platform without any advantage. Buy Raspberry PI 4 !
Away
  Reply
#27
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).
  Reply
#28
(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).
I left this community in Aug 2019 due to PINE64 refusal to produce/deliver ROCK64-1G version 3 after more than one year of changing statuses to "planning", "evaluating", "releasing", "availability", "estimated availability" and finally "no schedule" Angry. ROCK64 is dead platform without any advantage. Buy Raspberry PI 4 !
Away
  Reply
#29
(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.
  Reply
#30
is there still no support for interrupts? does the OS not support this? polling for GPIO is extremely inefficient.
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Rock64 bricked shawwwn 0 0 22 minutes ago
Last Post: shawwwn
  Are you guys still using Ayufan's OMV on your Rock64? AkiraSensei 0 62 11-26-2021, 07:01 PM
Last Post: AkiraSensei
  Rock64 kernel panics clay 15 984 10-17-2021, 06:30 PM
Last Post: Rocklobster
  Pine Rock64 eMMC lifespan moonspell79 3 743 08-19-2021, 06:46 PM
Last Post: bcnaz
  Rock64 No Audio - Solved wbecks 12 18,671 08-13-2021, 01:23 PM
Last Post: blakeadam
  Trustzone support for Rock64 capablegh 1 546 07-17-2021, 10:15 AM
Last Post: capablegh
  rock64, compile problems "illegal instruction", "memory fault" -> ddr_333Mhz? klausfelix 0 449 07-02-2021, 03:13 PM
Last Post: klausfelix
Information Serial Console for the Rock64 MarkHaysHarris777 33 36,684 06-24-2021, 12:24 PM
Last Post: mikeklien
  lost eletronic component rock64 marvin1986 1 769 06-01-2021, 06:27 PM
Last Post: 8bit
Shocked Rock64 - Reboots after few minutes addezai 2 1,101 04-22-2021, 07:03 PM
Last Post: addezai

Forum Jump:


Users browsing this thread: 1 Guest(s)