Mabzy Posted August 22, 2016 Posted August 22, 2016 Hi Can any one tell me how to access the GPIO from user space, I have tried this: sudo echo 203 > /sys/class/gpio/export But get this result -bash: /sys/class/gpio/export: Permission denied It's of course some thing really simple, but I haven't been able to find any thing which can lead in the right direction. I have tried adding user account to the /etc/sudoers By inserting this: # See sudoers(5) for more information on "#include" directives: #includedir /etc/sudoers.d mabzy ALL=(ALL) NOPASSWD: ALL
martinayotte Posted August 22, 2016 Posted August 22, 2016 This is because the "sudo" command apply only to the "echo", not to the redirection of the output. Try the following instead : sudo su - -c "echo 203 > /sys/class/gpio/export" 1
tkaiser Posted August 22, 2016 Posted August 22, 2016 Please compare with http://forum.armbian.com/index.php/topic/1851-rfc-make-armbian-more-iot-friendly/ Might be worth a try adding a group gpio, adding your user to this group and putting chown -R root:gpio /sys/class/gpio && chmod -R 770 /sys/class/gpio into /etc/rc.local prior to "exit 0". Adding group gpio and a user to it should be possible this way: sudo su - addgroup gpio usermod -aG gpio ${SUDO_USER} (log out and in afterwards) 1
Mabzy Posted August 22, 2016 Author Posted August 22, 2016 Thanks it works , but is there away to grant user space access so that I can access the gpio's like this from user space: echo 203 > /sys/class/gpio/export
Mabzy Posted August 22, 2016 Author Posted August 22, 2016 Thanks tkasier Your answer was crossing with my reply to martinayotte But also thanks to martinayotte Last one - where can I find UART -> ttyXX mappings ?
martinayotte Posted August 22, 2016 Posted August 22, 2016 What do you mean by ttyXX mappings ? The port numbers such /dev/ttyS0 are corresponding to uart0 defined in FEX for Legacy or DTS for Mainline.
Mabzy Posted August 23, 2016 Author Posted August 23, 2016 Thanks - I was referring to what device the uart0 was assigned to.
Will Allen Posted May 17, 2017 Posted May 17, 2017 On 8/22/2016 at 1:20 PM, tkaiser said: Please compare with http://forum.armbian.com/index.php/topic/1851-rfc-make-armbian-more-iot-friendly/ Might be worth a try adding a group gpio, adding your user to this group and putting chown -R root:gpio /sys/class/gpio && chmod -R 770 /sys/class/gpio into /etc/rc.local prior to "exit 0". Adding group gpio and a user to it should be possible this way: sudo su - addgroup gpio usermod -aG gpio ${SUDO_USER} (log out and in afterwards) I also had to run: chown -R root:gpio /sys/devices/platform/sunxi-pinctrl/gpio chmod -R 770 /sys/devices/platform/sunxi-pinctrl/gpio 1
Recommended Posts