Hi, in the docs it states that you can access GPIO ports through their numbers in /sys/class/gpio/gpio<pinnr> if I look do ls /sys/class/gpio/ i'm only seeing gpiochip[0 32 64 96 128 160 192] How does these relate to the gpio pins? Is this still work in progress?
Have you read that part in the docs entirely? http://www.udoo.org/docs-neo/Hardware_&_Accessories/Gpio.html You have to export them before Cheers
I've read and done the export thing but the ports didn't show up after I did some more investigations it seems it doesn't work with sudo after becoming root it works like stated in the documentation which is less then ideal, as i don't want my application to run as root but ii did unblock me, thanks
You should create a rule under Code: cat /etc/udev/rules.d/10-imx.rules to give these files the permissions of the "udooer" user. Try to add these two lines at the bottom: Code: SUBSYSTEM=="gpio", ACTION=="add", PROGRAM="/bin/sh -c 'chown -R root:ugpio /sys%p'" SUBSYSTEM=="gpio", ACTION=="add", PROGRAM="/bin/sh -c 'chmod -R g+rw /sys%p'" add the user "udooer" at the group ugpio
Dear Necromancer, to access GPIO you can use this library made by @Julien. Tell us if it works for you.
I have the same problem. I can only use something like sudo sh -c "echo ..." to do anything with the GPIO's or I have to be logged in as root. I tried appending those extra lines but nothing changed.
First off make sure you create the group ugpio and add it to the udooer user: sudo groupadd -r ugpio sudo usermod -a -G ugpio udooer When I added the lines mentioned above I could see that the gpios were available for the ugpio group but not /sys/class/gpio/export So I added another two lines to the udev file: SUBSYSTEM=="gpio", ACTION=="add", PROGRAM="/bin/sh -c 'chown -R root:ugpio /sys/class/gpio/export'" SUBSYSTEM=="gpio", ACTION=="add", PROGRAM="/bin/sh -c 'chmod -R g+w /sys/class/gpio/export'" Now I can do as user udooer: udooer@udooneo:~$ echo 25 > /sys/class/gpio/export udooer@udooneo:~$ echo out > /sys/class/gpio/gpio25/direction udooer@udooneo:~$ echo 1 > /sys/class/gpio/gpio25/value And the LED I connected on header J6 port 24 turns on.
Thanks a lot for the mention, unfortunately my library also needs root privileges for changing values
Not at all, everything I post here should be considered "public domain". The -R after the chown and chmod command isn't necessary, as it's only one file (-R is for recursive subdirectories). So this should work too, although I haven't tested it personally as I've got a very busy work week: SUBSYSTEM=="gpio", ACTION=="add", PROGRAM="/bin/sh -c 'chown root:ugpio /sys/class/gpio/export'" SUBSYSTEM=="gpio", ACTION=="add", PROGRAM="/bin/sh -c 'chmod g+w /sys/class/gpio/export'" You might also want to add that a reboot should be performed after these changes... (you can get around that if you know what you're doing but I don't have time to validate the exact steps right now)
I updated /etc/udev/rules.d/10-imx.rules by adding the following lines to the very end of the file: SUBSYSTEM=="gpio", ACTION=="add", PROGRAM="/bin/sh -c 'chown -R root:ugpio /sys%p'" SUBSYSTEM=="gpio", ACTION=="add", PROGRAM="/bin/sh -c 'chmod -R g+rw /sys%p'" SUBSYSTEM=="gpio", ACTION=="add", PROGRAM="/bin/sh -c 'chown -R root:ugpio /sys/class/gpio/export'" SUBSYSTEM=="gpio", ACTION=="add", PROGRAM="/bin/sh -c 'chmod -R g+w /sys/class/gpio/export'" I also did: sudo groupadd -r ugpio sudo usermod -a -G ugpio udooer I then re-booted I can change and see the direction change by: echo in > /sys/class/gpio/gpio25/direction echo out > /sys/class/gpio/gpio25/direction cat /sys/class/gpio/gpio25/direction but I CAN NOT change the output value, it's always a 0 when I do the following echo 1 > /sys/class/gpio/gpio25/value cat /sys/class/gpio/gpio25/value I have tried below which didn't work either. sudo echo 1 > /sys/class/gpio/gpio25/value What am I missing? Thanks for any help.
How do you know that the value is always 0? Do you have an LED connected? does the LED turn on and off? Did you try to read the value by if you did, then the document also says the following; So try putting an LED in that pin to see the led turn on and off
Thanks for the clarifications... It sounds like the GPIO it's self is not a true bi-directional pin if "read the value is not guaranteed that the kernel value is coherent with the voltage found on the external pinout." I am able to see the output change state using a DVM, now. Thanks again.
Just to inform you that this update is not needed anymore with the just released Udoobuntu 2 RC2! GPIO is exported at startup and no need for sudo rights to set value!
That's great, guess it's time for me to update the little fella. How did you learn about the RC2? I haven't received any email