Raspberry Pi 5 Support for GPIO Broken

I’m running the latest version of Volumio on a new Raspberry Pi 5 with a HifiBerry DAC2 HD. It seems to work fine in its default state, music plays and the interface functions. Bootup time is noticeably faster by about 20 seconds.

However this isn’t Bookworm. I could be wrong, but it looks like a Pi 5 kernel and libraries got backported to the old Bullseye version of Raspberry Pi OS that Volumio was already based on. That means that there’s NO support for interacting with the GPIO in any way. None of the GPIO-based plugins work at all. There are none of the new Bookworm utilities available in the configured repositories, and short of recompiling them, I doubt any of them would even work anyways.

That means there’s no way to configure external controls. No buttons, no rotary encoders, nothing. Even if I wanted to script those from scratch in the OS, it doesn’t seem possible without the proper utilities. That seems to render Volumio on Pi 5 pretty crippled.

1 Like

Please respect the free time of people who spend their private time to create free community plugins.
The plugins are not created by Volumio but by community members like yourself.

These plugins needs to be rewritten to work on a rPi5. Meaning people like yourself, need to free up time and spend money to buy a rPi5 to support your ranting free of charge.

So please respect these people and start programming.
Just as a small concept with 4 buttons, to show you how it can be done.

#!/bin/bash
# select
# pin GND - D0
GPIO0=13 # gpio-426 
GPIO1=16 # gpio-422
GPIO2=26 # gpio-406
GPIO3=20 # gpio-426
debug=1

while true; do
	sleep 1s
	STATUS0=$(gpioget gpiochip4 ${GPIO0})
	STATUS1=$(gpioget gpiochip4 ${GPIO1})
	STATUS2=$(gpioget gpiochip4 ${GPIO2})
	STATUS3=$(gpioget gpiochip4 ${GPIO3})
	if [ $debug == 1 ]; then
		echo "---------------------------------------------------"
			printf "GPIO 0: %s\n"  "${STATUS0}"
			printf "GPIO 1: %s\n"  "${STATUS1}"
			printf "GPIO 2: %s\n"  "${STATUS2}"
			printf "GPIO 3: %s\n"  "${STATUS3}"
	fi
	
	if   [ "$STATUS0" == 1 ]; then 
		echo "0" > '/home/volumio/scripts/status.txt'
	elif [ "$STATUS1" == 1 ]; then 
		echo "1" > '/home/volumio/scripts/status.txt'
	elif [ "$STATUS2" == 1 ]; then 
		echo "2" > '/home/volumio/scripts/status.txt'
	elif [ "$STATUS3" == 1 ]; then 
		echo "3" > '/home/volumio/scripts/status.txt'
	fi
done

Same for a rotary encoder, in python:

# Rotary encoder using evdev
# Add to /boot/userconfig.txt
# dtoverlay=rotary-encoder,pin_a=23,pin_b=24,relative_axis=1,steps-per-period=2
# Tweak pins and steps to match the encoder
 
import evdev
import subprocess
 
d = evdev.InputDevice('/dev/input/by-path/platform-rotary@17-event')
print('Rotary encoder device: {}'.format(d.name))
 
position = 0
 
for e in d.read_loop():
    print('Event: {}'.format(e))
    if e.type == evdev.ecodes.EV_REL:
        position += e.value
        print('Position: {}'.format(position))
        print('Value: {}' .format(e.value))
        if e.value > 0:
            subprocess.call('XAUTHORITY=~volumio/.Xauthority DISPLAY=:0 xdotool key Alt_L+Up', shell=True)
        else:
            subprocess.call('XAUTHORITY=~volumio/.Xauthority DISPLAY=:0 xdotool key Alt_L+Down', shell=True)

2 Likes

I’m not complaining about the plugins, I’m pointing out that Volumio as it currently exists is not suitable for GPIO plugin development on the Pi 5. The versions of piwiring, rpi.gpio and gpiozero that are included with Volumio and/or its configured repositories are no longer able to access the GPIO on the Pi 5.

Please read my previous response.
Everything is available and working on a rpi5, both GPIO and rotary encoders. Only not as plugin yet, but for sure if you code it yourself you get what you need.
If you don’t want to invest this time, be patient and respectful. or work very close with the developer of the rotary encoder @T0MR0 and provide what he asked.

but gpioget isn’t available on my system as far as I can see. What package is that from? How do I get that using the currently configured repositories?

Also, implying that I’m somehow freeloading is downright insulting

1 Like

if i recall correctly:

sudo apt-get update
sudo apt-get -y install gpiod
sudo apt-get -y install python3-libgpiod
1 Like

Thank you, that was very helpful. Would be helpful if that was included in the distributed image of Volumio

1 Like

Volumio comes with the bare minimum what is needed. It’s up to the user if they want something else.

