-
Notifications
You must be signed in to change notification settings - Fork 141
Description
Bug Report: GPIO Event and Value Handling Discrepancy
Board Type
- Raspberry Pi 4 Model B Rev 1.4
Operating System
- Debian GNU/Linux 12 (bookworm)
Swift Version
- Swift 6.0.1
Installed usingswiftlang.xyz
Description of the Issue
When using a button wired to GPIO 26 as an input, I encountered inconsistent behavior with GPIO event handling and value reading depending on the board configuration used.
-
Using
RaspberryPi4:- Issue: GPIO events (e.g.,
onChange) do not fire when pressing the button. - Observation: Manually reading
GPIO.valuereflects the correct value change when the button is pressed.
- Issue: GPIO events (e.g.,
-
Switching to
RaspberryPi4_2024:- Issue: GPIO events now fire properly, but manually reading
GPIO.valueno longer returns the correct value.
- Issue: GPIO events now fire properly, but manually reading
Investigation Findings
-
The filenames in
/sys/class/gpio/match the IDs used inRaspberryPi4_2024, which are offset by 512 (e.g.,/sys/class/gpio/gpio538/valuefor GPIO 26).
Thus,RaspberryPi4_2024seems necessary for proper event handling. -
However, the ids in
RaspberryPi4_2024appear to break the memory mapping.
Workaround
Here's a workaround I'm currently using. This ensures that the memory address calculations work as they did in RaspberryPi4 but the filenames will be offset by 512 as done in RaspberryPi4_2024. I don't understand all the details of this class so its likely I'm missing some things.