Kernel 6.6.47 changed the GPIO chip definition on Raspberry 5 and broke Seatalk1
sailoog opened this issue · 12 comments
In previous kernels the GPIO chip definition was "gpiochip0" for Raspberry Pi 4 and "gpiochip4" for Raspberry Pi 5. Now both are "gpiochip0" in latest kernel. Seatalk1 in Signal K is broken for Raspberry Pi 5 right now. We should just change this to get it working again:
Waiting for @astuder to wake up to confirm :)
Grrr :(
I will add a check for kernel version (/proc/version, or Python's platform.version from a quick search).
Why not make that configurable?
IMO the issue is a bit too low-level to confront users with.. even having to select the GPIO library is already border-line.
Seeing the error message reported in the OpenMarine forum, I think the simplest approach is to check for the file gpiochip4
and fall back to gpiochip0
if not present. That should keep working if Raspberry Pi foundation is flip-flopping on this change.
I will verify that with my Pi 5 later today.
Ok, looks a bit more complicated.
https://forums.raspberrypi.com/viewtopic.php?t=364196
I will investigate the method discussed in the PDF linked in the second post of that thread.
Agree, this is a lot to ask to users because there is not much information documenting this.
It seems that there is a symlink /dev/gpiochip-rpi I will test this in different scenarios too.
Unless they just introduced it, I don't think /dev/gpiochip-rpi is available on a stock Pi image. At least its not present on my non-updated Pi 5.
@sailoog can you run this script on a system with the update?
import gpiod
c = 0
while gpiod.is_gpiochip_device(f"/dev/gpiochip{c}"):
with gpiod.Chip(f"/dev/gpiochip{c}") as chip:
info = chip.get_info()
print(f"{info.name} [{info.label}] ({info.num_lines} lines)")
c += 1
on my non-updated Pi 5 it returns
gpiochip0 [gpio-brcmstb@107d508500] (32 lines)
gpiochip1 [gpio-brcmstb@107d508520] (4 lines)
gpiochip2 [gpio-brcmstb@107d517c00] (17 lines)
gpiochip3 [gpio-brcmstb@107d517c20] (6 lines)
gpiochip4 [pinctrl-rp1] (54 lines)
I made a new image for the Pi 5. Of course, the script above doesn't work with gpiod v1.x. Here's the same script for v1.x:
import gpiod
print(f"gpiod v{gpiod.__version__}")
for chip in gpiod.ChipIter():
print(f"{chip.name()} [{chip.label()}] ({chip.num_lines()} lines)")
on fresh new image, GPIO still is on gpiochip4:
gpiod v1.6.3
gpiochip0 [gpio-brcmstb@107d508500] (32 lines)
gpiochip1 [gpio-brcmstb@107d508520] (4 lines)
gpiochip2 [gpio-brcmstb@107d517c00] (17 lines)
gpiochip3 [gpio-brcmstb@107d517c20] (6 lines)
gpiochip4 [pinctrl-rp1] (54 lines)
My kernel version is 6.6.31.. will try to update that after lunch
Ok, that was quicker than expected. After running rpi-update I'm on kernel 6.6.50, and pinctrl-rp1
is now on gpiochip0
:
gpiod v1.6.3
gpiochip0 [pinctrl-rp1] (54 lines)
gpiochip10 [gpio-brcmstb@107d508500] (32 lines)
gpiochip11 [gpio-brcmstb@107d508520] (4 lines)
gpiochip12 [gpio-brcmstb@107d517c00] (17 lines)
gpiochip13 [gpio-brcmstb@107d517c20] (6 lines)
So yes, I can reproduce.
Tested on Raspberry 4 and 5, kernel 6.6.47 (stable), gpiod 1 and 2. No issues.