Error writing to /sys/class/gpio/export:

can someone please assist me


i have manually connected the gpio plug and slot successfully
and it the only snap using gpio 24
i am using core18 on raspberrypi 3 model B
I used https://github.com/raspberrypi/tools
gotora@localhost:~$ sudo /snap/bin/led-blink
Error writing to /sys/class/gpio/export: Device or resource busy

gotora@localhost:~$ sudo journalctl --output=short --follow --all

– Logs begin at Sat 2020-04-18 13:30:41 UTC. –
Apr 18 13:46:37 localhost systemd[1]: Started User Manager for UID 1000.
Apr 18 13:47:36 localhost sudo[1136]: gotora : TTY=pts/0 ; PWD=/home/gotora ; USER=root ; COMMAND=/snap/bin/led-blink
Apr 18 13:47:36 localhost sudo[1136]: pam_unix(sudo:session): session opened for user root by gotora(uid=0)
Apr 18 13:47:36 localhost audit[1137]: AVC apparmor=“ALLOWED” operation=“capable” info=“optional: no audit” error=-1 profile=“snap.led-blink.led-blink” pid=1137 comm=“snap-exec” capability=12 capname=“net_admin”
Apr 18 13:47:36 localhost kernel: audit: type=1400 audit(1587217656.961:21): apparmor=“ALLOWED” operation=“capable” info=“optional: no audit” error=-1 profile=“snap.led-blink.led-blink” pid=1137 comm=“snap-exec” capability=12 capname=“net_admin”
Apr 18 13:47:36 localhost audit[1137]: AVC apparmor=“ALLOWED” operation=“open” profile=“snap.led-blink.led-blink” name="/sys/class/gpio/export" pid=1137 comm=“led-blink” requested_mask=“w” denied_mask=“w” fsuid=0 ouid=0
Apr 18 13:47:36 localhost sudo[1136]: pam_unix(sudo:session): session closed for user root
Apr 18 13:47:36 localhost kernel: audit: type=1400 audit(1587217656.973:22): apparmor=“ALLOWED” operation=“open” profile=“snap.led-blink.led-blink” name="/sys/class/gpio/export" pid=1137 comm=“led-blink” requested_mask=“w” denied_mask=“w” fsuid=0 ouid=0
Apr 18 13:47:41 localhost sudo[1157]: gotora : TTY=pts/0 ; PWD=/home/gotora ; USER=root ; COMMAND=/bin/journalctl --output=short --follow --all
Apr 18 13:47:41 localhost sudo[1157]: pam_unix(sudo:session): session opened for user root by gotora(uid=0)

there was a clash between “/sys/class/gpio/export” and “snap conohnect led-blink:gpio pi:bcm-gpio-24”
this because they both do the same job and i removed “/sys/class/gpio/export” and used otherwise.

gpio interface
advantages:

  • is done manually
    disadvantages:
  • its manual

/sys/class/gpio/export
advanatges:
automatic connection and disconnection (exporting and unexporting)
disadvantages
-can only be done in the code
-the pi snap cannot register exported or unexported

  • in my case trying to export already exported gpio-24 caused fatal error
1 Like