Phunkafizer / RaspyRFM

Software for the RaspyRFM module with examples
MIT License
38 stars 17 forks source link

Event detection of RPi.GPIO broken since the new kernel 6.6 #13

Closed joberreiter closed 2 weeks ago

joberreiter commented 2 months ago

Trying to setup edge detection on a Pi Zero 2W results in an error with the new kernel 6.6: Note: The code had run for years on previous kernels without problems.

Mar 23 05:57:39 raspberry2 GetSensorData_RFM69[88878]: INFO Set up radio module
Mar 23 05:57:39 raspberry2 raspyrfm2[88878]: RFM69 found on CS 0
Mar 23 05:57:39 raspberry2 raspyrfm2[88878]: Traceback (most recent call last):
Mar 23 05:57:39 raspberry2 raspyrfm2[88878]:   File "/usr/local/bin/RaspyRFM2/GetSensorData_RFM69.py", line 110, in <module>
Mar 23 05:57:39 raspberry2 raspyrfm2[88878]:     rfm = RaspyRFM(1, RFM69)
Mar 23 05:57:39 raspberry2 raspyrfm2[88878]:           ^^^^^^^^^^^^^^^^^^
Mar 23 05:57:39 raspberry2 raspyrfm2[88878]:   File "/usr/local/bin/RaspyRFM2/raspyrfm/__init__.py", line 45, in RaspyRFM
Mar 23 05:57:39 raspberry2 raspyrfm2[88878]:     return rfm69.Rfm69(s[0], s[1])
Mar 23 05:57:39 raspberry2 raspyrfm2[88878]:            ^^^^^^^^^^^^^^^^^^^^^^^
Mar 23 05:57:39 raspberry2 raspyrfm2[88878]:   File "/usr/local/bin/RaspyRFM2/raspyrfm/rfm69.py", line 153, in __init__
Mar 23 05:57:39 raspberry2 raspyrfm2[88878]:     GPIO.add_event_detect(gpio_int, GPIO.RISING, callback=self.__rfm_irq)
Mar 23 05:57:39 raspberry2 raspyrfm2[88878]: RuntimeError: Failed to add edge detection
Mar 23 05:57:39 raspberry2 kernel: export_store: invalid GPIO 25
Mar 23 05:57:39 raspberry2 systemd[1]: raspyrfm2.service: Main process exited, code=exited, status=1/FAILURE
Mar 23 05:57:39 raspberry2 systemd[1]: raspyrfm2.service: Failed with result 'exit-code'.
Mar 23 05:57:39 raspberry2 systemd[1]: Failed to start raspyrfm2.service - RaspyRFM2 Radio Data Receiver.

The call of GPIO.add_event_detect(gpio_int, GPIO.RISING, callback=self.__rfm_irq) (with gpio_int = 25) results in an error message RuntimeError: Failed to add edge detection, the kernel can't export GPIO 25.

Reason: the pin numbering of the gpio has drastically changed, is no longer zero-based. On a Pi Zero 2 W, sudo cat /sys/kernel/debug/gpio | grep '(GPIO' lists as:

gpio-514 (GPIO2               )
gpio-515 (GPIO3               )
gpio-516 (GPIO4               |onewire@0           ) out hi
gpio-517 (GPIO5               )
gpio-518 (GPIO6               )
gpio-519 (GPIO7               |spi0 CS1            ) out hi ACTIVE LOW
gpio-520 (GPIO8               |spi0 CS0            ) out hi ACTIVE LOW
gpio-521 (GPIO9               )
gpio-522 (GPIO10              )
gpio-523 (GPIO11              )
gpio-524 (GPIO12              )
gpio-525 (GPIO13              )
gpio-526 (GPIO14              )
gpio-527 (GPIO15              )
gpio-528 (GPIO16              )
gpio-529 (GPIO17              )
gpio-530 (GPIO18              )
gpio-531 (GPIO19              )
gpio-532 (GPIO20              )
gpio-533 (GPIO21              )
gpio-534 (GPIO22              )
gpio-535 (GPIO23              )
gpio-536 (GPIO24              )
gpio-537 (GPIO25              )
gpio-538 (GPIO26              )
gpio-539 (GPIO27              )

This issue is not limited to the Zero 2W, should affect other platforms as well. It is definitely an issue of the underlying library RPi.GPIO.

Phunkafizer commented 2 weeks ago

Using rpi-lgpio instead of rpi-gpio now