Although the MinnowBoard Max has a SATA port like a normal PC, it also has nice IO lines like a Raspberry Pi. The easiest pins to use are on a 26-pin 0.1" DIL header, whose pinout1 is shown on the eLinux website.


If the proper kernel modules are installed, you can access the GPIO lines from userspace through devices in /sys.

Happily this is well documented in the kernel sources,2 but there is less abstract documentation3 on the eLinux website.

Sadly though the stock Ubuntu and Mint kernels do not include the relevant devices, so you will probably end up compiling your own.4 As Peter Ogden notes,5 the key configuration settings are:


Thanks to Peter for pointing this out.

You can also grab the config I used6 from GitHub.

GPIO numbering

GPIO numbering changed between versions 3.17 and 3.18 of the kernel. The discussions below assume the latter, but you can adjust them to the old world order by subtracting 256.

Having compiled a new kernel, and rebooted into it, you can see the GPIO entries in /sys:

# ls /sys/class/gpio/
export       gpiochip338/ gpiochip382/ gpiochip410/ unexport

Each gpiochip entry corresponds to a bank of GPIO pins.

We can find out more about the GPIO banks from sysfs:

# cat /sys/class/gpio/gpiochip*/base
# cat /sys/class/gpio/gpiochip*/ngpio

So, for example, we can see that there is a block of 44 GPIO pins starting at GPIO 338.

Hello Blinky

Pin 25 on the DIL header is easy to identify, so let’s connect an LED between there and Ground (with a suitable series resistor). Pin 25 is labelled (on the schematic7) as GPIO_S5_2, which can be identified as the third pin in the block of 44. For me, that block starts at GPIO 338, so my pin 25 corresponds to GPIO 340.

Having sorted out the hardware, we can flash the LED thus:

# echo 340 > /sys/class/gpio/export
# echo out > /sys/class/gpio/gpio340/direction
# echo 0 > /sys/class/gpio/gpio340/value
# echo 1 > /sys/class/gpio/gpio340/value
# echo 0 > /sys/class/gpio/gpio340/value
# echo 1 > /sys/class/gpio/gpio340/value
# echo 0 > /sys/class/gpio/gpio340/value
# echo 1 > /sys/class/gpio/gpio340/value

Similarly, we can work out that pin 26 of the header corresponds to an offset of 54 within the block of 102 GPIO lines. Given the base of 410, this makes it GPIO 464.

Thus to interpret the pinout on the eLinux site:

The gory details

All the GPIO numbers jumped by 256 when the kernel reached version 3.18, which caused me some confusion. The notes below might be helpful if it happens again.

Let’s try another. Header pin 25 connects to ball C18 which is GPIO_S5[02]. S5 is the block of 44 GPIO lines, which starts at GPIO 338 on my board. Thus, pin 25 is GPIO 340.

Adafruit Python GPIO library

I have hacked support for sysfs driven GPIO into the Adafruit Python GPIO Library.10 This lets you flash LEDs thus:

import Adafruit_GPIO as GPIO		
import time				
gpio = GPIO.get_platform_gpio()		
pin = 338				
gpio.setup(pin, GPIO.OUT)		
gpio.output(pin, 1)			
gpio.output(pin, 0)			

You can get the library from GitHub11 but be warned: it’s only a proof of concept and not production quality!