Getting an OS


The first step is to download an OS for your OLinuXinoOLinuXino.  There are a couple of options given on the olimex wiki.  The debian image seems pretty popular and works well, so if you aren’t sure which one to pick; that would be a good option.  One thing to note is that the image seems to be too big to fit on some 4GB micro SD cards.  My experience was that the image did not fit on the card that came with the OLinuXino board.  I ended up using a different micro SD card that I had lying around.


The instructions on the wiki are geared towards linux users.  If you are a Windows user like me, there are two tools that make the process pretty easy: SDFormatter and Win32 Disk Imager.  The first one erases all of the information on your SD card and the second one writes the OS image to the SD card.


Getting GPIO Library

Once you have an OS, you need to get the GPIO libraries.  To do this from the command line type:




After the download has completed, unzip it using:


tar -xvzf pyA13-0.1.12.tar.gz


Before we can install this, we need some additional python header files.  To get them type in:


sudo apt-get install python-dev


When that has completed, then you can enter into the directory that was created when you unzipped the downloaded file and install the python GPIO library:


cd pyA13-0.1.12

sudo python install


To test to make sure that everything installed correctly and is in working order, open up the python command prompt and try to load the GPIO library:



>>> import A13_GPIO


If you don’t get an error message, then everything worked just fine.


Blinking an LED with Python


Now that the python GPIO libraries are installed and working correctly, let’s put them to work. First, create the circuit shown in the image below:


Now, you can pick any GPIO pin on the board that you want.  I picked GPIO PIN6, which is physical pin 9 on the GPIO-2 connector. A description of the GPIO pins can be found in the OLinuXino user manual, and is shown here:


Awesome, now that that is connected, we need to enable the GPIO pin that we hooked the LED up to. To do this, you first need to become root.  After you are root, then you can enable the GPIO pin:


echo 6 > /sys/class/gpio/export


After that command has been issued, then you can look at the contents of /sys/class/gpio and see your pin.


Now we can write a python script that will blink the LED on/off.  Here’s the script to make that happen:

Once you copy that over into a file called then you can run it with:




And the LED that is connected to PIN6 should blink!


The code is pretty straight forward.  It starts by initializing the GPIO library.  Then it sets the GPIO PIN6 to be an output.  Next the code goes into an infinite loop.  The loop turns the LED off, then sleeps for a second, then turns the LED on, and finally sleeps for one second before repeating.


Blinking an LED with C


Next we’re going to do the exact same thing, but this time with C instead of python.  To do this, first copy over the GPIO libraries that are contained in the pyA13-0.1.12/source directory that was created when we unzipped the file that we downloaded earlier.  There should be two files: gpio_lib.h and gpio_lib.c.  Along with those two files, create a new one called blink.c and put the following code in there:

To compile it, type in the following command:


gcc blink.c gpio_lib.c -o blink


This will create an executable file called blink that you can run.  This should cause your LED to blink just like the python example did. The explanation for the code is the exact same as the python example.


The only interesting thing about the C example is trying to figure out which GPIO pin is which.  To do this, you can look at the python GPIO library source code (pyA13-0.1.12/source/pyA13.c).  At the very top there is a list of #define statements that show how to access the various GPIO pins.  I just copied over the one that applied to GPIO PIN6.



With a couple of quick steps, we were able to get up and started with the OLinuXinoOLinuXino.  We were able to get debian up and running and then use the GPIO ports to blink an LED.  This was done in both python and C to show off how it looks in both languages.