Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace RPi.GPIO with rpi-lgpio for V2 legacy #2469

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ If the code change results in a test failure, we will make our best effort to co

* All code has to run under the stable and legacy version of Raspberry Pi OS (please check if currently even an older version is still supported).
* For GPIO all code should work with **RPi.GPIO**. gpiozero is currently not intended to use.
> [!IMPORTANT]
> The original `RPi.GPIO` packages is currently not compatible with the 6.6 kernel (since bookworm). Therefore the lib `rpi-lgpio` is used as a replacement, which is api compliant. `RPi.GPIO` must not be installed directly or as a dependency as this breaks GPIO functionality (see `requirements-excluded`)!
AlvinSchiller marked this conversation as resolved.
Show resolved Hide resolved

### Additional Resources

Expand Down
6 changes: 5 additions & 1 deletion components/rfid-reader/RC522/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# RC522 related requirements
# You need to install these with `sudo python3 -m pip install --upgrade --force-reinstall -q -r requirements.txt`
# You need to install these with `sudo python3 -m pip install --upgrade --force-reinstall --no-deps -q -r requirements.txt`

#pi-rc522 has RPi.GPIO as a dependecy which is broken since kernel 6.6.
AlvinSchiller marked this conversation as resolved.
Show resolved Hide resolved
#Skip dependencies whith --no-deps and use the rpi-lgpio lib as a replacement, which should already be installed from the main installation.

spidev # dep of pi-rc522
pi-rc522==2.3.0
2 changes: 1 addition & 1 deletion components/rfid-reader/RC522/setup_rc522.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ case "$choice" in
esac

printf "Installing Python requirements for RC522...\n"
sudo python3 -m pip install --upgrade --force-reinstall -q -r "${JUKEBOX_HOME_DIR}"/components/rfid-reader/RC522/requirements.txt
sudo python3 -m pip install --upgrade --force-reinstall --no-deps -q -r "${JUKEBOX_HOME_DIR}"/components/rfid-reader/RC522/requirements.txt

printf "Activating SPI...\n"
sudo raspi-config nonint do_spi 0
Expand Down
5 changes: 5 additions & 0 deletions packages-excluded.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Remove exluded libs, if installed - see https://github.com/MiczFlor/RPi-Jukebox-RFID/pull/2469
AlvinSchiller marked this conversation as resolved.
Show resolved Hide resolved
# Define packages for apt-get. These must be removed with
# 'sed 's/#.*//g' packages.txt | xargs sudo apt-get remove'

python3-rpi.gpio
2 changes: 1 addition & 1 deletion packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ python3-pip
python3-setuptools
python3-wheel
python3-mutagen
python3-gpiozero
python3-spidev
wget
5 changes: 5 additions & 0 deletions requirements-excluded.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Remove exluded libs, if installed - see https://github.com/MiczFlor/RPi-Jukebox-RFID/pull/2469
AlvinSchiller marked this conversation as resolved.
Show resolved Hide resolved
# Libraries which must be excluded. These must be removed with
# `sudo python3 -m pip uninstall -y -r requirements-excluded.txt` before you can run this.

RPi.GPIO
21 changes: 18 additions & 3 deletions scripts/installscripts/install-jukebox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ JUKEBOX_BACKUP_DIR="${HOME_DIR}/BACKUP"

# Get the Raspberry Pi OS codename (e.g. buster, bullseye, ...)
OS_CODENAME="$( . /etc/os-release; printf '%s\n' "$VERSION_CODENAME"; )"
# Get the Raspberry Pi OS version id (e.g. 11, 12, ...)
OS_VERSION_ID="$( . /etc/os-release; printf '%s\n' "$VERSION_ID"; )"


WIFI_INTERFACE="wlan0"

