Apr 16 2012

Building Arduino From Eclipse

Category: Hardware,Java,Open Sourceadmin @ 8:08 pm

Arduino is not new to the tech world and it is an interesting hardware and software combo project that have pique the interest of different developers around the world. Personally myself have been into Arduino for the last 8 months and I love every bit of it. I love working with open source project and always enjoy spending time digging through the code to see what is going on internally, so to allow me to do this for Arduino I’ve created a step by step guide on how to setup Windows environment to allow me to debug and work with Arduino IDE code.

The picture in each step can be viewed properly if you click on it.

1. Download Eclipse from www.eclipse.org . In my case I downloaded Eclipse Classic 3.7.2 (Windows 32 bit)

2. Make sure you have JDK installed on your machine. I’ve got the following version of JDK installed on my Windows machine

3. Unzip the downloaded Eclipse file into a directory. You will see directories and files as follows

4. Start up Eclipse by executing the eclipse.exe executable. Once startup completed you will be shown the initial screen to select a workspace. Just select any local directory that you want to use to host your project in.

5. On clicking OK from the previous step you will be display a welcome page from Eclipse and now you can start using Eclipse

6. Now you are ready to checkout Arduino source code. The source code is hosted in github.com https://github.com/arduino/Arduino. If you have used git before than you can go ahead and check out the code otherwise the easiest way to use the code is to download the source in .zip format by clicking on the ZIP icon in github webpage

7. Once the .zip file has been download extract it to a separate folder and you will have directory as follows

8. Make sure the Java environment has been setup properly by going to Window ? Preferences. Specify the full JDK instead of only the JRE (Java Runtime Environment)

9. Arduino comes with Eclipse .classpath which means that all you have to do is import the project into Eclipse using the Import menu

10. Select Existing Projects into Workspace from the Import window. Click on Next button

11. Select the directory containing the Arduino source code. Once selected you will see something like the following. Click on the Finish button

12. You will see errors in the Problems tab as shown below. The following next few steps will show you how to fix this problem.

13. Right click the processing-head project from the Package Explorer as shown below. Select the Properties menu from the popup menu

14. Select the Projects tab from the Properties fro processing-head window. Select the processing-core (missing) option and click on the Remove button

15. Switch to the Source tab as shown below

16. Select the processing-head/app/src and remove it by clicking on the Remove button, your window will look as follows.

17. Open up a file called .classpath, if you can’t see it in the Package Explorer or Navigator you can open it by pressing Ctrl + Shift +R at the same time and type in .classpath in the Select an item to open

18. When the file is opened copy and paste the following text into the file save the file. The XML configuration that you copy and paste is to tell Eclipse what are the source files that need to build/included when building the .java files.

<?xml version="1.0" encoding="UTF-8"?>
	<classpathentry excluding="processing/app/tools/format/|processing/app/tools/format/src/|processing/app/Trace.java|processing/app/RunnerClassLoader.java" kind="src" path="app/src"/>
	<classpathentry excluding="app/src/|build/javadoc/|build/linux/|build/macosx/|build/shared/|build/windows/launcher/|core/methods/|core/preproc/|core/src/" kind="src" path=""/>
	<classpathentry excluding="tools/Mangler/src/" kind="src" path="build/shared"/>
	<classpathentry kind="src" path="core/src"/>
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
	<classpathentry kind="lib" path="app/lib/antlr.jar"/>
	<classpathentry kind="lib" path="app/lib/apple.jar"/>
	<classpathentry kind="lib" path="app/lib/ecj.jar"/>
	<classpathentry kind="lib" path="app/lib/jna.jar"/>
	<classpathentry kind="lib" path="app/lib/RXTXcomm.jar"/>
	<classpathentry kind="output" path="app/bin"/>

19. Now you need to setup the launch configuration to tell Eclipse how to launch the application including specifying the location of the java binaries and .dll files that are used by Arduino. You do this by clicking on the green button on the top menu as shown below and select Run Configuration…

20. The Run Configurations window will show up. Select the Java Application and click on the New Launch Configuration as shown below

21. For the new configuration there are few things that you need to do. Click on the Browse… button to select the project (in this case processing-head). You also need to specify the main class that will be run, you can select it by using the Search… button and select process.app.Base as shown below

22. Click on the Arguments tab and fill the following under the VM arguments: section


For the user.dir make sure you put in the correct directory location that host the Arduino source, the same applies for the java.library.path

By default the location of the binaries is under /app/bin

23. Now you need to extract the avr compilers that Arduino uses to compile the code. The compiler is inside a .zip file called avr_tools.zip which is inside the\build\windows directory. Unzip the files into the\build\hardware directory as shown below. This step will allow Eclipse to find the appropriate files when Arduino is trying to compile/upload the application. The compiler is a command line application that will be launched by Arduino when needed.

24. Following is the final layout of my Eclipse, see if your Eclipse match with what is shown below

25. Once all the steps have been completed you can launch Arduino by launching the configuration that you have configured before as follows. Click on the Run button.

26. Voila! Arduino is running and ready to compile your application.

Tags: , , , ,

One Response to “Building Arduino From Eclipse”

  1. Martin Bless says:

    Wow! That really looks great. And complete! I’ll try ASAP to adapt that to Netbeans 7.x. Should be possible I guess. Thank you very much for posting!

Leave a Reply

eight − 7 =