December 12, 2019, 11:37:19 am

News:

Have you visited the Allwinner Chipset wiki? - http://linux-sunxi.org/


beginner needs help understanding GPIOs

Started by daxdax, September 01, 2015, 04:36:53 pm

Previous topic - Next topic

daxdax

September 01, 2015, 04:36:53 pm Last Edit: September 01, 2015, 04:45:59 pm by daxdax
I want to program using GPIOs, but there are many things I don't quite get.
First, I found this, which was very helpful: http://falsinsoft.blogspot.com/2012/11/access-gpio-from-linux-user-space.html

But I still have some questions:


  • The above link tells me, in order to see if I can access GPIOs, to go to /sys/class/gpio and see if anything shows up there.  I do and I see two files, "export" and "unexport" but I cannot access them.  If I try a 'cd export' it tells me no such file exists.  What's going on?

  • The above link (and numerous other sites) tell me in order to 'reserve' a GPIO I must use this command: echo XX > /sys/class/gpio/export
    However when I do so, it says 'permission denied'.  I created a group and gave my user permissions but now it says "Write error: Invalid argument".  What's going on?

  • Why are most instructions talking about compiling a kernel?  Isn't a kernel just an operating system?  I have Ubuntu installed on my cubieboard.  Does that count?

  • Why is everyone specifying the type of chip they use (A10, A20, A80)?  I have a cubieboard2, A20 - can I use code or instructions written for an A10?



I have many more questions but this will do for now.  Thanks for any answers you may have.

slovenia

http://docs.cubieboard.org/tutorials/common/gpio_on_lubuntu

Check example above. For other boards you need to use proper PIN numbers but the principle is the same. You also need to enable GPIOS in fex file before using them. I guess you forgot that.

First you need to export that gpio become usable in userspace so you can change and read value ...

Debian and Ubuntu images with kernel 3.4.110, 4.3.3, 4.4
http://www.armbian.com