Design Build Test Repeat

Voluntarily cast upon the waves of outrageous fortune, this lowly geek flops from peak to peak of the technological ocean. Linux, Windows, C, Ruby, Python and embedded systems all attempt to pull our stalwart hero down. Will he survive alone or will the lifeboat of corporate servitude be too tempting.

Meraki – C programming

Posted by Diarmuid on May 1, 2007

I am OK with c ( no guru, that is for sure, but I can edit and change. Starting from scratch is another thing) and have done some work on ARM chips, the Olimex boards from Sparkfun and the Make Controller, but I have not done much on linux and nothing with the Atheros boards, those the meraki is based on. And the meraki does not have any nice serial command line programs that would make it easy to use the serial port from Ruby, etc. So I thought I would take the plunge and try to get a program to compile that would.

First off Helloworld.c

printf (“Hello World!\n”);
Simple but it will prove if this thing will work.

This you would normally compile using gcc -o hello helloworld.c

Then I downloaded the OpenWRT tar file supplied by Meraki on
tar zxvf openwrt-meraki.tar.gz
Then I followed the instruction in meraki.README. Mine, is a build machine so I have a tonne of dev apps and libraries on it. You will need all the usual, build-essential,etc and then the list in README in the OpenWRT directory.
You need to have installed gcc, binutils, patch, bzip2, flex, bison,
make, gettext, pkg-config, unzip, libz-dev and libc headers.

You will also need ruby as the Meraki system uses that, and seems to use ruby as a scripting tool during the compile.

Whatever happened, the make command blew up and did not complete. However, it had got through the Buildroot and toochain builds.
So, I had a look around and came across in this folder /home/dev/openwrt/openwrt-meraki/openwrt/staging_dir_mips/bin (my user is called dev) an exe called mips-linux-uclibc-gcc-3.4.6
A quick “file mips-linux-uclibc-gcc-3.4.6” showed that it is an i386 exe. So on a whim I tried
./mips-linux-uclibc-gcc-3.4.6 -o ~/test/hellomeraki ~/test/helloworld.c. It ran without an error and when I ran file ~/test/hellomeraki it showed that it was a mips exe!!!
dev@dev-desktop:~/test$ file hellomeraki
hellomeraki: ELF 32-bit MSB executable, MIPS, version 1 (SYSV), dynamically linked (uses shared libs), not stripped

I used scp to send the file to /storage
scp hellomeraki meraki@myipaddress:/storage/hellomeraki .
And then I ran it by typing ./hellomeraki.
Too easy!!
Now for the hard part. Writing the code to communicate with the serial port. Really what I want is a commandline tool that will write what ever I give it to the serial line and then close.
By the way, there is a huge gotcha here . The Meraki uses the serial line like a screen so the line is allready in use. I wondered at this point whether anything serial line programs would work, but i reasoned that since there seemed to be different programs writing to it at the moment then a new program would be able to also. ….. But what about incoming. Mmmmmm. Too much thinking is bad so carry on regardless.
I work with the excellent Fox board from

Fox Board - Runs Linux , uSB, WIFI, Ethernet, Cool.

They have a great website full of tutorials (in English). It only runs kernel 2.4 but supports wireless and USB. I recommend it for those that want a bit more from their embedded system. They have a sample c program that they use with their web based compiler. This article includes a link to a c file that they compile for their board. I wondered WHAT WOULD HAPPEN IF I TRIED IT LIKE HELLOWORLD!!! You can tell I was getting excited now. Anyway it compiled and ran like a dream on the Meraki.

Showing serial_test ( a c program ) running on the Meraki through Putty
I ran it with ./serial_test /dev/ttyS0 and when I typed in my SSH session the text appeared in the console app I had connected to.

Showing the Meraki booting through the Serial port

So that shows that I can get serial data out of the meraki. But, alas, it does not work the other way. Typing in the console program is accepted by whatever is latched on and accepting linux commands. This does mean however, that I can run any linux command I want from whatever is attached to the Meraki and I can get data in return. So actually, my custom program is not required. Great stuff.

A note on my serial connection. I am using the Fox console board from Acme. Fox Console Board - Used for getting Serila data from the Meraki

I have it wired up as in the photoMy setup showing the serial link between the Meraki and my PC

The meraki pins are left to right with the antenna point away from you, Vcc, RX, TX, VDD (3.3 Volt). The Fox console is (with the serial jack pointing away) VCC, NA, TX, RX, NA, VDD. A nice little LED lights when all is good. So I wired up live to live, gnd to gnd , tx to rx and rx to tx. The baud rate is 115200. Seemingly, Meraki sell a similar board but it is not on their website at present. For now, I suggest that you get a board from Acme.


2 Responses to “Meraki – C programming”

  1. I am more of a hardware geek and I was looking at Meraki for being a slave to the iPhone and your name pops up and I look at your stuff and I am very impressed. You sound like an awesome guy. I hope the corporate waves do not engulf you. Thanks for sharing your stuff and if you ever want to do some programming for me, send and e-mail. I am committed to open source.


  2. lol lots of of the comments readers put up are a little out there, time and again i wonder whether they even read the content articles and reports before leaving a comment or if perhaps they take a moment to read the title of the post and come up with the first idea that pops into their brain. in any case, it’s nice to look over clever commentary once in a while compared to the very same, traditional post vomit which i typically see on the web i’m off to enjoy a few hands of zynga poker have a pleasant day

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: