How to get GPIO interrupts working?

jwessel
jwessel New Member Posts: 11

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

Answers

  • nukular
    nukular New Member Posts: 61 ✭✭✭

    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

  • jwessel
    jwessel New Member Posts: 11

    @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 well

    Are 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
    falling

    One the UP Squared board the above sequence doesn't work.

  • nukular
    nukular New Member Posts: 61 ✭✭✭

    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

  • jwessel
    jwessel New Member Posts: 11

    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.

  • nukular
    nukular New Member Posts: 61 ✭✭✭

    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

  • Nicola Lunghi
    Nicola Lunghi Emutex Posts: 131 mod

    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 now

    Regards
    Nicola Lunghi

  • jwessel
    jwessel New Member Posts: 11

    @Nicola Lunghi said:
    MRAA is using the linux gpio numbering so it works.
    RPi.gpio uses the raspberry pi numbering so no interrupt for now

    Is there any easy way to fix the RPi.gpio library to use the linux gpio numbering?

Privacy Policy