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"

asked Feb 21, 2015 at 18:23
2
  • 1
    The source code is here: github.com/quick2wire/quick2wire-gpio-admin/blob/master/src/…. You could clone that project and edit the path, get that project onto your device and then rebuild it. Commented Feb 21, 2015 at 21:03
  • Hmmm I'm not sure how to exactly go about that and the link you posted is a 404 error. Do you know of any other way to interface with the GPIO pins through node.js Commented Feb 22, 2015 at 18:54

2 Answers 2

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...

answered Mar 1, 2015 at 23:24
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!

answered Nov 28, 2016 at 0:45

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.