I want to use some GPIO pins of BPI R64. but I don’t see the gpio folder here. Can anyone help me? I have loaded the linux kernel 16.04. Thank you everyone
https://wiki.fw-web.de/doku.php?id=en:bpi-r64:gpio
The sysfs interface (/sys/class/gpio/…) needs kernel-option CONFIG_GPIO_SYSFS
I guess your kernel does not have it…afair i have added it to my r64 defconfig
thank you.but how to set kernel-option CONFIG_GPIO_SYSFS. i’m newbie
You can look if there is a module for it and load it with modprobe
cd /lib/modules/$(uname -r)
find . -iname '*gpio*'
If not you need to update your kernel (maybe rebuilding it before)
Hello
I found it but I cannot control it
root@ :/lib/modules/5.4.260# find . -iname '*gpio*'
./kernel/drivers/leds/leds-gpio.ko
root@ :/lib/modules/5.4.260# ls /sys/class/leds/
mt76-phy0 mt76-phy1 mt76-phy2
Have you CONFIG_GPIO_SYSFS enabled (check via /proc/config.gz)?
Which board and which kernel/image?
Have you CONFIG_GPIO_SYSFS enabled (check via /proc/config.gz)? No , how to do that ?
Board = BPI R4
root@ :~# uname -a Linux 5.4.260 #3 SMP Thu Oct 10 09:27:17 PDT 2024 aarch64 GNU/Linux
zgrep -i sysfs /proc/config.gz
If there is no such file you can try loading config module first (possibly with s at the end)
modprobe config
I found sometimes it is easiest to change the gpio pin to led via devicetree overlay. Then you can control the gpio pin as output through sysfs very easy. No library or other tools needed.
Can you please provide the way how to do it for BPI R4?
That depends on your operating system. Find the docs for your specific OS on how to add a devicetree overlay.
You may have more luck with a more recent kernel then this. Didn’t even know the R4 will run on 5.4…
The mtk sdk for mt7988 was based on 5.4 and bpi repo used this for r4 suppprt…
Mainline kernel does not yet support R4 completely… currently i try to upstream some missing drivers and the dts.
If the mtk-sdk image does not implement loading devicetree overlays via u-boot, one could always apply the overlay to the .dtb directly, using the command fdtoverlay
Borrow the part of a led from the mtk-sdk devicetree and save it as an overlay.dts.
example overlay for a led on BPI-R64
Then edit the gpio to the desired pin, compile it to overlay.dtb with command dtc
and apply the overlay.
In a nutshell…
Imho dto is for beginners to difficult. We should try to get the sysfs/gpiolib working.
See:
GPIO control through libgpiod using the command gpiocli
I used a branch that has the dbus api, but:
It shows it is now part of the mainline libgpiod.
So one would need a very recent build of the libgpiod package. Even archlinux does not have it in ‘extra’ repo yet, so still need to build a new one yourself.
But I do not know if libgpiod works so well in 5.4 kernel…