Setup Eclipse

HowTo Setup Eclipse for AVR software development (for ubuntu)

What you will need?

  1. avr-gcc ( the compiler from c to machine code(hex))
  2. avr-dude ( the program to send the hex file to micro)
  3. eclipse ( IDE Integrated development environment, a software development system)
  4. Programmer hardware ( could be AVRRisp mkII)

1st Let’s install avr-gcc and avr dude on ubuntu

  • $ sudo apt-get install gcc-avr binutils-avr gdb-avr avr-libc avrdude
  • on the shell command do: $ avr-gcc -v ( attention if you want build programs for atxmega, you will need the version => 4.3.0, for atxmega16a4 you will need the 4.3.5 )

2nd  setup the programmer,

  • If you use the AVRRisp mkII programmer, you will need to give some permissions for ubuntu users, for that you need to do:
  1. $ sudo gedit /etc/udev/avarice.rules
  2. add this to the file:
SUBSYSTEM!="usb_device", ACTION!="add", GOTO="avarice_end"

# Atmel Corp. JTAG ICE mkII
ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2103", MODE="660", GROUP="dialout"
# Atmel Corp. AVRISP mkII
ATTRS{idVendor}=="03eb", ATRRS{idProduct}=="2104", MODE="660", GROUP="dialout"
# Atmel Corp. Dragon
ATTRS{idVendor}=="03eb", ATRRS{idProduct}=="2107", MODE="660", GROUP="dialout"

  1. save the file
  2. then on shell $ sudo cp /etc/udev/avarice.rules /etc/udev/rules.d/60-avarice.rules

3rd install Java on Ubuntu

  • you need java-virtual-machine to run Eclipse, for this go to synaptic Settings->Repositories
  • on other software activate the canonical Partners,
  • after this upgrade the list of software and install the package sun-java6-bin and sun-java6-jre on synaptic
  • or on shell run: sudo apt-get install sun-java6*

4 th install the eclipse

  • go to and download Eclipse IDE for C/C++ Developers (you must select this because you mainly will program in C/C++) (if you have 64bit processor choose the version 64bit)
  • on the shell and on the folder where you made the download, make: $ tar zxvf   eclipse-cpp-helios-SR1-linux-gtk-x86_64.tar.gz
  • Then make on shell $sudo mv eclipse /opt/eclipse
  • Then make on shell $sudo ln -s /opt/eclipse/eclipse /usr/bin
  • To start the eclipse just make on the shell $ eclipse  (you can also create an icon for eclipse)

5 th install the plugin for AVR

  • On eclipse go to Help menu
  • the go to eclipse marketplace
  • and find for “avr”
  • install AVR eclipse plugin

Now lets configure the programmer:

  • go Window->preferences
  • Then select AVR->AvrDude
  • Here you will add a new programmer, for our case press ADD, choose a name for the configuration (ex: HardProg),
  • Select the programmer “Atmel AVR ISP mkII”
  • on the override default port, write usb
  • choose the baudrate 38400 (you can select another one)
  • press ok and save

7 th  Save automatically files before build

  • On eclipse there are some default configurations that are not the best ones for our work, one of the is when you build the project this will not save the file before the compilation. To correct this:
  • go Window->preferences
  • Then go General->Workspace and select save automatically before build
  • press ok and save

8 th make test program

  • goto to File->”new project”
  • select C/C++ , C++ project and next
  • choose a project name (Testar_avr)
  • on project type select AVR Cross Target Project , Empty project, AVR-GCC Toolchain
  • press next, and on advanced settings, go AVR, AVRDude , programmer configuration, select HardProg, or you programmer name (named before), the press apply.
  • Here you can also configure the fuses, and other stuffs during the programing
  • Then on AVR, go to Target Hardware
  • Select you AVR, or simply press load MCU, and you will get the AVR type.
  • Press apply
  • Then go to: C/C++ Build -> Settings,  on Additional tools in toolchain, and select Generate HEX file for Flash memory, and select AVRDUDE
  • On: C/C++ Build -> Settings,  on AVR Compiler, on Optimization, select Moderate optimize (-o2)
  • Save and close

Now, if you are programing one atxmega, you can add main.c file an put this code (based on

[code lang="C"]
*              XMEGA test FlashBus clock 32M
#include <avr/io.h>
#include <stdint.h>
#include "clksys_driver.h"
#include "flashbus.h"

#define memmory_size 255
volatile uint8_t memmory[memmory_size];

bool FbSwrite_memory(uint8_t addr, uint8_t data){
if (addr<memmory_size){
       return true;
       return false;

bool FbSread_memory(uint8_t addr, volatile uint8_t* data){
    if (addr<memmory_size){
             return true;
         return false;

int main(void){

//clock configuration, 32 MHz Internal RC Oscillator
      CLKSYS_Enable( OSC_RC32MEN_bm );
      do {} while ( CLKSYS_IsReady( OSC_RC32MRDY_bm ) == 0 );
      CLKSYS_Main_ClockSource_Select( CLK_SCLKSEL_RC32M_gc );
      CLKSYS_Disable( OSC_RC2MEN_bm | OSC_RC32KEN_bm );
      // I/Os


     /* Enable global interrupts. */

  • Now, save the file. and on the project, press right button mouse, and make build project. You will get the firmware on the atxmega. (Attention to setup to build release code not debug)

9th install a terminal for debug communication (RS232)

Before install the terminal for debug, you will need to install a driver java to get access to serial port. For this: ( This is based on this document )

  • In Eclipse, go Help->Install New Software
  • add a new remote site, name=RXTX  and URL =
  • Finish and select the last version of RXTX an install It

Now let install serial terminal (console-DSDP Target Management Plugin):

  • In Eclipse, go Help->Install New Software
  • add a new remote site:
  • name=DSDP TM 2.0 Update Site
  • and URL =
  • Finish and select the last version of DSDP an install it
  • restart the eclipse
  • go to window->show view->other then select terminal

Now you will get a new window, on bottom that you could use for communication SSH, Telnet or serial console.

10th Configuration for AVRDude work with arduino


(Special thanks to: Heber, Miguel, Prof. Paulo Costa)

Good luck and programing