How to get GPIO interrupts working?
Out of the box it doesn't seem as if there is any possibility to make interrupt driven GPIO work using RPi.GPIO. I created a simple program to poll the input at the expense of significant CPU and it works fine, so the circuits that go into the board are working (they work on an actual Raspberry Pi correctly as well).
Is there something wrong with the board or is this just not supported?
upsquared@ubuntu:~$ uname -a
Linux ubuntu 4.10.0-9-upboard #11~16.04.1 SMP Wed Oct 25 17:10:46 IST 2017 x86_64 x86_64 x86_64 GNU/Linux
echo 23 > /sys/class/gpio/export
root@ubuntu:~# ls -l /sys/class/gpio/gpio23/
total 0
-rw-r--r-- 1 root root 4096 Jan 3 16:26 active_low
lrwxrwxrwx 1 root root 0 Jan 3 16:26 device -> ../../../gpiochip4
-rw-r--r-- 1 root root 4096 Jan 3 16:26 direction
drwxr-xr-x 2 root root 0 Jan 3 16:26 power
lrwxrwxrwx 1 root root 0 Jan 3 16:26 subsystem -> ../../../../../../../class/gpio
-rw-r--r-- 1 root root 4096 Jan 3 16:26 uevent
-rw-r--r-- 1 root root 4096 Jan 3 16:26 value
Am I supposed to see an entry for "edge" here? It seems that the RPi.GPIO is using the sysfs instead of accessing a memory mapped region of the kernel. I could not locate the source package that correlated with the kernel the board came with so further debugging was not possible with in the kernel. Is there an apt-get command or git tree we can pull down that matches the binaries the board ships with?
Best Answers
-
This was very useful. I was able to make a quick hack to the RPi.GPIO library in order to get the unmodified original python scripts to work.
Can the kernel code be fixed to allow interrupts with the raspberry pi gpio compatible gpio's? I could perhaps take a look at fixing it if I can get the code. Do you have a pointer?
-
This was very useful. I created a quick hack to the RPi.GPIO library, which is attached. Is it possible to get the kernel source for the kernel that comes with the board to perhaps fix it in the kernel for the compatibility with existing code?
With the modified RPi.GPIO I was able to use my custom shield and unmodified python code.
Answers
-
not sure about Rpi.GPIO, but interrupts do work with MRAA. I only tested it with the C/C++ version, but python will probably work as well
-
@nukular said:
not sure about Rpi.GPIO, but interrupts do work with MRAA. I only tested it with the C/C++ version, but python will probably work as wellAre you using the OS that came pre-installed with the Apollo Lake board (Ubuntu 16.04 with the 4.10 kernel)? If you take a look at the gpio pin in the sysfs does the "edge" object show up? I suspect there is a kernel driver problem with the configuration that the board shipped with.
For example on the raspberry pi:
root@raspberrypi# echo 23 > /sys/class/gpio/export
root@raspberrypi# echo in > /sys/class/gpio/gpio23/direction
root@raspberrypi# cat /sys/class/gpio/gpio23/edge
none
root@raspberrypi# echo falling > /sys/class/gpio/gpio23/edge
root@raspberrypi# cat /sys/class/gpio/gpio23/edge
fallingOne the UP Squared board the above sequence doesn't work.
-
sorry for the late reply.
I don't think my board had any OS preinstalled. I am using Ubuntu 16.04.03 with the 4.9.45-upboard kernel (https://github.com/emutex/ubilinux-kernel)
but you are right, I also don't see the edge object in sysfs
-
Hopefully someone else will report in about how to get the interrupts working with the 40 pin header. Now at least we know it doesn't work with either the 4.9.45 or 4.10 kernel which are "upboard" enabled.
-
you probably misunderstood. Interrupts work with 4.9.45-upboard, even though I do not see the "edge" object in sysfs. MRAA probably uses the pinctrl driver instead of sysfs.
So just use libmraa instead of RPi.GPIO -
Hi
the interrupt work but using the Linux gpio number not the "raspberry pi numbering" for now.
MRAA is using the linux gpio numbering so it works.
RPi.gpio uses the raspberry pi numbering so no interrupt for nowRegards
Nicola Lunghi -
-
@Nicola Lunghi said:
MRAA is using the linux gpio numbering so it works.
RPi.gpio uses the raspberry pi numbering so no interrupt for nowIs there any easy way to fix the RPi.gpio library to use the linux gpio numbering?