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:

  1. 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
  2. Get the Pandaboard System Reference Manual
  3. 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.
    Pandaboard connector pinout

    Pandaboard connector pinout: Top rows are odd pins starting with 1, bottom rows are even pins starting with 2

  4. 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
  5. That’s it for the setup. To set the pin to low or high, you can now do:
    $ echo "0" > value
    $ echo "1" > value
  6. 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.

This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.