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.
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:
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:
- make flash – Will flash your software to the device connected on ARDUINO_PORT.
- make reset – Restart your board (pretty much the same as the reset button on the board).
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.
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.
In: devel, en, linux, nerd · Tagged with: arduino, buildsystem, cmake, hack, hardware, howto, ubuntu