GPIO Interrupt issue with sysfs on Colibri IMX6 - embedded linux

Hello,

I am using Colibri iMX6 DL module + Iris carrier board + Colibri_iMX6_LinuxImageV2.6_20160630,
I have made the following setup to test GPIO interrupts using sysfs:
Exported GPIO number 15 as output, on extension connector X16 pin 13.
Exported GPIO number 51 as input along with both edges as interrupts, on extension connector X16 pin 19.
Connected a jumper wire to these two pins.
Now driving output on /sys/class/gpio/gpio15/value and capturing input on /sys/class/gpio/gpio51/value works fine, however if I use either the poll or select method described here: gpio.txt « Documentation - linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules, to detect interrupt on gpio51 then it doesn’t work.
With select exceptfds, call remains blocked for either edge signal.
With poll, call immediately returns with POLLPRI event even when there is no signal change.
I tried setting the interrupt edge type to rising, falling in /sys/class/gpio/gpio51/edge, but same issue.

Am I missing some configuration? Can you please provide/point to an GPIO interrupt example in userspace for linux platform?

Thank you

Hi

I assume you did neither do a lseek to the beginning of the file you use poll with, nor do you close and reopen it as requested by the sysfs description. This is needed to acknowledge the event and be able to wait for the next one.

Attached a small program we once did to test the sysfs interface with poll().
gpio_event_driven

Max

Hi Max,

Thanks for your reply, I was doing lseek with poll after getting POLLPRI event but it didn’t made any change, so I then shifted to select method, I will try your program and let you know.

Thanks
Ravikiran

Hello Max,

It is working now with poll method, the missing part was: before calling poll and then lseek, the current value has to be read after opening the value file, in your program since there is a loop so it works from second iteration onwards.
But just for your note, for some reason select call method continues to remain blocked. This is the extra code I add for using select call:

fd = open(“/sys/class/gpio/gpio51/value”, O_RDONLY);
FD_ZERO(&except_fds);
FD_SET(fd, &except_fds);
select(1, NULL, NULL, &except_fds, &tv);

For our application poll is fine, thanks for your test program.
Ravikiran