Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: GPIO | Latest kernel deprecates sysfs API #5385 #6993

Closed
maartenlangeveld opened this issue Mar 29, 2024 · 20 comments
Closed

Regression: GPIO | Latest kernel deprecates sysfs API #5385 #6993

maartenlangeveld opened this issue Mar 29, 2024 · 20 comments
Labels
External bug 🐞 For bugs which are not caused by DietPi. Kernel related 🧬 Solution available 🥂 Definite solution has been done
Milestone

Comments

@maartenlangeveld
Copy link

maartenlangeveld commented Mar 29, 2024

Hi @MichaIng,

As of lately my NanoHatOLED has stopped working

Linux M-DNS 6.6.16-current-sunxi64 #2 SMP Fri Feb 23 08:25:28 UTC 2024 aarch64 GNU/Linux

It seems GPIO devices are missing again in latest kernel.

2024-03-29 21:57:23 root@M-DNS:/# cat /tmp/nanohat-oled.log
open of gpio 0 returned -1: No such file or directory
error opening gpio sysfs entries

Would you be so kind to re-address this issue at Armbian devs since you have some authority, moreover you are knowledgeable whereas I am not? So that they can include GPIO in the kernel again?

Thanks,
Maarten

@Joulinar
Copy link
Collaborator

Well our relationship to Armbian devs is not the best. Usually they don't like DietPi and issues addressed from or side.

@maartenlangeveld
Copy link
Author

Well our relationship to Armbian devs is not the best. Usually they don't like DietPi and issues addressed from or side.

Meanwhile I have addressed this issue at Armbian user forum, we leet you know if and when this issue will be resolved.

@Joulinar
Copy link
Collaborator

Maybe you like to share the related form link?

@MichaIng
Copy link
Owner

MichaIng commented Mar 30, 2024

A build is running with this re-enabled: https://github.com/MichaIng/DietPi/actions/runs/8491886407/job/23264312017

You will find the kernel image and dtb packages here once done: https://dietpi.com/downloads/binaries/testing/
Would be great if you could give them a try.

I'll open a PR, if it works as expected. It should do, it was removed accidentally and is still enabled in edge and legacy kernel builds.

@MichaIng MichaIng added this to the v9.3 milestone Mar 30, 2024
@MichaIng MichaIng added External bug 🐞 For bugs which are not caused by DietPi. Waiting for external fix ⏳ labels Mar 30, 2024
@maartenlangeveld
Copy link
Author

Hi @MichaIng,

Eager to help, but do not know how to install the kernel. If you provide guidance, I will give it a try.

@MichaIng
Copy link
Owner

cd /tmp
wget https://dietpi.com/downloads/binaries/testing/linux-{image,dtb}-current-sunxi64.deb
dpkg -i linux-{image,dtb}-current-sunxi64.deb
reboot

@maartenlangeveld
Copy link
Author

maartenlangeveld commented Mar 30, 2024

It boots normal however, NanoHatOLED still dark....

2024-03-30 18:36:35 root@M-DNS:~# uname -a
Linux M-DNS 6.6.23-current-sunxi64 #1 SMP Tue Mar 26 22:22:53 UTC 2024 aarch64 GNU/Linux
2024-03-30 18:38:04 root@M-DNS:~# gpio readall
-bash: gpio: command not found
2024-03-30 18:38:25 root@M-DNS:~# ls -l /sys/class/gpio
ls: cannot access '/sys/class/gpio': No such file or directory

@MichaIng
Copy link
Owner

Hmm, the gpio command is WiringPi, which can be installed only on RPi and some Odroids. /sys/class/gpio however should exist. Which SBC are you using?

Can you verify it's using this Linux 6.6.23 build:

uname -a

I'll test on Orange Pi Zero 3 in an hour.

@maartenlangeveld
Copy link
Author

maartenlangeveld commented Mar 30, 2024

NanoPi NEO2

Have installed NanoPi's software (https://github.com/friendlyarm/NanoHatOLED) which includes https://github.com/friendlyarm/WiringNP. It worked up until latest kernel update.

Will try re-installing soon if necessary.

2024-03-30 18:36:35 root@M-DNS:~# uname -a
Linux M-DNS 6.6.23-current-sunxi64 #1 SMP Tue Mar 26 22:22:53 UTC 2024 aarch64 GNU/Linux

@MichaIng
Copy link
Owner

