UDOO command line environment to compile and flash Arduino sketch from shell.
C HTML C++ Objective-C Arduino Assembly Other


UDOO Arduino CLI

It's for anybody who is looking for a headless command line compiler and flasher for your UDOO board to build and upload your Arduino sketches directly and internally from inside a UDOO Linux shell.



We are using great UDOO boards to build our products. But when we had to update and flash our sketches to the Arduino Due it was a boring task to start Arduino IDE on second computer, connect via USB, remove Jumper JN18, compile and flash etc. This was even time-consuming when trying to roll-out to a number of devices.

In case of a less resource consuming OS we are running the Linux OS on UDOO board without Xserver. So normal Arduino IDE on board was no option.


Let's assume that you want to run one of the famous blink examples on your Arduino Due.
Now you can compile and flash with this easy command:

udoo-arduino-build --flash-sam Blink.ino

All is done local on your UDOO, you do not need X or Java or ... :-)


If you want to do it like above, just install the latest deb packages to your UDOO.
check and download latest releases, e.g.:

cd /tmp
wget https://github.com/TomFreudenberg/udoo-arduino-cli/releases/download/v1.6.1-pre1/udoo-arduino-cli-1.6.1-pre1_all.deb
sudo dpkg -i udoo-arduino-cli-1.6.1-pre1_all.deb

All done!

Getting started (the quick way)

Complete magic is handled by the script udoo-arduino-build which is also linked to /usr/local/bin so that you can enter this command system-wide.

Build usage:

e.g. compile and flash MySketch.ino and add the standard Servo library to your build process:

udoo-arduino-build --flash-sam -L Servo.cpp MySketch.ino

Flash usage:

e.g. flash previously created MySketch.bin:

udoo-arduino-build --flash-sam MySketch.bin

The flash procedure is handled by included bossac utility and via the internal processors serial communication device (normally /dev/ttymxc3).

Make your sketch (extended usage)

There are some really useful cmdline options available for udoo-arduino-build script.

udoo-arduino-build [-I <path>] [-L <library.cpp>] [-o <path> [--fast]] [--copy] [--flash-sam] sketch.ino [<sources.cpp>]"


Show help and command usage info.

-I <include-path>

Append additional folders to INCLUDES path for compiling your sketch.ino. Path may be relative or absolute. If you divided your source into several pieces, you may include custom library folders like -I ./my_libs

-L <library.cpp>

Add necessary standard libraries to your project. Correct library path is automatically located by searching the libraries main .cpp-file. If you need the Servo library, you can add it just by -L Servo.cpp. You can add this option as often as needed like -L Servo.cpp -L Wire.cpp.

If you need to include libraries from local or project directories as well, you can add also relative librariy files like -L mylibs/motor/Motor.cpp

-o <build-path>

Normally the script will create a temporary folder like /tmp/udoo-arduino-build-12345 and remove this folder after build process – even when build was successful or not. If you like to use a defined folder it is possible to set your own build-path by this option.


Fast is an addtional option to build process. Instead of rebuilding all sources (your and standard Arduino) the --fast option will try to re-use already built objects from standard sources. To use this option, you have to specify your own -o build-path because the temporary folders will be dropped each time.


After a successful build of your sketch.ino the generated sketch.bin will be copied and backuped from your build-pathto your sketch project-path. You can flash this binary on multiple boards or publish it to others.

-A <arduino (ide) installation path>

If you do not use default installation of udoo-arduino-cli or want to try another build environment, you may change the base installation path.


Run the flashing process after build or as a single action. The Atmel SAM Flash will be erased before flashing and the CPU gets a reset finally.


Just erase the Atmel SAM Flash and reset its CPU. This has to be a single action.


Just reset the Atmel SAM CPU. This has to be a single action.

-D <internal UART device for interprocessor communication>

If on any reason necessary you can change the default device ttymcx3 when flashing your sketch.


To allow maximum control of the build process you can disable some magic like the appendixes for automatically compatibility. This option will prevent include "Arduino.h" headers.


To allow maximum control of the build process you can allow linker to build binary even when there are undefined reference warnings.


This is 100% Arduino IDE, so it is 100% compatible to your existing sources. The Arduino IDE does some magic before running the compile process and so we do it too - that is: Adding references like #include <Arduino.h> of standard Arduino headers so that you may use code like digitalWrite(13, HIGH); without changing your codes. All should be getting compiled as in Arduino IDE.

Use clone from this repository

If you wish to create the deb package by yourself or want to make some changes, you just can clone this repo to your development machine. I added a script build-dpkg-deb and that will generate a debian installer package from within your cloned filespace. So you still can publish your changes easily all the time to your UDOO board(s).

Some background information

Looking for a suitable solution

I read a lot of information on the internet but did not find anywhere a suitable solution. The cool arduino-mk project did not handle the Arduino Due micro-processor. At least I tried to re-engineer the command sequences from Arduino IDE and got some really useful hint from user fletchers post on UDDO forum.

Ongoing with the idea behind his script I decided to build a complete CLI which should be easy to install on UDOO boards. This ends-up in this new repository and package. You can download an installable debian package directly from release section: show releases and downloads

How was this environment created?

I built up the first release based on original Arduino IDE (stable release 1.6.1) taken from http://arduino.cc/en/Main/Software. In case that I do not wanted any IDE part, I dropped any file and folder referencing this. The standard Arduino IDE is not built for ARM device so I tried to run the build process on my UDOO. This did not worked in a number of issues I would not have to solve. So I extract the Arduino IDE 1.5.8 from UDOO 1.1 image (see: /opt/arduino-1.5.8) and replaced the folder hardware/tools with the folder from UDOO image. Last I checked all libraries and ran some tests to find out, that Arduino 1.6.1 changed something in UARTClass and USARTClass. Those contained only minor changes and I replaced this 5 source files also with the correspondings from UDOO image.

That's it! Now you have an environment with Arduino 1.6.1 sources and libraries and an UDOO compatible Arduino Due (SAM3X) gcc-4.8.3 (20131129) toolset. Last but not least also the bossac flashing tool works well.


Here are some of the ressources which I consumed during this work.

UDOO pages
  1. http://www.udoo.org/downloads/
  2. https://github.com/UDOOboard/Arduino
  3. http://www.udoo.org/forum/here-script-compile-upload-arduino-sketches-via-cli-t1822.html
  4. http://www.udoo.org/forum/program-arduino-without-using-arduino-ide-t1642.html
  5. http://www.udoo.org/forum/debian-jessie-rootfs-with-gpu-vpu-t693.html
  6. http://www.udoo.org/forum/eclipse-ide-atmel-asf-alternative-arduino-ide-t1260.html
  1. http://arduino.cc/en/Main/Software
  2. https://github.com/arduino/Arduino/tree/1.6.1
MIXED internet pages
  1. https://github.com/amperka/ino
  2. http://www.shumatech.com/web/products/bossa
  3. http://www.atwillys.de/content/cc/using-custom-ide-and-system-library-on-arduino-due-sam3x8e/?lang=en
  4. http://arduino.stackexchange.com/questions/1312/not-using-the-ide-and-understanding-the-compilation-linking-upload-process
  5. http://www.linuxcircle.com/2013/05/15/programming-and-uploading-arduino-sketch-without-ide/
  6. http://hardwarefun.com/tutorials/compiling-arduino-sketches-using-makefile
  7. http://stackoverflow.com/questions/15184932/how-to-upload-source-code-to-arduino-from-bash
  8. http://www.cloud-rocket.com/2014/05/programming-arduino-due-atmel-studio-asf/