# Arduino Support

This section describes how to use Zigbit modules in the Arduino Build Environment. Currently the build process is described for Linux.

## Build the Arduino Environment from the Sources.

Get Arduino Sources

     svn checkout http://arduino.googlecode.com/svn/trunk/ arduino  && echo OK

The checkout may need several retries, since connection maybe reset during checkout. If you see "OK" on the command line, then svn has succeeded. (Normally you will need 2 to 5 retries, depending how often the svn server cancels the the connection).

Note:
  In order to save the time of a complete check out for later updates, zip the build directory now.

Prebuild the distribution

The next step patches some source files and builds the distribution.

     cd arduino/
     patch -p0 -i [uracoli-src-dir]/Contrib/Arduino/zigbit.patch
     cd build/linux
     bash make.sh

The make.sh script produces this output:

     Setting up directories to build for Linux...
     cp: cannot stat `../shared/libraries': No such file or directory
     Copying examples...
     Extracting reference...
     Extracting JRE...
     Building processing.core
     Note: Some input files use unchecked or unsafe operations.
     Note: Recompile with -Xlint:unchecked for details.

     Done.

While running make.sh, it seems that the following error message can be ignored.

     cp: cannot stat `../shared/libraries': No such file or directory

Build your personal Zigbit Arduino Distribution

     cd arduino/build/linux
     cp -rfv [uracoli-src-dir]/Contrib/Arduino/examples/* ../shared/examples/
     cp -rfv [uracoli-src-dir]/Contrib/Arduino/hardware/* ../../hardware/
     bash dist.sh

The dist.sh script produces this output:

      Creating Arduino distribution for revision 0018...
      Building processing.core
      Note: Some input files use unchecked or unsafe operations.
      Note: Recompile with -Xlint:unchecked for details.

      Done.
      cp: cannot stat `../shared/libraries': No such file or directory
      Copying examples...
      Extracting reference...
      Creating tarball and finishing...
      Done.

Install and Test the new distribution

The result file is arduino-<version>.tgz, unpack it and start arduino in the usual way.

Copy arduino-<version>.tgz to a save place and remove the arduino directory.

     tar xvzf arduino-<version>.tgz
     cd arduino-<version>
     ./arduino

## Patch arduino binary distribution

Todo:
  Check if it would be possible to replace the patched Compiler.java in the jar archiv, so only this file needs to be checked out. (see arduino/build/linux/work/lib/pde.jar that contains arduino/app/src/processing/app/debug/Compiler.class)