-
First let's fix the python module. This will replace RPi.GPIO with a newer module that uses the same commands.
sudo apt update && sudo apt install python3-rpi-lgpio --auto-remove --purge -y -
Next We need to fix the issue of pins not showing in /sys/class/gpio. We will use the 'sysfs-gpio-shim' by info-beamer https://github.com/info-beamer/sysfs-gpio-shim.
-
This is going to require building libgpiod2.1. Lets do that first.
cd ~ sudo apt install autoconf-archive -y git clone https://github.com/brgl/libgpiod.git cd libgpiod ./autogen.sh make sudo make install -
Next let's install the required libraries to compile sysfs-gpio-shim. We aren't going to compile just yet, we needed to build libgpiod and install libfuse3-dev before updating the kernel to 6.6.
sudo apt install libfuse3-dev -
Update the kernel to 6.6
sudo rpi-update sudo reboot -
Finally, it is time to build sysfs-gpio-shim
sudo remount cd ~ git clone https://github.com/info-beamer/sysfs-gpio-shim.git cd sysfs-gpio-shim git checkout ac2faee make -
Go to the /home/pi directory, and create a new script file
cd ~
nano kernel_gpio_fix.sh
-
Paste the following into that file and save it.
cd /home/pi/sysfs-gpio-shim GPIO_GID="$(cut -d: -f3 < <(getent group gpio))" sudo ./sysfs-gpio-shim -o default_permissions,allow_other,gid=$GPIO_GID /sys/class/gpio echo 12 > /sys/class/gpio/export echo 16 > /sys/class/gpio/exportMake i execuable
chmod +x kernel_gpio_fix.sh -
Place it in
rc.localso it runs as boot
sudo nano /etc/rc.local
-
Look for the line near the top starting with
rfkillRight below that line, add a new line with the followingbash /home/pi/kernel_gpio_fix.sh -
Now we need to edit direwatch.py in a few places. Let's start with making a backup of our work.
cd ~
cp direwatch.py direwatch.py.bak -v
nano direwatch.py
-
croll down until you find the imports. Put a
#in front ofimport LED, then addimport RPi.GPIO as GPIOto the bottom of the list belowimport numpy. -
Scroll down a bit more until you find
def bluetooth_connection_poll_thread():. In that function, remove the#in front of each line starting withGPIO(4 places) and add a#in front of each line starting withblue_led(3 places) -
reboot the system
sudo reboot
Bob's Your Uncle! The GPIO pins should be fixed for kernel 6.6.