AVR Studio for Ubuntu 11.10

About AVR

The ATMEL AVR is a modified Harvard architecture 8-bit RISC single chip microcontroller which was developed by Atmel in 1996. The AVR was one of the first microcontroller families to use on-chip flash memory for program storage, as opposed to one-time programmable ROMEPROM, or EEPROM used by other microcontrollers at the time.The AVR is a modified Harvard architecture machine where program and data are stored in separate physical memory systems that appear in different address spaces, but having the ability to read data items from program memory using special instructions.

Atmel® AVR Studio® is the Integrated Development Environment (IDE) for developing and debugging embedded Atmel AVR® applications. The AVR Studio gives a seamless and easy-to-use environment to write, build, and debug your C/C++ and assembler code. The Studio is integrated with Compilers, assembler and a simulator, and interfaces seamlessly with in-system debuggers and programmers to make Windows code development easier.

In this post,I will demonstrate how to create your own version of Atmel AVR Studio for Ubuntu 11.10. The post explains two (2) different ways of compiling, simulating , debugging and burning of hex unto any AVR microcontroller without the use Atmel AVR Studio.

AVR Development Environment Setting

    1.  Repository index update
      sudo apt-get update
    2. *C Compiler installation
      sudo apt-get install gcc # c compiler download
      sudo apt-get install build-essential # Packages which are considered essential for building Debian packages

      *skip this section, if your gcc is the current one

    3.  AVR Packages Download
      sudo apt-get install gcc-avr   # A port of GCC to AVR target processor
      sudo apt-get install gdb-avr   # AVR GNU debugger
      sudo apt-get install binutils-avr #low-level utilities for building & manipulating object files
      sudo apt-get install avr-libc # AVR Library files
      sudo apt-get install avrdude # command-line program for programming AVR chips.

MakeFile Configuration

MakeFile is a utility for automatically building executable programs and libraries from source-code.

    1. AVR MakeFile Template Download                                                                 
      Download the make file for AVR microcontrollers from here.
      NB: The downloaded file should be saved into your project directory.The file should be as as “MakeFilewithout extension.
    2. AVR MakeFile configurationAssumption: I’m assuming that The microcontroller is ATmega32 and programmers hardware is JTAG ICE. Then the following parameters commented in bold should be edited.
      MCU=atmega32 /*Add the name of the processor you are using */
      PROGRAMMER_MCU=m32 /* This is microcontroller id. see manual pages of avrdude. i.e gedit /etc/avrdude.conf */
      PROJECTNAME=myproject /* Project name , This could be anything you wish */
      AVRDUDE_PROGRAMMERID=jtagmki  /*Programmer ids are listed in /etc/avrdude.conf */
      AVRDUDE_PORT=/dev/ttyUSB0 /* Make sure that driver for parallel port is loaded and working and change permissions to 777 */

Sample code Testing

    1. Sample source code
      #include <avr/io.h>
      int main(void)
      // Set Port D pins as all outputs
      DDRD = 0xff;
      // Set all Port D pins as HIGH
      PORTD = 0xFF;
      return 1;
      • Save file to the same directory as the MakeFile
      • Use your terminal and navigate to the file directory.
    2. Execution command
      $ make              /* Compile your project*/
      $ make hex        /* Generate hex file */
      $ make install    /* Burn hex file in microcontroller ( Make sure your board is switched on and programmer is connected )*/


    1. http://stringofthoughts.wordpress.com/2009/11/06/setting-up-avr-development-environment-in-ubuntu/
    2. http://www.ladyada.net/learn/avr/setup-unix.html
    3. http://www.atmel.com/microsite/avr_studio_5/default.aspx
    4. http://en.wikipedia.org/wiki/Atmel_AVR

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s