From 8d559ee9e55f66ce5a9dfbfbbffff1a469b2c7ae Mon Sep 17 00:00:00 2001 From: s-martin Date: Sun, 22 Dec 2024 13:43:30 +0000 Subject: [PATCH 1/9] replace RPi.GPIO with rpi-lgpio --- requirements.txt | 3 ++- scripts/installscripts/install-jukebox.sh | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index f4424e001..b20391dc7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,8 @@ evdev git+https://github.com/lthiery/SPI-Py.git#egg=spi-py yt-dlp pyserial -RPi.GPIO +# use shim to keep current RPi.GPIO behavior also under Bookworm - see https://github.com/MiczFlor/RPi-Jukebox-RFID/issues/2313 +rpi-lgpio # Type checking for python # typing diff --git a/scripts/installscripts/install-jukebox.sh b/scripts/installscripts/install-jukebox.sh index 28d0efbfc..3d851927e 100644 --- a/scripts/installscripts/install-jukebox.sh +++ b/scripts/installscripts/install-jukebox.sh @@ -948,6 +948,9 @@ 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 rpi-gpio + # Install required spotify packages if [ "${SPOTinstall}" == "YES" ]; then echo "Installing dependencies for Spotify support..." From 71218bb25f0901f19d9542b85e7db97bd56cea46 Mon Sep 17 00:00:00 2001 From: s-martin Date: Tue, 31 Dec 2024 16:08:29 +0100 Subject: [PATCH 2/9] Update scripts/installscripts/install-jukebox.sh Co-authored-by: Alvin Schiller <103769832+AlvinSchiller@users.noreply.github.com> --- scripts/installscripts/install-jukebox.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/installscripts/install-jukebox.sh b/scripts/installscripts/install-jukebox.sh index 3d851927e..ea0562965 100644 --- a/scripts/installscripts/install-jukebox.sh +++ b/scripts/installscripts/install-jukebox.sh @@ -949,7 +949,7 @@ install_main() { 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 rpi-gpio + sudo python3 -m pip uninstall -y -q rpi-gpio # Install required spotify packages if [ "${SPOTinstall}" == "YES" ]; then From b7b330a13b4f4795c64dca3aef49db94442ef5a6 Mon Sep 17 00:00:00 2001 From: Alvin Schiller <103769832+AlvinSchiller@users.noreply.github.com> Date: Thu, 2 Jan 2025 23:16:35 +0100 Subject: [PATCH 3/9] fix: add exclusion for libs (RPi.GPIO). add tests --- packages-excluded.txt | 5 +++ requirements-excluded.txt | 5 +++ scripts/installscripts/install-jukebox.sh | 21 ++++++++++-- .../installscripts/tests/test_installation.sh | 34 ++++++++++++++++--- 4 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 packages-excluded.txt create mode 100644 requirements-excluded.txt diff --git a/packages-excluded.txt b/packages-excluded.txt new file mode 100644 index 000000000..1618cb99a --- /dev/null +++ b/packages-excluded.txt @@ -0,0 +1,5 @@ +# Remove exluded libs, if installed - see https://github.com/MiczFlor/RPi-Jukebox-RFID/pull/2469 +# Define packages for apt-get. These must be removed with +# 'sed 's/#.*//g' packages.txt | xargs sudo apt-get remove' + +python3-rpi.gpio diff --git a/requirements-excluded.txt b/requirements-excluded.txt new file mode 100644 index 000000000..96d214372 --- /dev/null +++ b/requirements-excluded.txt @@ -0,0 +1,5 @@ +# Remove exluded libs, if installed - see https://github.com/MiczFlor/RPi-Jukebox-RFID/pull/2469 +# 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 diff --git a/scripts/installscripts/install-jukebox.sh b/scripts/installscripts/install-jukebox.sh index ea0562965..47343cb33 100644 --- a/scripts/installscripts/install-jukebox.sh +++ b/scripts/installscripts/install-jukebox.sh @@ -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" @@ -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 @@ -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 + 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 @@ -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 + ${pip_uninstall} -r "${jukebox_dir}"/requirements-excluded.txt # Install required spotify packages if [ "${SPOTinstall}" == "YES" ]; then @@ -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 + 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 diff --git a/scripts/installscripts/tests/test_installation.sh b/scripts/installscripts/tests/test_installation.sh index 3f3aeebd8..243f3a5fc 100755 --- a/scripts/installscripts/tests/test_installation.sh +++ b/scripts/installscripts/tests/test_installation.sh @@ -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() { @@ -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 @@ -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() { @@ -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 @@ -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() { From d7a78c040b02ffc6024506c1288d14d32bbcfe71 Mon Sep 17 00:00:00 2001 From: Alvin Schiller <103769832+AlvinSchiller@users.noreply.github.com> Date: Thu, 2 Jan 2025 23:16:54 +0100 Subject: [PATCH 4/9] fix: add no-deps for rc522 --- components/rfid-reader/RC522/requirements.txt | 6 +++++- components/rfid-reader/RC522/setup_rc522.sh | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/components/rfid-reader/RC522/requirements.txt b/components/rfid-reader/RC522/requirements.txt index 312014b2c..ebec34374 100644 --- a/components/rfid-reader/RC522/requirements.txt +++ b/components/rfid-reader/RC522/requirements.txt @@ -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. +#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 diff --git a/components/rfid-reader/RC522/setup_rc522.sh b/components/rfid-reader/RC522/setup_rc522.sh index b6333767b..0397112b2 100644 --- a/components/rfid-reader/RC522/setup_rc522.sh +++ b/components/rfid-reader/RC522/setup_rc522.sh @@ -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 From 1b56ad14237d1bba3f407282438f27c6b4208b0b Mon Sep 17 00:00:00 2001 From: Alvin Schiller <103769832+AlvinSchiller@users.noreply.github.com> Date: Thu, 2 Jan 2025 23:17:15 +0100 Subject: [PATCH 5/9] fix: add used package to definition --- packages.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/packages.txt b/packages.txt index 68e201c29..2e10e5dd5 100644 --- a/packages.txt +++ b/packages.txt @@ -28,3 +28,4 @@ python3-wheel python3-mutagen python3-gpiozero python3-spidev +wget From a687a4b62b54ef29bf8dc394947360598d61f968 Mon Sep 17 00:00:00 2001 From: Alvin Schiller <103769832+AlvinSchiller@users.noreply.github.com> Date: Thu, 2 Jan 2025 23:17:27 +0100 Subject: [PATCH 6/9] fix: update docs --- CONTRIBUTING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 44b4ff13b..dc1956863 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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`)! ### Additional Resources From ab57ad6f60a3f6725c4f8ab57c663c268adfb1c9 Mon Sep 17 00:00:00 2001 From: Alvin Schiller <103769832+AlvinSchiller@users.noreply.github.com> Date: Thu, 2 Jan 2025 23:58:52 +0100 Subject: [PATCH 7/9] fix: remove python-gpiozero dependecy as it is not used --- packages.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/packages.txt b/packages.txt index 2e10e5dd5..a68fdb8e2 100644 --- a/packages.txt +++ b/packages.txt @@ -26,6 +26,5 @@ python3-pip python3-setuptools python3-wheel python3-mutagen -python3-gpiozero python3-spidev wget From 2d4b5b8b28f88ab599161def295c7b0b6e440920 Mon Sep 17 00:00:00 2001 From: Alvin Schiller <103769832+AlvinSchiller@users.noreply.github.com> Date: Sun, 5 Jan 2025 14:29:40 +0100 Subject: [PATCH 8/9] Update docs Co-authored-by: s-martin --- CONTRIBUTING.md | 2 +- components/rfid-reader/RC522/requirements.txt | 2 +- packages-excluded.txt | 2 +- requirements-excluded.txt | 2 +- scripts/installscripts/install-jukebox.sh | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dc1956863..e443a526f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -94,7 +94,7 @@ 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`)! + > The original `RPi.GPIO` package 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`)! ### Additional Resources diff --git a/components/rfid-reader/RC522/requirements.txt b/components/rfid-reader/RC522/requirements.txt index ebec34374..b2f7aa89f 100644 --- a/components/rfid-reader/RC522/requirements.txt +++ b/components/rfid-reader/RC522/requirements.txt @@ -1,7 +1,7 @@ # RC522 related requirements # 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. +#pi-rc522 has RPi.GPIO as a dependency which is broken since kernel 6.6. #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 diff --git a/packages-excluded.txt b/packages-excluded.txt index 1618cb99a..31daa451d 100644 --- a/packages-excluded.txt +++ b/packages-excluded.txt @@ -1,4 +1,4 @@ -# Remove exluded libs, if installed - see https://github.com/MiczFlor/RPi-Jukebox-RFID/pull/2469 +# Remove excluded libs, if installed - see https://github.com/MiczFlor/RPi-Jukebox-RFID/pull/2469 # Define packages for apt-get. These must be removed with # 'sed 's/#.*//g' packages.txt | xargs sudo apt-get remove' diff --git a/requirements-excluded.txt b/requirements-excluded.txt index 96d214372..5d407f43c 100644 --- a/requirements-excluded.txt +++ b/requirements-excluded.txt @@ -1,4 +1,4 @@ -# Remove exluded libs, if installed - see https://github.com/MiczFlor/RPi-Jukebox-RFID/pull/2469 +# Remove excluded libs, if installed - see https://github.com/MiczFlor/RPi-Jukebox-RFID/pull/2469 # 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. diff --git a/scripts/installscripts/install-jukebox.sh b/scripts/installscripts/install-jukebox.sh index 47343cb33..801d5ef15 100644 --- a/scripts/installscripts/install-jukebox.sh +++ b/scripts/installscripts/install-jukebox.sh @@ -919,7 +919,7 @@ 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 + # Remove excluded libs, if installed - see https://github.com/MiczFlor/RPi-Jukebox-RFID/pull/2469 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 @@ -954,7 +954,7 @@ install_main() { echo "${VERSION_NO} - ${COMMIT_NO} - ${USED_BRANCH}" > ${jukebox_dir}/settings/version chmod 777 ${jukebox_dir}/settings/version - # Remove exluded libs, if installed - see https://github.com/MiczFlor/RPi-Jukebox-RFID/pull/2469 + # Remove excluded libs, if installed - see https://github.com/MiczFlor/RPi-Jukebox-RFID/pull/2469 ${pip_uninstall} -r "${jukebox_dir}"/requirements-excluded.txt # Install required spotify packages From 15f4737cdcf937de5f19fb538bdff68c765bd5db Mon Sep 17 00:00:00 2001 From: Alvin Schiller <103769832+AlvinSchiller@users.noreply.github.com> Date: Thu, 9 Jan 2025 23:53:21 +0100 Subject: [PATCH 9/9] fix: update gpiocontrol docs for rpi-lgpio --- components/gpio_control/README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/gpio_control/README.md b/components/gpio_control/README.md index 986526092..dca66ab21 100644 --- a/components/gpio_control/README.md +++ b/components/gpio_control/README.md @@ -1,5 +1,10 @@ # GPIO CONTROL +> [!IMPORTANT] +> Since v2.9.0 the original `RPi.GPIO` library was replaced with `rpi-lgpio` to support the GPIO access in newer OS versions (>= kernel 6.6). +> This new library is api compliant to the old one, but behaves differently in some aspects (see [rpi-lgpio differences](https://rpi-lgpio.readthedocs.io/en/latest/differences.html)). +> Especially the `Debounce` difference changes the behavior of the `bouncetime` property! The actions are not triggered immediately anymore, but after the signal has been stable for the specified time, causing a delay. This also has impact to the usage of `hold_time` and `antibouncehack`! + This service enables the control of different GPIO input & output devices for controlling the Phoniebox. It uses to a configuration file to configure the active devices. @@ -74,7 +79,7 @@ However, a button has more parameters than these. In the following comprehensive Holding the button even longer than `hold_time` will cause no further action unless you are in the `Repeat` or `SecondFuncRepeat` mode. -* **hold_time**: Reference time for this buttons `hold_mode` feature in seconds. Default is `0.3`. This setting is ignored if `hold_mode` is unset or `None` +* **hold_time**: Reference time for this buttons `hold_mode` feature in seconds. Default is `0.3`. This setting is ignored if `hold_mode` is unset or `None`. Attention: `hold_time` is running **after** the action was triggered, so the total time will add up with `bouncetime`. * **functionCall2**: Secondary function, default is `None`. This setting is ignored unless `hold_mode` is set to `SecondFunc` or `SecondFuncRepeat`. * **functionCall2Args**: Arguments for secondary function, default is `None`. Arguments are ignored, if `functionCall2` does not take any. * **pull_up_down**: Configures the internal Pull up/down resistors. Valid settings: @@ -85,7 +90,7 @@ However, a button has more parameters than these. In the following comprehensive * `falling` (Default). Triggers if the GPIO voltage goes down. * `rising`. Triggers only if the GPIO voltage goes up. * `both`. Triggers in both cases. -* **bouncetime**: This is a setting of the GPIO library to limit bouncing effects during button usage. Default is `500` ms. +* **bouncetime**: This is a setting of the GPIO library to limit bouncing effects during button usage. The action is only triggered after the signal has been stable for the defined time. Default is `500` ms. * **antibouncehack**: Despite the integrated bounce reduction of the GPIO library some users may notice false triggers of their buttons (e.g. unrequested / double actions when releasing the button). If you encounter such problems, try setting this to `True` to activate an additional countermeasure. > [!NOTE]