2

I was wondering how to change the gpio directory for the node.js pi-gpio library. Whenever I try to run the script to change the pin it returns this error:

"Error when trying to open pin 40

gpio-admin: failed to change group ownership of /sys/devices/virtual/gpio/gpio21/direction: No such file or directory"

Matthew Pitzer
  • 55
  • 1
  • 3
  • 7

2 Answers2

3

When the latest package raspberrypi-bootloader:armhf 1.20150130-1 was installed, the gpio symbolic links in /sys/class/gpio/ moved from /sys/devices/virtual/ to /sys/devices/soc/20200000.gpio.

Solution 1

chmod -R +x /sys/devices/soc/20200000.gpio

Solution 2

Update the pi-gpio.js so that

sysFsPath = "/sys/devices/virtual/gpio";

points to the new path:

sysFsPath = "/sys/class/gpio";

Solution 3

Add line device_tree= in /boot/config.txt. That will revert the links to be in the old path. Make sure you reboot after changing the config.txt.


Pick your flavor :)

Edit:

I've fixed both pi-gpio (pull request #34) and gpio-admin (pull request #7) in a manner so that both the old and the new paths are supported. Hopefully, those pull requests are merged soon...

Saran
  • 293
  • 3
  • 18
1

I had the same error as Matthew and after trying this solution I could see that Saran's fix had already been implemented into the "npm pi-pgio".

If you're still having this problem this solution worked for me. You need to update the path in gpio-admin.

First Download gpio-admin and open source code (I used nano, but any editor will do)

$git clone https://github.com/quick2wire/quick2wire-gpio-admin
$nano quick2wire-gpio-admin/src/gpio-admin.c

Check this file and make sure that the paths are updated. Update the function allow_access_by_user() the path needs to be updated to "/sys/class/gpio/gpio%u/%s"

Now navigate into the folder and install

$cd quick2wire-gpio-admin
$make
$sudo make install

Note: you may need to add yourself as a user

$sudo add adduser $USERNAME gpio

Hope this helps save some headaches!

Cody Wikman
  • 111
  • 2