Chumby and Go

Cross compiling Go for the Chumby One on OS X

A number of years ago I purchased a Chumby One, basically a fancy alarm clock running linux. I’ve played with a few different languages for it but haven’t really done much with it lately. I’ve also been using a bit of Go recently and thought it might be fun to get Go running on the Chumby One, this has actually proven to be remarkably easy thanks to Go already coming with a number of compilers for different architectures. In this post I’ll run through what’s required to run a Go program on the Chumby One, note that I’m using OS X however the steps shouldn’t be too different for Linux.

Cross Compiling Go

First things first, Go will need to be installed with the compilers for different architectures as well. The easiest way to do this is via Homebrew, a package manager for OS X. Information regarding how to install Homebrew can be found at this link.

Once Homebrew is installed Go can be installed with the most common compilers for other architectures.

brew install go --cross-compile-all

The Chumby one device itself runs linux with an ARM926EJ-S processor, for our purposes it is important to know that this runs the v5 ARM architecture. Say that we have a simple HelloWorld program in go as below:

package main

import (
	"fmt"
)

func main() {
	fmt.Println("Hello World")
}

Then to cross-compile for the Chumby One on OS X we can just compile the code as such:

GOARCH=arm GOOS=linux GOARM=5 go build main.go
That’s all that’s needed to build go programs for the Chumby One on OS X. In the next section I’ll go through how that can be put onto the Chumby.

Running the Go program on the Chumby

The next stage is to move the compiled code onto the Chumby. Luckily a few years ago I’d produced a post on how to run the Pure-FTPd ftp server on the Chumby One that can be found here. If you’re following this then I’d advise to follow the post to install the ftp-server, then on OS X you can just connect to the ftp-server with your favourite ftp client, my preference is Cyberduck.

Now we have to connect to the Chumby to run the program, we’ll do this by connecting via SSH. To start the Chumby daemon, click on the top button of the Chumby, this will open the control panel. Once the control panel is up click the Settings button on the lower right hand corner. On the Settings panel click on the Chumby Info button, this will bring up some more specific details about the network connection. On this page there is a Pi symbol in the very upper right hand corner, click this. This will bring up a hidden panel, on this panel there is a button labeled SSHD, this will start the SSH daemon on the Chumby.

Now on OS X open Terminal and type in:

ssh 192.168.2. -l root

where the IP address is the IP address of the Chumby. Then cd into the directory where you placed the compiled code. Then just type ./main. If all goes well “Hello World” will be printed on the terminal.

Next I’ll go through how to access the frame buffer, touch screen and other hardware devices on the Chumby via go.

David Roberts

Read more posts by this author.

Newcastle upon Tyne, UK https://davidatroberts.github.io/