Permissions on /sys/class/gpio*

Hi All.

Getting up and running with new BBAI64 - connecting to https://192.168.7.2:3000/ and trying to run blink.sh example (after I sorted out correct pin).

I’m getting “permission denied” while trying to run it from VSCode code-server as user debian.

Logging in via ssh as root works, however it seems that everything under /sys/class/gpio* is created as root and there is no way to change.

What is the solution to this? (a) Can I modify ‘debian’ user somehow to have permissions over /sys/class/gpio or (b) Should I modify code-server to run as ‘root’?

Hi @BarryBeagle should be good now:

voodoo@bbai64-02:~$ ls -l /sys/class/gpio/
total 0
--w--w---- 1 root gpio 4096 Aug  7 13:25 export
lrwxrwxrwx 1 root root    0 Jan  1  1970 gpiochip264 -> ../../devices/platform/bus@100000/601000.gpio/gpio/gpiochip264
lrwxrwxrwx 1 root root    0 Jan  1  1970 gpiochip300 -> ../../devices/platform/bus@100000/600000.gpio/gpio/gpiochip300
lrwxrwxrwx 1 root root    0 Jan  1  1970 gpiochip428 -> ../../devices/platform/bus@100000/bus@100000:bus@28380000/42110000.gpio/gpio/gpiochip428
--w--w---- 1 root gpio 4096 Aug  7 13:25 unexport
voodoo@bbai64-02:~$ ls -l /sys/class/gpio/gpiochip264/
total 0
-r--r--r-- 1 root gpio 4096 Aug  7 13:25 base
lrwxrwxrwx 1 root gpio    0 Aug  7 13:25 device -> ../../../601000.gpio
-r--r--r-- 1 root gpio 4096 Aug  7 13:25 label
-r--r--r-- 1 root gpio 4096 Aug  7 13:25 ngpio
drwxrwxr-x 2 root gpio    0 Aug  7 13:25 power
lrwxrwxrwx 1 root gpio    0 Aug  7 13:25 subsystem -> ../../../../../../class/gpio
-rw-rw-r-- 1 root gpio 4096 Aug  7 13:25 uevent

just run:

sudo apt update ; sudo apt upgrade

Regards,

Many thanks for the speedy response! I upgraded and saw a new bb-customizations applied.

hmmm…but I’m not seeing the same permissions as you

--w--w---- 1 root gpio 4096 Aug  7 13:25 unexport
--w--w---- 1 root gpio 4096 Aug  7 13:25 export
lrwxrwxrwx 1 root root    0 Jan  1  1970 gpiochip264 -> ../../devices/platform/bus@100000/601000.gpio/gpio/gpiochip264
lrwxrwxrwx 1 root root    0 Jan  1  1970 gpiochip300 -> ../../devices/platform/bus@100000/600000.gpio/gpio/gpiochip300
lrwxrwxrwx 1 root root    0 Jan  1  1970 gpiochip428 -> ../../devices/platform/bus@100000/bus@100000:bus@28380000/42110000.gpio/gpio/gpiochip428

Result is I can “export/unexport” a pin but can’t set its value…

As an aside…I see in /etc/udev/rules.d there is both a 80-gpio-noroot.rules and a 85-gpio-noroot.rules present…perhaps they are stepping on each other?

For reference, I was able to correct by changing /etc/udev/rules.d/80-gpio-noroot.rules to:

SUBSYSTEM=="gpio", ACTION=="add", \
        RUN+="/bin/chgrp -R gpio '/sys%p'", \
        RUN+="/bin/chmod -R g=u '/sys%p'"

SUBSYSTEM=="subsystem", KERNEL=="gpio", ACTION=="add", \
        RUN+="/bin/chgrp -R gpio '/sys/class/gpio'", \
        RUN+="/bin/chmod -R g=u '/sys/class/gpio'"

Not sure if that has any other bad side-effects but seems to be working so far…

1 Like