Using the GPIO pins on a Pandaboard
by cs
The Pandaboard is a neat little computer featuring a dual-core ARM processor. While the on-board GPIO pins seem like a fantastic way to use this board for all sorts of projects, I couldn’t find any documentation how to address them from linux, so here’s a summary of what I did:
- Make sure your kernel supports GPIO:
$ grep GPIOLIB /boot/config-`uname -r` CONFIG_ARCH_REQUIRE_GPIOLIB=y CONFIG_GPIOLIB=y $ grep GPIO_SYSFS /boot/config-`uname -r` CONFIG_GPIO_SYSFS=y
- Get the Pandaboard System Reference Manual
- Tables 10 and 11 on pp. 43-44 show you the pin definitions for J3 and J6. You should be able to use (at least) the pins for GPMC Address/Data bits 8-15, which are mostly located on J6. See Fig. 17 on p. 42 for the placement and orientation of these connectors.
- Export the GPIO that you’d like to use to the file system. For example, to write to GPIO_32 on pin 18 of J6:
$ sudo su $ cd /sys/class/gpio $ echo 32 > export $ cd gpio32 $ echo "low" > direction
- That’s it for the setup. To set the pin to low or high, you can now do:
$ echo "0" > value $ echo "1" > value
- Put this into your /etc/rc.local if you want members of “yourgroup” to access the gpio without root privileges:
sudo sh -c "echo 32 > /sys/class/gpio/export" sudo sh -c "echo \"low\" > /sys/class/gpio/gpio32/direction" sudo chgrp yourgroup /sys/class/gpio/gpio32/value sudo chmod 664 /sys/class/gpio/gpio32/value exit 0
Links
Some more generic documentation is available on kernel.org and avrfreaks.net. A video illustrating the procedure has been posted on YouTube. And someone has bluntly copied most of this tutorial over at OMAPpedia.org.
Hello,
I can do all of the above but set the input gpio pin high. In other words, I call do an internal pullup for the input mode.
kelvin@papa-panda:/sys/class/gpio/gpio121$ cat direction
in
kelvin@papa-panda:/sys/class/gpio/gpio121$ echo “1” > value
-bash: echo: write error: Operation not permitted
The problem is that you set the direction to be in, not out. You can’t specify that the GPIO pin gives 1.8v if it is looking for 1.8v.
Try:
UNIX$ echo out > /sys/class/gpio/gpio121/direction
UNIX$ echo 1 > /sys/class/gpio/gpio121/value
UINX$ cat /sys/class/gpio/gpio121/value
That should give one. A better way to check if it is actually give power is to use a DMM and check if the output is 1.8v.
Nice succinct intro to GPIOs. It would be useful to also see some examples of toggling GPIOs from a C program.
Hello,
Myself Balakrishna, i am working on Pandaboard,
I was googling for some help in the community, related to 1 problem on pandaboard and landed up here,
We have Connected a Expansion Board on J3 PIN of Pandaboard 4430, on which we have connected some device,
When we check the Power from Multimeter it shows proper readings,
But the device connected on the Expansion Board is not getting detected, is there a short circuit in the B2B connector or anthing ?
Thanks for the Help.
Thanks,
Balu
[…] read this literature and this. This should help you get […]
[…] Using the GPIO pins on a Pandaboard […]