rpi.gpio aarch64 archlinux ARM

This forum is for topics dealing with problems with software specifically in the AArch64 repo.

rpi.gpio aarch64 archlinux ARM

Postby jerlem » Thu Oct 29, 2020 4:24 pm

I am trying to get the rpi.gpio package working on RPi 4B with archlinux aarch64 but somehow it doesn't telling me that it only works on a Raspberry Pi...

Any insight or help?

Thanks,
Jérôme
jerlem
 
Posts: 1
Joined: Sat Aug 15, 2020 3:09 am

Re: rpi.gpio aarch64 archlinux ARM

Postby darksky » Fri Oct 30, 2020 5:30 pm

I do not know about the one in the repo but the one in AUR worked a month ago for me.

https://aur.archlinux.org/packages/pyth ... erry-gpio/
darksky
 
Posts: 35
Joined: Thu Oct 15, 2020 5:57 pm

Re: rpi.gpio aarch64 archlinux ARM

Postby mafes » Sat Nov 07, 2020 5:49 pm

Hi, I have the same issue in Raspberry Pi 4B Arch Linux ARMv8. Could you finally get it working? I tried installing AUR package python-raspberry-gpio 0.7.0-2 but it does not work:
$this->bbcode_second_pass_code('', '
$ python
Python 3.8.6 (default, Oct 6 2020, 22:56:58)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/site-packages/RPi/GPIO/__init__.py", line 23, in <module>
from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!
>>> import RPi.GPIO as GPIO
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/site-packages/RPi/GPIO/__init__.py", line 23, in <module>
from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!
')

But I can activate GPIO pins through the command line:
$this->bbcode_second_pass_code('', '
$ ls /sys/class/gpio/
export gpiochip446 gpiochip454 unexport
$ echo "464" > /sys/class/gpio/export
$ ls /sys/class/gpio/gpio464/
active_low device direction edge power subsystem uevent value
')

And also initialize them through python-periphery, but only running a sudo Python shell for permission issues:
$this->bbcode_second_pass_code('', '$ sudo python
Python 3.8.6 (default, Oct 6 2020, 22:56:58)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from periphery import GPIO
>>> gpio_in = GPIO("/dev/gpiochip0", 10, "in")
>>>
$ python
Python 3.8.6 (default, Oct 6 2020, 22:56:58)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from periphery import GPIO
>>> gpio_in = GPIO("/dev/gpiochip0", 10, "in")
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/periphery/gpio.py", line 530, in _open
self._chip_fd = os.open(path, 0)
PermissionError: [Errno 13] Permission denied: '/dev/gpiochip0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/site-packages/periphery/gpio.py", line 487, in __init__
self._open(path, line, direction, edge, bias, drive, inverted, label)
File "/usr/lib/python3.8/site-packages/periphery/gpio.py", line 532, in _open
raise GPIOError(e.errno, "Opening GPIO chip: " + e.strerror)
periphery.gpio.GPIOError: [Errno 13] Opening GPIO chip: Permission denied
>>>

')

There was an issue in aarch64 systems which lead to the first error, but it was resolved in 0.7.0 release:
$this->bbcode_second_pass_code('', 'Change Log
==========

0.7.0
-------
- Updated RPI_INFO to include RPi 4B
- Fixed pull up/down for Pi4 (issue 168)
- Fix spelling mistake in docstrings
- Tested and working on Raspbian Buster + Python 3.8.0b2
- Fix board detection for aarch64 (Issues 161 / 165)
- Fix checking mmap return value in c_gpio.c (issue 166)')

Could somebody make it?

Thanks


EDIT:
I've just realized that in my case the problem was that file /proc/cpuinfo lacks hardware, serial and revision information. I made it by editing the source code of the package (source/cpuinfo.c) and creating an auxiliary cpuinfo file to look into. May be this was your problem too, so I found in the Internet similar cases. I created another post https://archlinuxarm.org/forum/viewtopic.php?f=65&t=14858 to resolve this issue.
mafes
 
Posts: 3
Joined: Sat Nov 07, 2020 5:18 pm

Re: rpi.gpio aarch64 archlinux ARM

Postby Fincer » Fri Dec 18, 2020 10:19 pm

To make this work, you need a kernel which has support for/adds GPIO device /dev/gpiomem (kernel config: CONFIG_BCM2835_DEVGPIOMEM=y, etc.).

Instead of linux-aarch64 kernel by Arch Linux ARM, I use Raspberry Pi Linux kernel to get proper support for Raspberry Pi GPIOs.

Another issue, as you mentioned, is lack of information in /proc/cpuinfo. By default, it does not have all the information which is required for python-raspberry-gpio. I have a dumb workaround script for it which allows me to use python-raspberry-gpio stuff. The script is as follows:

$this->bbcode_second_pass_code('', '
#!/bin/env sh

# Fixes issue with Python Raspberry Pi modules which can't recognize
# a Raspberry Pi device as Raspberry Pi due to missing cpuinfo fields

cat /proc/cpuinfo >> /tmp/cpuinfo_tmp

echo "
Revision : a02082
" >> /tmp/cpuinfo_tmp

#echo "
#Hardware : BCM2835
#Revision : a02082
#Serial : 00000000b6d3553f
#Model : Raspberry Pi 3 Model B Rev 1.2
#" >> /tmp/cpuinfo_tmp

chmod u-w+r,go-wx+r /tmp/cpuinfo_tmp

mount --bind /tmp/cpuinfo_tmp /proc/cpuinfo
')

The script is executed each time I boot a Raspberry Pi. Feel free to customize it as needed.

Overall, this approach has worked for all of my Arch Linux ARM based Raspberry Pi 3 and Raspberry Pi 4 units for several years.
Fincer
 
Posts: 3
Joined: Fri Dec 18, 2020 5:48 pm

Re: rpi.gpio aarch64 archlinux ARM

Postby graysky » Fri Dec 18, 2020 11:14 pm

You can try my 5.10.y branch of kernels which are based very heavily on rpi-5.10.y. They are maintained for both armv7h and aarch64. I host a repo containing the aarch64 packages I compile myself you can use directly or you can use my fork of PKGBUILDs and build you own. 5.10.1-1 was released today. There is also a kodi-rpi-git package there based on the latest v19b2 which works very well and offers HW decoding for both h264 and x265.

https://github.com/graysky2/PKGBUILDs/commits/5.10.y
http://repo-ck.com/aarch64-test/

Instructions are on the repo header if you just browse to it.

Feel free to provide feedback. The kernels both contain that particular config setting:
$this->bbcode_second_pass_code('', '% grep -i bcm2835_dev config*
config:CONFIG_BCM2835_DEVGPIOMEM=y
config8:CONFIG_BCM2835_DEVGPIOMEM=y
')
graysky
Developer
 
Posts: 1731
Joined: Sun Jun 26, 2011 6:56 am
Location: /run/user/1000


Return to ARMv8

Who is online

Users browsing this forum: No registered users and 14 guests