Eclipse - Arduino - Installation

You would like to program with Arduino but you can't do this with the Arduino Software provided.

Instead you would prefer to use your favorite IDE: Eclipse.

That's what we're going to see in this Eclipse and Arduino setup tutorial from scratch.

We are going to see settings for the Arduino ADK ATmega 2560 and the Arduino Uno.

Installation on Linux Ubuntu

What we need

  • Linux Ubuntu 12.04

  • The avr-gcc compiler

  • Openjdk, the open source version of the JDK (Java Development Kit)

  • Eclipse Juno CDT (or JavaEE)

  • Arduino library

Java

We need the JDK and we will use the open source version. I invite you to install the version 6 (and not the 7) due to security issues in the seventh one.

This version is the OpenJDK 6 and you can either install it with the USC (Ubuntu Software Center) or with the following command line:

sudo apt-get install openjdk-6-jdk

The compiler

The compiler is avr-gcc.

To dowload it, two solutions:

  • Either go in the USC and search for: gcc-avr

  • Or type the following command line:

sudo apt-get install avrdude binutils-avr gcc-avr avr-libc gdb-avr

Once downloaded, the compiler is available by typing in your shell:

avr-gcc

You can note the difference between the gcc-avr and avr-gcc writings. A bit confused at beginning.

Eclipse

  1. Download Eclipse Juno CDT ou Java EE on the official website: http://www.eclipse.org/

  2. Open Eclipse

  3. Click on Help > Install New Software

  4. On the text input on the right of "Work with :" there is a little triangle (at the left of the Add... button). Click it and select: Juno - http://download.eclipse.org/releases/juno

  5. Wait for the list

  6. Once the list is there, click on Programming Languages to display its content

  7. Select:

  • Autotools support for CDT 3.0.1.201209170703
  • C/C++ Call Graph Visualization 1.0.0.201209191645
  • C/C++ Development Tools 8.1.1.201209170703
  • C/C++ Development Tools SDK 8.1.1.201209170703
  • C/C++ Library API Documentation Hover Help 1.0.0.201209191645
  • C/C++ Unit Testing Support 7.0.0.201209170703
  1. Click Next > Next

  2. Accept agreement

  3. Click Finish

  4. Plugins are installing themselves and then Eclipse asks to restart, click Yes

  5. Once restarted, click Help > Eclipse MarketPlace

  6. In the text input Find, write avr then click Go on the right

  7. Once the AVR Eclipse Plugin is found, click Install and Eclipse should restart

  8. Create a new C++ project, select AVR Cross Target Application then Empty Project (the toolchain AVR-GCC Toolchain is already selected by default) and write the following project name: 
    proj-1 then click Next twice

  9. Right click on proj-1 > Properties > ADR > Target Hardware, fill Type by ATmega2560 (or ATmega328p for the Uno) and Frequency by 16000000, click Finish.

  10. Right click on the project > Properties > AVR > AVRDude

  11. In the Programmer tab, click New on the right

  12. The window Edit ADRDude Programmer Configuration New Configuration opens

  13. In Configuration Name, write Arduino ADK ATmega 2560 for example (or Arduino Uno)

  14. In Programmer Hardware (-c), select: Atmel STK500 Version 2.x firmware for the ATmega 2560 (or Atmel STK500 Version 1.x firmware for the Uno) if it was not already done

  15. In Override default port (-P), write: /dev/ttyACM0

  16. In Override default baudrate (-b) select: 115200

  17. Click OK > OK

Arduino Library

We have now to download the Arduino library in order to add it to our project.

  1. Go on the following link and select the version of your choice, in my case Linux 64-bit (if you hesitated, you should take the 32-bit version) : http://arduino.cc/en/Main/Software

  2. Once downloaded, extract it where you want, I put it in: 
    /home/mi-k/soft/arduino

  3. Then take the pins_arduino.h file of our board Mega ADK from:
    /home/mi-k/soft/arduino/arduino-1.0.3/hardware/arduino/variants/mega
    (Or /home/mi-k/soft/arduino/arduino-1.0.3/hardware/arduino/variants/standard for the Uno)

    And put it in:

    /home/mi-k/soft/arduino/arduino-1.0.3/hardware/arduino/cores/arduino

    So the file pins_arduino.h is now in cores/arduino.

  4. Now in Eclipse > Right click the project > Properties > C/C++ Build > Settings > Tool Settings > AVR Compiler > Directories

  5. Click the tiny plus green icon to add the path until your Arduino library

  6. Select File System and browse until the library folder, for example:
    /home/mi-k/soft/arduino/arduino-1.0.3/hardware/arduino/cores/arduino

  7. Click OK > OK

  8. The library is now in the includes of your project

  9. Create a C++ file on your project, for example go.cpp

  10. Within copy paste the following snippet:

#include "Arduino.h"

void setup() {
    pinMode(13, OUTPUT);
}

void loop() {
    digitalWrite(13, HIGH);   // set the LED on
    delay(1000);              // wait for a second
    digitalWrite(13, LOW);    // set the LED off
    delay(1000);              // wait for a second
}

Plug your card on your computer via the USB slot and put a LED on the pin 13.

Build your project and send it to your Arduino Mega ADK (or Uno) board with the AVR icon.

You could also send it by the following command line, by puttin the shell at the root of your project.

For example, you should have this in the directory /home/mi-k/dev/proj-1/:

  • go.c
  • Release/proj-1.hex

So, just send your .hex in your board from the directory proj-1/ by typing the following line (with a sudo if access is denied for example to open ttyACM0).

For the Arduino Mega ADK 2560

avrdude -p m2560 -c stk500v2 -P /dev/ttyACM0 -b 115200 -F -U flash:w:./Release/proj-1.hex -D

For the Arduino Uno

avrdude -p m328p -c stk500v1 -P /dev/ttyACM0 -b 115200 -F -U flash:w:./Release/proj-1.hex -D

Conclusion

Wow, it wasn't so easy.
But you are now free to use your favorite IDE to develop your next Arduino programs.

Congratulations, you made it! cool

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.