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

Raspbian 12 BookWorm, kernel 6.6.20: RuntimeError: Failed to add edge detection #1136

Open
f18m opened this issue Mar 29, 2024 · 2 comments
Open

Comments

@f18m
Copy link

f18m commented Mar 29, 2024

Operating system: Raspbian Bookworm, with kernel 6.6.20+rpt-rpi-v8
Python version: 3.11
Pi model: Pi 4 Model B
GPIO Zero version: 2.0.1
Pin factory used: RPi.GPIO 0.7.1

The basic snippet below

import gpiozero
gpiozero.Button(26)  # or any other pin number 

fails with error

Mar 29 00:30:28 raspberrypi-ha-alarm python3[1574]:   File "/root/ha-alarm-raspy2mqtt-venv/lib/python3.11/site-packages/gpiozero/devices.py", line 108, in __call__
Mar 29 00:30:28 raspberrypi-ha-alarm python3[1574]:     self = super().__call__(*args, **kwargs)
Mar 29 00:30:28 raspberrypi-ha-alarm python3[1574]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Mar 29 00:30:28 raspberrypi-ha-alarm python3[1574]:   File "/root/ha-alarm-raspy2mqtt-venv/lib/python3.11/site-packages/gpiozero/input_devices.py", line 412, in __init__
Mar 29 00:30:28 raspberrypi-ha-alarm python3[1574]:     super().__init__(
Mar 29 00:30:28 raspberrypi-ha-alarm python3[1574]:   File "/root/ha-alarm-raspy2mqtt-venv/lib/python3.11/site-packages/gpiozero/mixins.py", line 417, in __init__
Mar 29 00:30:28 raspberrypi-ha-alarm python3[1574]:     super().__init__(*args, **kwargs)
Mar 29 00:30:28 raspberrypi-ha-alarm python3[1574]:   File "/root/ha-alarm-raspy2mqtt-venv/lib/python3.11/site-packages/gpiozero/input_devices.py", line 168, in __init__
Mar 29 00:30:28 raspberrypi-ha-alarm python3[1574]:     self.pin.when_changed = self._pin_changed
Mar 29 00:30:28 raspberrypi-ha-alarm python3[1574]:     ^^^^^^^^^^^^^^^^^^^^^
Mar 29 00:30:28 raspberrypi-ha-alarm python3[1574]:   File "/root/ha-alarm-raspy2mqtt-venv/lib/python3.11/site-packages/gpiozero/pins/__init__.py", line 471, in <lambda>
Mar 29 00:30:28 raspberrypi-ha-alarm python3[1574]:     lambda self, value: self._set_when_changed(value),
Mar 29 00:30:28 raspberrypi-ha-alarm python3[1574]:                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Mar 29 00:30:28 raspberrypi-ha-alarm python3[1574]:   File "/root/ha-alarm-raspy2mqtt-venv/lib/python3.11/site-packages/gpiozero/pins/pi.py", line 639, in _set_when_changed
Mar 29 00:30:28 raspberrypi-ha-alarm python3[1574]:     self._enable_event_detect()
Mar 29 00:30:28 raspberrypi-ha-alarm python3[1574]:   File "/root/ha-alarm-raspy2mqtt-venv/lib/python3.11/site-packages/gpiozero/pins/rpigpio.py", line 220, in _enable_event_detect
Mar 29 00:30:28 raspberrypi-ha-alarm python3[1574]:     GPIO.add_event_detect(
Mar 29 00:30:28 raspberrypi-ha-alarm python3[1574]: RuntimeError: Failed to add edge detection

A few points:

  1. there are already SIMILAR (but confused IMHO) issues open on this topic. I spent time reading them with no much success, so opening this one that, I hope, will help others

  2. Searching online my understanding is that in latest Linux kernel the sysfs interface for GPIOs has been removed, and most of the GPIO factory libraries are still trying to use it, like RPI.GPIO.

  3. I already managed to work-around the problem by using pigpio library as GPIO factory.

My suggestion: change documentation to clearly state that at this point in time, if you are on Bookworm and using a recent Linux kernel (would be nice to find out the exact Linux version since the sysfs deprecation), you MUST switch to pigpio library.

@bennuttall
Copy link
Member

@waveform80 what's the state of play for Pi 4 these days?

@lurch
Copy link
Contributor

lurch commented Apr 2, 2024

See also #1132

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

3 participants