Weird. Indeed I do not see the libgpio-sysfs driver being compiled in the logs, and the final kernel config does not contain CONFIG_GPIO_SYSFS, as if some dependency was missing. But all dependencies/selects are explicitly enabled: https://www.kernelconfig.io/config_gpio_sysfs?q=&kernelversion=6.6.23&arch=arm64

CONFIG_GPIOLIB=y
CONFIG_GPIO_SYSFS=y
CONFIG_GPIO_CDEV=y
CONFIG_SYSFS=y

Also the build log says:

[🐳|🌿] No misconfigurations or missing kernel option dependencies detected

I need to check other families configs.

@MichaIng
Copy link
Owner

MichaIng commented Mar 30, 2024

Ah, found the old PR which re-enabled this for 64-bit Allwinner chips: armbian/build#3635
There is another flag missing indeed, respectively a patch to make the sysfs API independent of this other flag.

@MichaIng
Copy link
Owner

MichaIng commented Mar 30, 2024

Next try, now with the patch added: https://github.com/MichaIng/DietPi/actions/runs/8491886407/job/23267118549
If I am not mistaken, while CONFIG_GPIO_SYSFS=y was set for e.g. 32-bit Allwinner and Rockchip boards already, it is not effective anymore since Linux 6.6, as the patch to make it independent of CONFIG_EXPERT=y was not ported. And it is still needed: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/gpio/Kconfig#n61

@maartenlangeveld
Copy link
Author

Hi @MichaIng,

Next try did not help either unfortunately

2024-03-30 22:44:08 root@M-DNS:~# uname -a
Linux M-DNS 6.6.23-current-sunxi64 #1 SMP Tue Mar 26 22:22:53 UTC 2024 aarch64 GNU/Linux
2024-03-30 22:43:42 root@M-DNS:~# ls -l /sys/class/gpio
ls: cannot access '/sys/class/gpio': No such file or directory

@MichaIng
Copy link
Owner

I need to learn how the patch system works. Looks like they need to be added in two config files: MichaIng/build@52f6b19
Comparing with another added patch, now it should be applied: armbian/build@cf392c1

Next attempt: https://github.com/MichaIng/DietPi/actions/runs/8491886407/job/23268009107

@MichaIng
Copy link
Owner

Now it works:

root@OrangePiZero3:~# ls -l /sys/class/gpio
total 0
--w------- 1 root root 4096 Mar 31 00:18 export
lrwxrwxrwx 1 root root    0 Mar 31 00:17 gpiochip0 -> ../../devices/platform/soc/300b000.pinctrl/gpio/gpiochip0
lrwxrwxrwx 1 root root    0 Mar 31 00:17 gpiochip352 -> ../../devices/platform/soc/7022000.pinctrl/gpio/gpiochip352
--w------- 1 root root 4096 Mar 31 00:18 unexport

@maartenlangeveld
Copy link
Author

Yes, I can confirm. THANKS !!!

@MichaIng
Copy link
Owner

MichaIng commented Mar 30, 2024

For some reason I cannot open a PR at Armbian. Will try to check back tomorrow at Discord.

@maartenlangeveld
Copy link
Author

Thanks again, @MichaIng. It's very kind of you to provide this tremendous support !!

@MichaIng MichaIng added the Workaround available 🆗 Workaround is available/has been implemented, but a definite solution should be found when possible. label Mar 31, 2024
@maartenlangeveld
Copy link
Author

maartenlangeveld commented Apr 2, 2024

@MichaIng MichaIng modified the milestones: v9.3, v9.4 Apr 16, 2024
@MichaIng MichaIng added Solution available 🥂 Definite solution has been done and removed Workaround available 🆗 Workaround is available/has been implemented, but a definite solution should be found when possible. Waiting for external fix ⏳ labels May 13, 2024
@MichaIng
Copy link
Owner

Our own kernel build with GPIO sysfs re-implemented, should have been installed with DietPi v9.4. In the meantime, also Armbian re-enabled it for all their builds, but by adding CONFIG_EXPERT=y for all of them, instead of decoupling CONFIG_GPIO_SYSFS=y from it: armbian/build@fb17a2a
The upside is, that I can drop our patch then, keeping the diff with upstream as small as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External bug 🐞 For bugs which are not caused by DietPi. Kernel related 🧬 Solution available 🥂 Definite solution has been done
Projects
None yet
Development

No branches or pull requests

3 participants