Saturday 30 April 2011

AVR and Ubuntu

Today I have been trying to compile the code in Ubuntu environment. This is what I have done.

First of all I have installed the packages agcc-avr, binutils-avr, gdb-avr, avr-libc and avrdude

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

Then, I have download the Eclipse 3.4 (Ganymede) for C/C++. You can download it from:


After installing the Eclipse you have to install AVR plugging. To do it, go to the Software update dialog (Help >Software Updates...)

Then select the Available Software tab. Click on the 'Add Site... button o the right hand side and enter the URL of the update site:

http://avr-eclipse.sourceforge.net/updatesite/

Then click on OK. The AVR Eclipse update site is now shown in the list of update sites. Select the "AVR Eclipse Plugin" and press the Install... button in the top right corner.

To setup the tool you have to follow the next steps:
  • goto to File->”new project”
  • select C/C++ , C++ project and next
  • choose a project name (Test_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)
Well, that's all. You can send me a mail if you have some question.