Arduino Uno + Ubuntu + CMake

I’ve been playing with my brand new Arduino Uno since the beginning of this week on my Linux box. Unfortunately the Maverick (10.10) release of Ubuntu ships a version of Arduino SDK that is incompatible with Uno, looks like the package version was frozen days before the release of Uno hardware. So, the first thing I had to do was update the SDK using unstable packages from Natty (11.04). Just download and manually upgrade the from the Ubuntu website (remember to upgrade both arduino and arduino-core).

The IDE is very user friendly to casual developers and allows to write simple programs without much effort. At the first glance might look like a non-standard C/C++, although the IDE magically adds some include headers and a simple main() calling your setup() and loop() routine when you click on the Upload button. Looks like there is no way to use multiples files in your project, which is OK for small sketches.

Arduino IDE

For those who want to develop things in the traditional way using the command line, I started a CMake template for Arduino Uno. The template was written in a such way that makes possible to add support for new devices by just creating a new device profile file. There is no restrictions of using this template on other Linux distributions (or even other OS, since CMake runs on Mac and Windows), but adaptations might be needed. Patches are always welcome. :)

Using the Arduino CMake template

As pre-condition, you will need cmake package (duh!) and a compatible version of Arduino SDK (see Ubuntu Maverick x Uno issue above and how to fix). Only the arduino-core package is necessary for this setup.

Download the latest version of the buildsystem template:

arduino_cmake.tar.gz

This is a modified version of the classic Blink example, converted to a standard C/C++ (it’s really weird why the Arduino libraries are a mixture of C and C++ and not only C). This example is great because gives you visual feedback without attaching any component to the board, since there is a built-in LED on the board tied to pin 13. Because cmake it’s not a widely spread buildsystem (which is a shame for such a great tool), here are some basic instructions of how to build the project. Type this from the root of your project tree:

$ mkdir build
$ cd build
$ cmake ..
$ make

You can either export the environment variable ARDUINO_PORT set to your device port or edit CMakeLists.txt and change the default value permanently. Mostly likely you don’t need to touch this if you are using Ubuntu Maverick and Arduino Uno combo.

Two extra targets were added to the generated Makefile for your convenience:

Bonus tip

My favorite debugging tool is printf(). The modified version of the Blink application in the template also contains some debug output. Use minicom to read the output from the terminal:

$ minicom -b 115200 -D /dev/ttyACM0

You need to exit from minicom before flash your device again. Do that by hitting CTRL+A and then X.

Disclaimer

Of course that by following this tutorial and using my buildsystem template you can turn your device in a useless geek-looking paperweight. Use at your own risk.

Posted on December 23, 2010 at 10:26 by Thiago · Permalink
In: devel, en, linux, nerd · Tagged with: , , , , , ,

6 Responses

Subscribe to comments via RSS

  1. Written by milton
    on January 12, 2011 at 17:29
    Reply · Permalink

    Vou passar um link por aqui pra circunvencionar a falta de gmail aqui no trampo :-P

    http://news.geek.com.br/posts/14589-geek-usa-arduino-para-fazer-joystick-no-iphone

  2. Written by QueezyTheGreat
    on May 2, 2011 at 06:55
    Reply · Permalink

    Hi,

    Great article, if you are interested I’ve also started an CMake alternative to the Arduino SDK.

    My system integrates with an existing SDK and lets you build using CMake on Windows, Linux and Mac. Also it supports all boards that the SDK supports.

    You can find my project on GitHub at https://github.com/queezythegreat/arduino-cmake .

  3. Written by Layla Chaves
    on October 3, 2011 at 15:23
    Reply · Permalink

    Olá Thiago!
    Meu nome é Layla Chaves! Trabalho em uma empresa de desenvolvimento de software livre e atualmente estamos como uma oportunidade em aberto para desenvolvedor C++.
    Vi que você tem conhecimento nesta área.
    Caso tenha interesse, ou tenha amigos que possam se interessar, favor fazer contato através do email: layla@syst.com.br.

    att

  4. Written by Sathishkumar D
    on November 30, 2011 at 11:36
    Reply · Permalink

    Hi Thiago Marcos P. Santos,

    Thanks for CMake template. Works very fine.

  5. Written by Sathishkumar D
    on December 5, 2011 at 09:30
    Reply · Permalink

    Hi Thiago,

    Based on this and based on http://arduino.cc/playground/Code/Kdevelop, I have developed a template for arduino. I will be very useful to all I hope. You may notice, I have fixed the “firmware” as the default name to the project name. But it works only for the kdevelop.

    You can details at, http://flowersopenlab.weebly.com/4/post/2011/12/using-kdevelop-and-arduino.html

  6. Written by milton
    on January 6, 2012 at 18:54
    Reply · Permalink

    Great work! Tried in a Duomillenove board with very few changes required. Now we can get rid of that clumsy IDE application and come back to Vim ;-)

    However, the reset command did not work. Will send some patches as suggestions to start the discussion.

Subscribe to comments via RSS

Leave a Reply