Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel 6.6 breaks RpiGpioSensor EventDetection #125

Closed
DanielDecker opened this issue Mar 29, 2024 · 6 comments
Closed

Kernel 6.6 breaks RpiGpioSensor EventDetection #125

DanielDecker opened this issue Mar 29, 2024 · 6 comments

Comments

@DanielDecker
Copy link
Contributor

Linux kernel 6.6 (Raspberry Pi OS - current release) breaks the RPi.GPIO event detection which is used by RpiGpioSensor.
Sources:

I verified this on an RPi3 running kernel 6.6.20+rpt-rpi-v7 (bookworm). Using RpiGpioSensor with EventDetection results in RuntimeError: Failed to add edge detection. The rest of the RPi.GPIO functionality seems to work as expected, polling a GPIO also works. With kernel 6.1 (bookworm) EventDetection works perfectly.

The RPi.GPIO project on sourceforge seems to be out of date. According to the above sources, it's still not compatible with the RPi5. Maybe we should consider a different GPIO implementation!

@rkoshak
Copy link
Owner

rkoshak commented Apr 1, 2024

I'm open to a different implementation. I think RPi.GPIO was originally brought in to get the edge detection. The original implementation just polled the pins every 100 msec or so IIRC. I'd hate to go back to polling but it's a lot better than not working at all.

@DanielDecker
Copy link
Contributor Author

I've looked at several GPIO libraries and decided on lgpio (github). It's quite similar to RPi.GPIO, so it shouldn't be too hard to implement. It has all the features we use from RPi.GPIO, including edge detection.
But it's only possible to define pins with Broadcom numbering (e.g. GPIO4), which is our default setting. So you cannot define pins with Board numbering, which is a small breaking change.

I'd start to port RpiGpioSensor and work on the other modules that relay on RPi.GPIO later on, to get RPi5 support for them too.

@DanielDecker
Copy link
Contributor Author

DanielDecker commented Apr 14, 2024

With PR #127 RpiGpioActuator & GpioColorLed also use the lgpio library.

So the only remaining device using the RPi.GPIO library is the DhtSensor. RPi.GPIO seams to be a sub-dependency of adafruit-blinka which is required by adafruit-circuitpython-dht. Only the latter is directly referenced by the DhtSensor.

I don't know if kernel 6.6 breaks the DhtSensor, so for now I wouldn't change the library here for now.
I've looked at the source code for adafruit-circuitpython-dht and adafruit-blinka. And it seems that the adafruit-circuitpython-dht library uses pulseio (via blinka), which in turn uses libgpiod. So DhtSensor shouldn't be affected.

Since pip install automatically installs sub-dependencies it should be save to remove RPi.GPIO and adafruit-blinka from gpio/dependencies.txt.
What do you think?

@rkoshak
Copy link
Owner

rkoshak commented Apr 15, 2024

I have to believe there are other DHT libraries out there so if adafruit is causing any problems I'm open to using something else. But since it appears not to be a problem removing RPi.GPIO and adafruit-blinka from the dependencies makes a lot of sense.

@DanielDecker
Copy link
Contributor Author

Thanks for your opinion!
In a few weeks I'll be able to test a DHT20 sensor with kernel 6.6. So you'll hear from me if there's is a problem!

@DanielDecker
Copy link
Contributor Author

This issue was solved with #127

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants