You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
interrupts are not passed to userspace (e.g. poll()) when an interrupts occurs on a gpio pin on a raspberry pi 4 #5159
changed the title [-]poll() on /sys/class/gpioXX/value does not trigger when an interrupt occurs on raspberry pi 4[/-][+]interrupts are not passed to userspace (e.g. poll()) when an interrupts occurs on a gpio pin on a raspberry pi 4[/+]on Sep 1, 2022
@lategoodbye I did. And I verified with strace that it may not be related to libpigpio e.g. it performs the right steps (set input to in, set trigger to edge, perform poll() on fd).
I'm not expert in libpigpio. How does it interact with the GPIOs (SOC register level or via /sys/class/gpio)?
Are other GPIOs affected not just GPIO 2?
How do you trigger the interrupt?
Did it worked with an older kernel version?
It's working fine for me on a Pi 4 running 5.15.61.
I've modified the test program so you can pass in a GPIO number, but that doesn't change the fundamental behaviour - your version also works for me. In the spirit of test code it is not defensively written, but it does avoid the I/O error caused by re-exporting the same GPIO.
I've been testing all morning and started to see that sometimes it does work and sometimes it doesn't - with 5.15.56-v7+.
So I took a scoop and measured.
In rpi3-001-start.png you see that after a fresh boot, the voltage on that pin (between the rpi and the tranceiver) is 0V.
When a packet comes in (rpi3-002-recv-packet.png), the pin is pulled up to 3.28V.
Now it gets strange: when I reset and re-initialised the tranceiver and reconfigured the rpi-part, the voltage suddenly goes to 0.84V! If then another packet comes in, the voltage again goes to 3.28V but the rpi doesn't "see" this.
So what I'm thinking now:
either the batch of tranceivers I've got is buggy causing that 0.84V voltage - but why isn't that a problem with at least the rpi1? (I noticed suddenly that I was using the rpi2 this morning so that one is problematic as well: only the rpi1 seems to be rock solid).
GPIO 2 has an external hardware pull-up resistor - it's intended for I2C use - so it will not float. You can use raspi-gpio get 2 (or sudo grep -w 2 /sys/kernel/debug/gpio) to get a snapshot of the actual pin level.
For the record, I repeated the test on the latest BRANCH=stable build - due to appear in a new RPiOS image in the near future - and it works as expected:
raspberrypi$ uname -a
Linux raspberrypi 5.15.61-v7l+ #1579 SMP Fri Aug 26 11:13:03 BST 2022 armv7l GNU/Linux
pi@raspberrypi:~ $ sudo ./polltest
Waiting for a change on GPIO 2 (currently 1)
pi@raspberrypi:~ $
GPIO 2 has an external hardware pull-up resistor - it's intended for I2C use - so it will not float. You can use raspi-gpio get 2 (or sudo grep -w 2 /sys/kernel/debug/gpio) to get a snapshot of the actual pin level.
Hmmm I did not know that. Means I have to retest as with the scope I was using gpio 22 instead.
Do you know if I can set gpio 22 to pull down explicitly? Not via /sys/class/gpio it looks like?
the tranceiver I work with pulls a 'DIO0'-pin high when it receives a packet
when you reset its IRQ-register, the DIO0 goes down
Now it looks like if the library I use for that tranceiver does not reset that IRQ-flag before (re-)setting the tranceiver to receive and the gpio-pin to input, that the voltage stays at 0.84V for some reason.
This needs further testing from my side, but it looks promising.
I think I can conclude this is a problem with that library and not neccessarily with the kernel(?) so I suggest we can close this issue?
Activity
[-]poll() on /sys/class/gpioXX/value does not trigger when an interrupt occurs on raspberry pi 4[/-][+]interrupts are not passed to userspace (e.g. poll()) when an interrupts occurs on a gpio pin on a raspberry pi 4[/+]lategoodbye commentedon Sep 4, 2022
@folkertvanheusden Did you already contacted the author of libpigpio-dev before?
folkertvanheusden commentedon Sep 4, 2022
@lategoodbye I did. And I verified with strace that it may not be related to libpigpio e.g. it performs the right steps (set input to in, set trigger to edge, perform poll() on fd).
lategoodbye commentedon Sep 4, 2022
I'm not expert in libpigpio. How does it interact with the GPIOs (SOC register level or via /sys/class/gpio)?
Are other GPIOs affected not just GPIO 2?
How do you trigger the interrupt?
Did it worked with an older kernel version?
folkertvanheusden commentedon Sep 4, 2022
@lategoodbye via /sys/class/gpio
(I'm not an expert in libpigpio either but I dug a bit in it)
It's also with other GPIOs. I also checked one without pull-up.
I trigger the interrupt via hardware (a switch connected to the gpio pin).
Older kernel: I'll see if I can check that out. I'll keep you posted.
folkertvanheusden commentedon Sep 4, 2022
GPIO 2
This works fine on "4.19.75-v7l+ # 1270 SMP Tue Sep 24 18:51:41 BST 2019".
It does NOT work on "5.15.61-v7l+ # 1579 SMP Fri Aug 26 11:13:03 BST 2022".
lategoodbye commentedon Sep 4, 2022
Just to make it clear:
Kernel 4.19.75: Rpi 1, 2, 3 & 4 works
Kernel 5.15.61: Rpi 1 & 2 works, but 3 & 4 doesn't
correct?
folkertvanheusden commentedon Sep 5, 2022
Yes!
folkertvanheusden commentedon Sep 5, 2022
Well, that's not accurate: 4.19.75 has been tested on my rpi4 and there it works; i have not tested it on an rpi1.
folkertvanheusden commentedon Sep 5, 2022
Hi,
Update:
So somewhere between 5.15.32 and 5.15.61 it broke.
pelwell commentedon Sep 5, 2022
It's working fine for me on a Pi 4 running 5.15.61.
I've modified the test program so you can pass in a GPIO number, but that doesn't change the fundamental behaviour - your version also works for me. In the spirit of test code it is not defensively written, but it does avoid the I/O error caused by re-exporting the same GPIO.
folkertvanheusden commentedon Sep 5, 2022
Hi @pelwell,
I've been testing all morning and started to see that sometimes it does work and sometimes it doesn't - with 5.15.56-v7+.
So I took a scoop and measured.
In rpi3-001-start.png you see that after a fresh boot, the voltage on that pin (between the rpi and the tranceiver) is 0V.
When a packet comes in (rpi3-002-recv-packet.png), the pin is pulled up to 3.28V.
Now it gets strange: when I reset and re-initialised the tranceiver and reconfigured the rpi-part, the voltage suddenly goes to 0.84V! If then another packet comes in, the voltage again goes to 3.28V but the rpi doesn't "see" this.
So what I'm thinking now:
pelwell commentedon Sep 5, 2022
GPIO 2 has an external hardware pull-up resistor - it's intended for I2C use - so it will not float. You can use
raspi-gpio get 2(orsudo grep -w 2 /sys/kernel/debug/gpio) to get a snapshot of the actual pin level.For the record, I repeated the test on the latest
BRANCH=stablebuild - due to appear in a new RPiOS image in the near future - and it works as expected:folkertvanheusden commentedon Sep 5, 2022
Hmmm I did not know that. Means I have to retest as with the scope I was using gpio 22 instead.
Do you know if I can set gpio 22 to pull down explicitly? Not via /sys/class/gpio it looks like?
pelwell commentedon Sep 5, 2022
raspi-gpio set 22 ip pdwill make it an input, enabling the pull-down resistor.... puenables the pull-up instead, and... pndisables the pulls.folkertvanheusden commentedon Sep 5, 2022
F.w.i.w.:
Now it looks like if the library I use for that tranceiver does not reset that IRQ-flag before (re-)setting the tranceiver to receive and the gpio-pin to input, that the voltage stays at 0.84V for some reason.
This needs further testing from my side, but it looks promising.
I think I can conclude this is a problem with that library and not neccessarily with the kernel(?) so I suggest we can close this issue?