Right, but here you are encouraging me to develop a plugin using tools that aren’t available in the base image… that’s not useful unless those tools are there by default. If you want to suggest I use functional tools that already exist in the base image, I’m all ears

1 Like

I am not suggesting anything. Either your patient and wait for the developer to provide an update or do it yourself. What do you think a plugin does when you install it. As starters installing packages.

2 Likes

Thank you!

1 Like

a little remark, even with the new release, the GPIO Button and GPIO Control plugin are still not working

as mentioned by @Wheaten those plugins needs to be rewritten to work on a RPi5

1 Like

I’m assuming that with the new release, those plugins now can be modified to work. At least with regards to the gpio-buttons plugin, it imports a library version that was no longer working at all with the Pi 5, so I figure these resources are being updated to newer versions that support the new board

2 Likes

the plugin must be re-written, nothing to do with the core Volumio system

it was the plugin that was downloading and using the library that is not maintained anymore and not compatible with RPi5

1 Like

What I’d love to see is the updated gpiozero library made available on the system without having to jump through hoops. Version 2.0 is available in more recent versions of Pi OS, but not in Volumio unless I add a different repository or install python3-pip which involves installing an entire build environment. That’s not feasible from the point of view of a simple plugin, I can’t be expecting Volumio users to have to do that, even if it’s automatic in the background.

1 Like

This won’t happen, as @Wheaten mentioned those libraries are not part of the Volumio core image.

if a certain plugin needs a library, it will be downloaded and installed during the setup of the plugin itself.

That’s too bad, it really hampers plugin development. Not everyone has time to waste re-inventing the wheel. Those libraries already implement basic functionalities that can be used with just 2 lines of code rather than over a dozen.

I just got gpiozero-2.0 installed on Volumio with just some basic additional package dependencies, but it requires creating a virtual python3 environment, which I’m pretty sure is beyond the scope of what a simple plugin should have to do

1 Like
sudo apt install python3-venv

The following NEW packages will be installed:
  python-pip-whl python3-venv python3.7-venv

And then inside a python3 virtual environment:

python3 -m pip install gpiozero

Installing collected packages: colorzero, gpiozero
Successfully installed colorzero-2.0 gpiozero-2.0

Now to see whether this library works on Volumio…

If it does, would it be out of the question to include a python3 venv in the default Volumio image specifically intended for plugin development? Throw a bunch of useful libraries in there as the volumio user and call it “volumio-plugins-env” to provide as an official plugin development environment and encourage anyone to create plugins more easily. I realize not everyone chooses python3 as their language of choice, but if Volumio had an “official” plugin environment that could be maintained and updated separately from the base OS, then these big OS changes that break things (like a new Raspberry Pi board being released) could be minimized and resolved quickly and easily in the future

1 Like

ugh, I give up. gpiozero is supposedly successfully installed in my venv:

(deadman-env) volumio@tamusique:~$ pipdeptree
gpiozero==2.0
└── colorzero [required: Any, installed: 2.0]
    └── setuptools [required: Any, installed: 40.8.0]
importlib-metadata==6.7.0
├── typing-extensions [required: >=3.6.4, installed: 4.7.1]
└── zipp [required: >=0.5, installed: 3.15.0]
pip==18.1
pipdeptree==2.9.6
pkg-resources==0.0.0

But attempting to run any simple script that calls on a gpiozero library results in this error:

(deadman-env) volumio@tamusique:~$ deadman-env/bin/python3 button-check.py
Traceback (most recent call last):
  File "button-check.py", line 1, in <module>
    from gpiozero import Button
  File "/home/volumio/deadman-env/lib/python3.7/site-packages/gpiozero/__init__.py", line 19, in <module>
    from .pins import (
  File "/home/volumio/deadman-env/lib/python3.7/site-packages/gpiozero/pins/__init__.py", line 21, in <module>
    from ..devices import Device
  File "/home/volumio/deadman-env/lib/python3.7/site-packages/gpiozero/devices.py", line 19, in <module>
    from importlib.metadata import entry_points
ModuleNotFoundError: No module named 'importlib.metadata'

Which makes no sense because the importlib-metadata module is right there in the venv. And it wasn’t even installed automatically, I had to install it myself because it’s not listed as a dependency by gpiozero.

I think the real problem is that an actual build environment is necessary to install many of the necessary modules, like an adequate pin factory that supports the Pi 5. Again, this is far outside the realm of plugin development. Until Volumio provides a plugin development environment, very few people are gonna be interested in developing or maintaining plugins. They’ll all just end up quitting everytime something breaks.

Also worth pointing out that Buster stops getting security updates in less than 6 months…

1 Like

importlib.metadata is a built-in module of Python 3.8. gpiozero imports this.

On Python 3.7.3 which Volumio uses, the import statement for the external module you installed manually should be from importlib_metadata import ...

1 Like