Expand Down Expand Up @@ -837,6 +840,7 @@ install_main() {
local apt_get="sudo apt-get -qq --yes"
local allow_downgrades="--allow-downgrades --allow-remove-essential --allow-change-held-packages"
local pip_install="sudo python3 -m pip install --upgrade --force-reinstall -q"
local pip_uninstall="sudo python3 -m pip uninstall -y -q"

clear

Expand Down Expand Up @@ -915,6 +919,8 @@ install_main() {
source "${jukebox_dir}"/scripts/helperscripts/inc.helper.sh
source "${jukebox_dir}"/scripts/helperscripts/inc.networkHelper.sh

# Remove exluded libs, if installed - see https://github.com/MiczFlor/RPi-Jukebox-RFID/pull/2469
AlvinSchiller marked this conversation as resolved.
Show resolved Hide resolved
call_with_args_from_file "${jukebox_dir}"/packages-excluded.txt ${apt_get} ${allow_downgrades} remove

# some packages are only available on raspberry pi's but not on test docker containers running on x86_64 machines
if [[ $(uname -m) =~ ^armv.+$ ]]; then
Expand Down Expand Up @@ -948,8 +954,8 @@ install_main() {
echo "${VERSION_NO} - ${COMMIT_NO} - ${USED_BRANCH}" > ${jukebox_dir}/settings/version
chmod 777 ${jukebox_dir}/settings/version

# Remove RPi.GPIO, if still installed - see https://github.com/MiczFlor/RPi-Jukebox-RFID/issues/2313
sudo python3 -m pip uninstall -y -q rpi-gpio
# Remove exluded libs, if installed - see https://github.com/MiczFlor/RPi-Jukebox-RFID/pull/2469
AlvinSchiller marked this conversation as resolved.
Show resolved Hide resolved
${pip_uninstall} -r "${jukebox_dir}"/requirements-excluded.txt

# Install required spotify packages
if [ "${SPOTinstall}" == "YES" ]; then
Expand Down Expand Up @@ -982,9 +988,18 @@ install_main() {
sudo chmod 440 "${sudoers_mopidy}"
fi

# prepare lgpio build for bullseye as the binaries are broken
local pip_install_options=""
if [ "${OS_VERSION_ID}" -le "11" ]; then
${apt_get} install swig unzip
mkdir -p tmp && cd tmp && wget -q http://abyz.me.uk/lg/lg.zip && unzip lg.zip > /dev/null && cd lg && make > /dev/null && sudo make install > /dev/null
s-martin marked this conversation as resolved.
Show resolved Hide resolved
cd "${HOME_DIR}" && sudo rm -rf tmp > /dev/null
pip_install_options="--no-binary=lgpio"
fi

# Install more required packages
echo "Installing additional Python packages..."
${pip_install} -r "${jukebox_dir}"/requirements.txt
${pip_install} -r "${jukebox_dir}"/requirements.txt ${pip_install_options}

samba_config

Expand Down
34 changes: 30 additions & 4 deletions scripts/installscripts/tests/test_installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ call_with_args_from_file() {
local package_file="$1"
shift

sed 's/.*#egg=//g' ${package_file} | sed -E 's/(#|=|>|<).*//g' | xargs "$@"
sed 's/.*#egg=//g' ${package_file} | sed -E 's/(#|=|>|<|;).*//g' | xargs "$@"
}

verify_apt_packages() {
Expand All @@ -344,7 +344,9 @@ verify_apt_packages() {
local packages_autohotspot_dhcpcd=$(call_with_args_from_file "${jukebox_dir}"/packages-autohotspot_dhcpcd.txt echo)
local packages_autohotspot_NetworkManager=$(call_with_args_from_file "${jukebox_dir}"/packages-autohotspot_NetworkManager.txt echo)

printf "\nTESTING installed packages...\n\n"
local packages_excluded=$(call_with_args_from_file "${jukebox_dir}"/packages-excluded.txt echo)

printf "\nTESTING apt packages...\n\n"

# also check for spotify packages if it has been installed
if [[ "${SPOTinstall}" == "YES" ]]; then
Expand Down Expand Up @@ -378,6 +380,17 @@ verify_apt_packages() {
fi
((tests++))
done

for package in ${packages_excluded}
do
if [[ $(echo "${apt_list_installed}" | grep -i "${package}.*installed") ]]; then
echo " ERROR: ${package} is installed (excluded)"
((failed_tests++))
else
echo " ${package} is not installed (excluded)"
fi
((tests++))
done
}

verify_pip_packages() {
Expand All @@ -388,7 +401,9 @@ verify_pip_packages() {
local modules_rc522=$(call_with_args_from_file "${jukebox_dir}"/components/rfid-reader/RC522/requirements.txt echo)
local deviceName="${jukebox_dir}"/scripts/deviceName.txt

printf "\nTESTING installed pip modules...\n\n"
local modules_excluded=$(call_with_args_from_file "${jukebox_dir}"/requirements-excluded.txt echo)

printf "\nTESTING pip modules...\n\n"

# also check for spotify pip modules if it has been installed
if [[ "${SPOTinstall}" == "YES" ]]; then
Expand All @@ -415,11 +430,22 @@ verify_pip_packages() {
if [[ $(echo "${pip_list_installed}" | grep -i "${module}") ]]; then
echo " ${module} is installed"
else
echo " ERROR: pip module ${module} is not installed"
echo " ERROR: ${module} is not installed"
((failed_tests++))
fi
((tests++))
done

for module in ${modules_excluded}
do
if [[ $(echo "${pip_list_installed}" | grep -i "${module}") ]]; then
echo " ERROR: ${module} is installed (excluded)"
((failed_tests++))
else
echo " ${module} is not installed (excluded)"
fi
((tests++))
done
}

verify_samba_config() {
Expand Down
Loading