Hallo Carambola

Today I got my Carambola boards (thank you Matze). The Carambola is a MIPS based SoC from 8devices. It uses the Ralink RT3050 which includes a high performance 320MHz MIPS24KEc CPU core, 8 MB Flash and 32 MB RAM. The device also provides two Ethernet ports and w a 802.11bgn radio. And best of it all: it is very low cost (about 22 EURO). For a quick start I also ordered a devboard, which breaks out RS232, the PYHs for the two Ethernet ports, and some of the GPIO pins of the CPU. The board comes with a pre-installed OpenWrt distribution, but building the distribution on your own is very simple and well described in the Carambola wiki.

Thus, after compiling and installing the firmware (which worked flawlessly on Ubuntu 12.04), I couldnt resists on soldering some 2×10, 2,54 female headers to the devboard, and see if I could blink some LEDs for “Hello Carambola”.



It turned out to be very simple. OpenWrt provides a tool called "gpioctl". It allows you to configure a GPIO as output or input, and also to set/clear an output, or get the state for an input:

gpioctl dirin|dirout|get|set|clear gpio

The first parameter is the command, the second one the number of the GPIO. E.g. to refer to GPIO1, one would pass 1 as second argument. To refer to GPIO5, 5 is passed an so on. On the J5 header of the devboard, the GPIOs 1 and 2 are available on pins 13 and 15, ground is located on pin 18. For the full pinout see this wiki page.

What I did was connecting a blue LED each between pin 13/15 and ground. Then configured this pins as output:

gpioctl dirout 1 
gpioctl dirout 2

Now the outputs could be set (HIGH):

gpioctl set 1
gpioctl set 2

And cleared (LOW):

gpioctl clear 1
gpioctl clear 2

Thats it! The full shell script looks like this:

#!/bin/sh

##  
# simple shell script blinking two LEDs on GPIO1+2 (pins 15+13)
# of the carabola.
#        
# 02.07.2012, Stefan Wendler
##                        
                          
P1=1                      
P2=2                      
                          
setup() {                   
   # set GPIO1+2 as output  
   gpioctl dirout $P1       
   gpioctl dirout $P2       
}                           
                            
high() {                    
  # set given output to HIGH
  gpioctl set $1           
}                          
                           
low() {                    
  # set given output to LOW
  gpioctl clear $1
}                 
                  
setup             
                  
while [ 1 -eq 1 ];
do        
  high $P1
  low $P2 
  sleep 1 
          
  high $P2
  low $P1
  sleep 1
done

1 Comment to Hallo Carambola

  1. 18. Juli 2012 at 22:34 | Permalink

    nice work, good primer for gpio on the carambola
    only the gpioctrl output is nagging a bit … ;)

Leave a Reply

You must be logged in to post a comment.