Skip to content

Raspberry Pi 4 Model B Change Events Won't Fire #143

@gestrich

Description

@gestrich

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 using swiftlang.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.value reflects the correct value change when the button is pressed.
  • Switching to RaspberryPi4_2024:

    • Issue: GPIO events now fire properly, but manually reading GPIO.value no longer returns the correct value.

Investigation Findings

  • The filenames in /sys/class/gpio/ match the IDs used in RaspberryPi4_2024, which are offset by 512 (e.g., /sys/class/gpio/gpio538/value for GPIO 26).
    Thus, RaspberryPi4_2024 seems necessary for proper event handling.

  • However, the ids in RaspberryPi4_2024 appear 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions