lcdgfx
lcdgfx copied to clipboard
Raspberry compatibility with Kernel 6.6
Hi, I'm asking for confirmation of the compatibility of the lcdgfx library with the latest versions of the operating system for Raspberry, based on Kernel 6.6 and Debian 12 where there have been several changes in the management of the GPIO pins and the pin numbering on the sysfs driver. Thank you Emanuele
First test went KO. Trying same configuration of my previous Raspbian, with an SPI SSD1351 128*128 where display perfectly working with: DisplaySSD1351_128x128x16_SPI display(24,{-1, {0}, 23, 20000000,-1,-1});
After upgraded OS to 6.6 kernel: Linux dev 6.6.74+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.74-1+rpt1 (2025-01-27) aarch64 GNU/Linux, i tried demos with: ./build_and_run.sh -p linux -f demos/ssd1351_demo but when i run compiled code, i got:
Failed to allocate gpio pin[24]: Invalid argument! Failed to allocate gpio pin[24]: Invalid argument! Failed to allocate gpio pin[24]: Invalid argument! Failed to allocate gpio pin[24]: Invalid argument! Failed to allocate gpio pin[23]: Invalid argument! Failed to allocate gpio pin[23]: Invalid argument! Failed to allocate gpio pin[23]: Invalid argument! Failed to allocate gpio pin[23]: Invalid argument! Failed to allocate gpio pin[23]: Invalid argument! .......
I Tried $ ./spidev_test -v after connect pin 19 (BCM 10 = MOSI) to pin 21 (BCM 9 = MISO) for test and i succesfully read on pin21 what i send to 19:
dev@dev:~/Downloads/spidev-test $ ./spidev_test -v spi mode: 0x0 bits per word: 8 max speed: 500000 Hz (500 KHz) TX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D | ......@....�..................�. RX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D | ......@....�..................�.
then tried:
$ lsmod | grep -i spi spidev 16384 0
and:
ls -l /dev/spi* crw-rw---- 1 root spi 153, 0 Mar 25 22:04 /dev/spidev0.0 crw-rw---- 1 root spi 153, 1 Mar 25 22:04 /dev/spidev0.1
so i think SPI is working.
Any advice is welcome. Thanks. Emanuele
Hi @emanueleci Do you have sufficient permissions or is any other process using GPIO pins? The problem you are describing relates not to spi interface, but to GPIO pins usage. Please look at the pin numbers GPIO 24 and GPIO 23.
Hi @lexus2k, thank you for your time. I checked my system and i think the problem is related to different GPIO numbering on new Kernel 6.6 for Raspberry. The error comes from your platform.cpp (linux) in gpio_export(int pin) function.
As you can see, now pin numbers start from 512:
dev@dev:~ $ sudo cat /sys/kernel/debug/gpio gpiochip0: GPIOs 512-569, parent: platform/fe200000.gpio, pinctrl-bcm2711: gpio-512 (ID_SDA ) gpio-513 (ID_SCL ) gpio-514 (GPIO2 ) gpio-515 (GPIO3 ) gpio-516 (GPIO4 ) gpio-517 (GPIO5 ) gpio-518 (GPIO6 ) gpio-519 (GPIO7 |spi0 CS1 ) out hi ACTIVE LOW gpio-520 (GPIO8 |spi0 CS0 ) out hi ACTIVE LOW gpio-521 (GPIO9 ) gpio-522 (GPIO10 ) gpio-523 (GPIO11 ) gpio-524 (GPIO12 ) gpio-525 (GPIO13 ) gpio-526 (GPIO14 ) gpio-527 (GPIO15 ) gpio-528 (GPIO16 ) gpio-529 (GPIO17 ) gpio-530 (GPIO18 ) gpio-531 (GPIO19 ) gpio-532 (GPIO20 ) gpio-533 (GPIO21 ) gpio-534 (GPIO22 ) gpio-535 (GPIO23 ) gpio-536 (GPIO24 ) gpio-537 (GPIO25 ) gpio-538 (GPIO26 ) gpio-539 (GPIO27 ) gpio-540 (RGMII_MDIO ) gpio-541 (RGMIO_MDC ) gpio-542 (CTS0 ) gpio-543 (RTS0 ) gpio-544 (TXD0 ) gpio-545 (RXD0 ) gpio-546 (SD1_CLK ) gpio-547 (SD1_CMD ) gpio-548 (SD1_DATA0 ) gpio-549 (SD1_DATA1 ) gpio-550 (SD1_DATA2 ) gpio-551 (SD1_DATA3 ) gpio-552 (PWM0_MISO ) gpio-553 (PWM1_MOSI ) gpio-554 (STATUS_LED_G_CLK |ACT ) out hi gpio-555 (SPIFLASH_CE_N ) gpio-556 (SDA0 ) gpio-557 (SCL0 ) gpio-558 (RGMII_RXCLK ) gpio-559 (RGMII_RXCTL ) gpio-560 (RGMII_RXD0 ) gpio-561 (RGMII_RXD1 ) gpio-562 (RGMII_RXD2 ) gpio-563 (RGMII_RXD3 ) gpio-564 (RGMII_TXCLK ) gpio-565 (RGMII_TXCTL ) gpio-566 (RGMII_TXD0 ) gpio-567 (RGMII_TXD1 ) gpio-568 (RGMII_TXD2 ) gpio-569 (RGMII_TXD3 )
gpiochip1: GPIOs 570-577, parent: platform/soc:firmware:gpio, raspberrypi-exp-gpio, can sleep: gpio-570 (BT_ON |shutdown ) out hi gpio-571 (WL_ON ) gpio-572 (PWR_LED_OFF |PWR ) out lo ACTIVE LOW gpio-573 (GLOBAL_RESET ) gpio-574 (VDD_SD_IO_SEL |vdd-sd-io ) out hi gpio-575 (CAM_GPIO |cam1_regulator ) out lo gpio-576 (SD_PWR_ON |regulator-sd-vcc ) out hi gpio-577 (SD_OC_N )
so, if i try manually to export GPIO with classic numbers i get error:
dev@dev:~ $ echo 23 | sudo tee /sys/class/gpio/export 23 tee: /sys/class/gpio/export: Invalid argument
but if i try with with 536 it's ok: dev@dev:~ $ echo 536 | sudo tee /sys/class/gpio/export 536
and i can check direction too: dev@dev:~ $ cat /sys/class/gpio/gpio536/direction in
tried to initialize SDD with new numbering, something like DisplaySSD1351_128x128x16_SPI display(536,{{-1}, 0, 535, 20000000, 523, 522}), unfortunately I keep getting errors.
I found similar problem on other discussion (not related to your library) es: https://github.com/domoticz/domoticz/issues/6014
Do you think is there any workaround? Thanks Emanuele
To recap, i understood that sysfs GPIO interfaces is deprecated and for raspberry 5 (and updated 4) libgpio should be used.
From official Raspberry documentation:
"Raspberry Pi Ltd make considerable effort to maintain backward compatibility over much of their software stack, however GPIO has always been problematic due to the plethora of third-party libraries, along with the evolution of the underlying Raspberry Pi hardware and the associated Linux GPIO subsystem. It is hoped that the most recent move to libgpiod will stabilise the GPIO environment, meaning better compatibility for future products, and less or no work needed when porting software to them."
Yes, it will take some time to rework lcdgfx/src/lcd_hal/linux/platform.cpp module. It provides all GPIO operations for the library.
Has this issue been addressed at all yet?
I'm seeing the same behaviour as @emanueleci currently on kernel 6.12.25 and the latest main branch with ssd1351 wired per waveshare's recommendations:
RST: 13
MOSI: 19
CLK: 23
CS: 24
DC: 22