Arduino Source developer setup

I'm interested in contributing my code skills to the arduino project. I have manage to build it with ant as detailed in the build instructions on the github wiki and am interested in diving deeper. I have had some difficulty setting up a debug environment for the code however. I have tried opening the various eclipse projects, resolving the compile errors (mostly due to no main-class being specified in processing-head and your classpath libraries in your project settings being out of date), but ran into a number of runtime errors that made it increasingly obvious that this was probably not the way the arduino devs set up their dev environment.

I have searched both the forums, arduino documentation, and the arduino devs mailing list and have found little help so far. Which development environment (OS, tools, IDE if any) should be used to debug the arduino source code? How should I set up such an environment?

I've figured it out. Here are the steps it took for me to be able to debug Arduino 1.8.6 from Eclipse in linux. It is likely that a few steps will need to be modified if you are running from Windows or Mac OS but hopefully this will give you some guidance.

I am using the Eclipse Photon (4.8.0) for Java.

First you must download the source code from github.

  • First you must download the source code which I will assume is stored in a folder called "Arduino" for future steps.

  • Build it using "ant dist" from Arduino/build. This will fetch all of the necessary C++ libraries from the internet that will be needed for later steps. It may be necessary to run it as well using "ant run", but I would do it even if it wasn't to ensure it is working properly.

  • Import processing head (Arduino folder), arduino-core, and processing (Arduino/app) projects into eclipse

  • (Optional) add the build.xml files to the ant window

  • Open the project settings for processing-head and go to Run/Debug Settings. Create a new one or edit the existing with the following settings:

  • Project: processing-head

  • Main-Class: processing.app.Base

  • Open project settings for processing-head

  • Navigate to Java Build Path, libraries tab

  • Delete all libraries other than JRE System library as they are out of date

  • Click add external jars

  • Add all jars from the Arduino/app/lib folder

  • Add all jars from the Arduino/app/test-lib folder

  • Remove the slf4j-simple-(version).jar file from the libraries or it will cause an error.

  • Copy the Arduino/build/(os)/work/lib folder to the Arduino folder. Where (os) should be replaced with your os. In linux you can just create a symlink instead.

  • Copy Arduino/build/(os)/work/hardware/platform.keys.rewrite.txt to Arduino/hardware. Where (os) should be replaced with your os. Symlinks don't seem to work for this one.

  • Navigate to Arduino/build/(os)/work where the script to launch arduino should be found. I was able to find this location by looking at the build.xml file in Arduino/build and following the "run" target. At the end of this file I found the command used to run Arduino, but it uses numerous variables so I echoed the command instead of running it. For example:
    echo "$JAVA" "${JAVA_OPTIONS[@]}" processing.app.Base "$@"
    This printed the command to the command line. This was important for obtaining the command line parameters passed to the JVM:

-DAPP_DIR=/home/cptmonkeyfist/src/arduino/build/linux/work 
-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel 
-splash:/home/cptmonkeyfist/src/arduino/build/linux/work/lib/splash.png
  1. Copy the parameters. In Eclipse, open the project properties again for processing-head. Go to Run/Debug settings and open the configuration you created earlier. Open the Arguments tab and paste the arguments you copied earlier to the VM arguments box[/li]

You should now be able to run/debug the Arduino IDE.

Thanks for your interesting in contributing to the Arduino project and for taking the time to document your findings! Although I am a contributor to the project, I haven't done much on the Java side of things so I've never had to go through all this stuff.

Thanks! This is likely to come in handy sometime.