Hi,
I’ve been working on a project that involves controlling GPIO pins on a Raspberry Pi using Balena. I successfully managed to get it working on a Raspberry Pi 4 following the guidelines provided in this document.
However, when I try to run the same setup on a Raspberry Pi 5, it doesn’t seem to work. Here are the details:
- Setup on Raspberry Pi 4:
- Followed the Balena documentation for GPIO access.
- Used Python with the
gpiozerolibrary. - Everything worked as expected.
- Attempt on Raspberry Pi 5:
- Followed the same steps as for the Raspberry Pi 4.
- Used Python with the
gpiozerolibrary, which is supposed to support Raspberry Pi 5. - Encountered the following errors:
PinFactoryFallback: Falling back from lgpio: No module named 'lgpio'
warnings.warn(
Traceback (most recent call last):
File "/workspace/demo-led/venv/lib/python3.11/site-packages/gpiozero/pins/pi.py", line 411, in pin
pin = self.pins[info]
~~~~~~~~~^^^^^^
KeyError: PinInfo(number=37, name='GPIO26', names=frozenset({'WPI25', 'GPIO26', '26', 'BCM26', 'BOARD37', 26, 'J8:37'}), pull='', row=19, col=1, interfaces=frozenset({'', 'sdio', 'spi', 'gpio', 'jtag', 'dpi'}))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/workspace/demo-led/led.py", line 10, in <module>
led = RGBLED(R_GPIO, G_GPIO, B_GPIO)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/demo-led/venv/lib/python3.11/site-packages/gpiozero/devices.py", line 108, in __call__
self = super().__call__(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/demo-led/venv/lib/python3.11/site-packages/gpiozero/output_devices.py", line 877, in __init__
self._leds = tuple(
^^^^^^
File "/workspace/demo-led/venv/lib/python3.11/site-packages/gpiozero/output_devices.py", line 878, in <genexpr>
LEDClass(pin, active_high=active_high, pin_factory=pin_factory)
File "/workspace/demo-led/venv/lib/python3.11/site-packages/gpiozero/devices.py", line 108, in __call__
self = super().__call__(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/demo-led/venv/lib/python3.11/site-packages/gpiozero/output_devices.py", line 392, in __init__
super().__init__(pin, active_high=active_high, initial_value=None,
File "/workspace/demo-led/venv/lib/python3.11/site-packages/gpiozero/output_devices.py", line 74, in __init__
super().__init__(pin, pin_factory=pin_factory)
File "/workspace/demo-led/venv/lib/python3.11/site-packages/gpiozero/mixins.py", line 75, in __init__
super().__init__(*args, **kwargs)
File "/workspace/demo-led/venv/lib/python3.11/site-packages/gpiozero/devices.py", line 553, in __init__
pin = self.pin_factory.pin(pin)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/demo-led/venv/lib/python3.11/site-packages/gpiozero/pins/pi.py", line 413, in pin
pin = self.pin_class(self, info)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/demo-led/venv/lib/python3.11/site-packages/gpiozero/pins/rpigpio.py", line 101, in __init__
GPIO.setup(self._number, GPIO.IN, self.GPIO_PULL_UPS[self._pull])
RuntimeError: Cannot determine SOC peripheral base address
- Additionally, when I try to manually export a GPIO pin with
echo 26 > /sys/class/gpio/exportas mentioned in the documentation, I get:
bash: echo: write error: Invalid argument
I’m looking for guidance on the following points:
- Is GPIO access enabled by default for the Raspberry Pi 5 on Balena OS?
- Are there any additional steps or configurations needed specifically for the Raspberry Pi 5 to enable GPIO access?
- Is there support for
lgpioor an equivalent library that works seamlessly withgpiozeroon the Raspberry Pi 5?
Any insights or suggestions to resolve this issue would be greatly appreciated. Thank you for your assistance!