[Nov 13] Slackware Aarch64 Miniroot & XFCE (20181101) / NextCloudPi (11-04-18) / Armbian Debian Stretch Desktop & Armbian Ubuntu Bionic (5.65) - Rock64 |[Nov 12] Q4OS ( 2.4-r5) - 1080P Pinebook / Pinebook |[Nov 09] KDE Neon ( 20181104-1500) - 1080P Pinebook / Pinebook /Arch Linux (20181104) - Pinebook |[Nov 09]Arch Linux (20181104) /Armbian - Xenial (5.56) - PineA64-LTS / SOPINE |[Nov 09]Armbian (5.65) /Arch Linux (20181104) /motionEyeOS (20180627) - PINE A64(+) |[Nov 02] Volumio ( 2.462-2018-09-29) - Rock64 |[Oct 23] AOSC with Mate Desktop [20181016] - Pinebook / Q4OS (2.6-r3) - Pinebook

Project Inspiration | Get Started | IRC Logs | Forum Rules/Policy


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:
[email protected]:/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'
[email protected]:/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
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).
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
  HW image transitions in Python gaggleoxfoggy 0 87 Yesterday, 12:36 AM
Last Post: gaggleoxfoggy
  Rock64 as multiple server Sputnik 2 174 11-01-2018, 12:59 AM
Last Post: Sputnik
  ROCK64 RTC Avengerman14s 9 763 10-28-2018, 07:02 AM
Last Post: petec
Information Serial Console for the Rock64 MarkHaysHarris777 23 6,838 10-04-2018, 04:25 PM
Last Post: scat70
  STBY led is red, rock64 fail? heroes1412 1 113 10-04-2018, 12:28 AM
Last Post: tllim
  Ceph on ROCK64 maal 2 302 09-29-2018, 08:51 PM
Last Post: suberimakuri
  Rock64 hangs without trace szus 10 514 09-15-2018, 01:42 PM
Last Post: szus
  Rock64 as a retro-gaming console: personal thoughts Danielsan 8 900 09-13-2018, 03:45 PM
Last Post: jessiehughes
  height of rock64? heocb 2 101 09-13-2018, 11:48 AM
Last Post: heocb
  Crypto wallets - rock64 Vegeta 0 91 09-10-2018, 01:49 AM
Last Post: Vegeta

Forum Jump:


Users browsing this thread: 1 Guest(s)