Skip to content

Commit 4746039

Browse files
Merge pull request #481 from AndreWohnsland/dev
Fix gpio issues on the new raspberry pi5 kernel
2 parents 704a6dc + 92abf26 commit 4746039

File tree

6 files changed

+23
-24
lines changed

6 files changed

+23
-24
lines changed

docs/troubleshooting.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ A better way would be to add the user to the gpio/other needed groups, so you ca
132132
# for v1: change this line
133133
# uv run --extra v1 --extra nfc runme.py
134134
# into:
135-
uv sync --extra v1 --extra nfc
135+
uv sync --inexact --extra v1 --extra nfc
136136
sudo -E .venv/bin/python runme.py
137137
# for v2: change this line
138138
# uv run --extra nfc api.py
139139
# into:
140-
uv sync --extra nfc
140+
uv sync --inexact --extra nfc
141141
sudo -E .venv/bin/python api.py
142142
```
143143

@@ -384,3 +384,17 @@ I've noticed when running as root (sudo python) and running as the pi user (pyth
384384
Using the pi user will result in the shown interfaces at CocktailBerry (and the program should work without root privilege).
385385
Setting the XDG_RUNTIME_DIR to use the qt5ct plugin may also work but is untested.
386386
Using the users environment with `sudo -E python runme.py` should also do the trick.
387+
388+
### Raspberry Pi 5 GPIO Issues
389+
390+
If you are using a Raspberry Pi 5, you may run into issues with the lgpio library for GPIO access.
391+
The latest installer should already address this issue.
392+
But if you are running an old installation and did a kernel update, some things might have changed.
393+
To fix possible issues with lgpio on the Raspberry Pi 5, please run the following commands:
394+
395+
```bash
396+
cd "$HOME/CocktailBerry/"
397+
sudo apt install liblgpio-dev
398+
uv pip install lgpio
399+
uv run --extra v1 --extra nfc runme.py
400+
```

scripts/all_in_one.sh

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export DEBIAN_FRONTEND=noninteractive
3737
export NEEDRESTART_MODE=a
3838

3939
echo "~~ Disabling needrestart kernel hints ~~"
40-
sed -i "s/#\$nrconf{kernelhints} = -1;/\$nrconf{kernelhints} = -1;/g" /etc/needrestart/needrestart.conf || echo "> Could not disable needrestart kernel hints, but continuing ..."
40+
sudo sed -i "s/#\$nrconf{kernelhints} = -1;/\$nrconf{kernelhints} = -1;/g" /etc/needrestart/needrestart.conf || echo "> Could not disable needrestart kernel hints, but continuing ..."
4141

4242
echo "~~ Updating system to latest version, depending on your system age, this may take some time ... ~~"
4343
sudo apt-get update && sudo apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
@@ -57,22 +57,6 @@ fi
5757
echo "~~ linking python to python3 if not already done ~~"
5858
sudo apt install python-is-python3
5959

60-
# steps for python >= 3.11
61-
echo "~~ Check that Python version is at least 3.11 ~~"
62-
version=$(python -V 2>&1 | grep -Po '(?<=Python )(.+)')
63-
parsedVersion="${version//./}"
64-
echo "> Detected version: $version"
65-
if [[ "$parsedVersion" -lt "3110" ]]; then
66-
echo "> Python must be at least 3.11. Please upgrade your Python or the system to use CocktailBerry."
67-
echo "> You can check your local Python version with 'python -V'"
68-
echo "> If you have an older system, python3 -V may use the python 3, you should set up python that the python command uses python 3"
69-
echo "> For a tutorial, you can look at https://alluaravind1313.medium.com/make-python3-as-default-in-ubuntu-machine-572431b69094"
70-
echo "> 'apt install python-is-python3' may also fix this, but should already be installed previous this step"
71-
exit 1
72-
else
73-
echo "> You got a valid Python version."
74-
fi
75-
7660
# might also need to install python-venv
7761
echo "~~ Check if python3-venv and ensurepip are available ~~"
7862
python3 -m venv --help >/dev/null 2>&1

scripts/setup.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ else
4646
fi
4747

4848
echo "> Installing nmcli, this is needed for wifi setup"
49-
sudo apt install network-manager
49+
sudo apt install network-manager liblgpio-dev
5050

5151
# using desktop file for autostart
5252
echo "> Copying desktop file to: /etc/xdg/autostart/cocktail.desktop"
@@ -101,15 +101,16 @@ else
101101
echo "> Installing needed Python libraries, this may take a while depending on your OS (especially in v1), so it is time for a coffee break :)"
102102
# v1 needs to sync with system python (for pyqt)
103103
if [[ "$V2_FLAG" = true ]]; then
104-
uv sync --extra nfc || echo "ERROR: Could not install Python libraries with uv" >&2
104+
uv sync --inexact --extra nfc || echo "ERROR: Could not install Python libraries with uv" >&2
105105
else
106106
echo "> Installing PyQt"
107107
sudo apt-get -y install python3-pyqt6 || echo "ERROR: Could not install PyQt6" >&2
108-
uv sync --extra v1 --extra nfc || echo "ERROR: Could not install Python libraries with uv" >&2
108+
uv sync --inexact --extra v1 --extra nfc || echo "ERROR: Could not install Python libraries with uv" >&2
109109
fi
110110
if is_raspberry_pi5; then
111111
sudo usermod -aG gpio "$(whoami)"
112112
newgrp gpio
113+
uv pip install lgpio
113114
fi
114115
# on none RPi devices, we need to set control to the GPIOs, and set user to sudoers
115116
if ! is_raspberry_pi; then

scripts/v1-launcher.sh

100644100755
File mode changed.

scripts/v2-launcher.sh

100644100755
File mode changed.

src/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def restart_v1() -> None:
113113
if "SUDO_USER" in os.environ:
114114
cmd = ["sudo", "-E", python]
115115
if uv_executable:
116-
subprocess.run([uv_executable, "sync", *uv_args], check=True)
116+
subprocess.run([uv_executable, "sync", "--inexact", *uv_args], check=True)
117117
os.execvp(cmd[0], [*cmd, str(EXECUTABLE_V1), *arguments])
118118

119119

@@ -134,7 +134,7 @@ def restart_v2() -> None:
134134
if "SUDO_USER" in os.environ:
135135
cmd = ["sudo", "-E", python]
136136
if uv_executable:
137-
subprocess.run([uv_executable, "sync"], check=True)
137+
subprocess.run([uv_executable, "sync", "--inexact"], check=True)
138138
os.execvp(cmd[0], [*cmd, str(EXECUTABLE_V2), *arguments])
139139

140140

0 commit comments

Comments
 (0)