Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4060

Troubleshooting • On Raspberry Pi 5, one should use GPIO chip 4, not chip 0

$
0
0
Posting this to save you folks half a day - because it took me that long.

So , my program uses GPIO lines via the Linux kernel "gpio.h" library, using calls like open(), ioctl(), poll() and read().

I imagined it was rock solid... then I received my fancy new Raspberry Pi 5. :)

Short summary: externally accessible GPIO lines have moved to "/dev/gpiochip4" instead of "/dev/gpiochip0" on Raspberry Pi 5. Don't play with the other chips unless you know about them (I don't).

My program failed silently, as if all GPIO lines were dead. I took out measurement tools and indeed, none of the lines were changing state when my program ran. Finally, I wrote a routine that prints out the list of lines for a given GPIO chip, and whoa... different line count, different line names, what is happening? Then I listed the lines for all chips, and reaching chip 4, recognized a familiar landscape. And my program runs now. :)

For anyone curious enough:

Code:

gpiochip0gpio-brcmstb@107d508500lines: 320  -1  2712_BOOT_CS_N2  2712_BOOT_MISO3  2712_BOOT_MOSI4  2712_BOOT_SCLK5  -6  -7  -8  -9  -10  -11  -12  -13  -14  PCIE_SDA15  PCIE_SCL16  -17  -18  -19  -20  PWR_GPIO21  2712_G21_FS22  -23  -24  BT_RTS25  BT_CTS26  BT_TXD27  BT_RXD28  WL_ON29  BT_ON30  WIFI_SDIO_CLK31  WIFI_SDIO_CMDgpiochip1gpio-brcmstb@107d508520lines: 40  WIFI_SDIO_D01  WIFI_SDIO_D12  WIFI_SDIO_D23  WIFI_SDIO_D3gpiochip2gpio-brcmstb@107d517c00lines: 170  RP1_SDA1  RP1_SCL2  RP1_RUN3  SD_IOVDD_SEL4  SD_PWR_ON5  SD_CDET_N6  SD_FLG_N7  -8  2712_WAKE9  2712_STAT_LED10 -11 -12 PMIC_INT13 UART_TX_FS14 UART_RX_FS15 -16 -gpiochip3gpio-brcmstb@107d517c20lines: 60  HDMI0_SCL1  HDMI0_SDA2  HDMI1_SCL3  HDMI1_SDA4  PMIC_SCL5  PMIC_SDAgpiochip4 <-- USE THIS CHIP!pinctrl-rp1lines: 540  ID_SDA1  ID_SCL2  GPIO23  GPIO34  GPIO45  GPIO56  GPIO67  GPIO78  GPIO89  GPIO910  GPIO1011  GPIO1112  GPIO1213  GPIO1314  GPIO1415  GPIO1516  GPIO1617  GPIO1718  GPIO1819  GPIO1920  GPIO2021  GPIO2122  GPIO2223  GPIO2324  GPIO2425  GPIO2526  GPIO2627  GPIO2728  PCIE_RP1_WAKE29  FAN_TACH30  HOST_SDA31  HOST_SCL32  ETH_RST_N33  -34  CD0_IO0_MICCLK35  CD0_IO0_MICDAT036  RP1_PCIE_CLKREQ_N37  -38  CD0_SDA39  CD0_SCL40  CD1_SDA41  CD1_SCL42  USB_VBUS_EN43  USB_OC_N44  RP1_STAT_LED45  FAN_PWM46  CD1_IO0_MICCLK47  2712_WAKE48  CD1_IO1_MICDAT149  EN_MAX_USB_CUR50  -51  -52  -53  -

Statistics: Posted by diastrikos — Sat Apr 13, 2024 11:23 am



Viewing all articles
Browse latest Browse all 4060

Trending Articles