Using the GPIO pins on a Pandaboard
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
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.
Copyright © 2011. All Rights Reserved.