AVR development with GNU/Linux tools


Electronics freaks all around the world are rapidly moving toward Linux based free tools for thier development work. Most of the newbies find it difficult to switch fully to linux as the lack of availability of window counterpart tools in linux.

Here i am giving you an idea how to start AVR development while you are using some Linux distro as your OS. Now a days UBUNTU is one of the most popular Linux distro for beginners because it is very easy to use, and most of the necessary tools are packed with the distro.

Here i am describing how to write a program, compile a program and burn the AVR in UBUNTU. I checked this procedure on UBUNTU Desktop edition 8.10 it should be compatible with others also but i didnt try. So lets start your embedded world on linux too

To start with AVR development on linux you need following four packages.

1. avr-gcc
2. avr-binutils
3. avr-libc // standard AVR C library
4. avr-dude // basic package that transfers ur ihex to MC.

The whole installation procedure is explained in this document, but first i will explain you what these above 4 packages actually are;

avr-gcc is the �C� cross compiler for AVR which generates

The binutils package provides all the low-level utilities needed in building and manipulating object files. Once installed, your environment will have an AVR assembler (avr-as), linker (avr-ld), and librarian (avr-ar and avr-ranlib). In addition, you get tools which extract data from object files (avr-objcopy), dissassemble object file information (avr-objdump), and strip information from object files (avr-strip). Before we can build the C compiler, these tools need to be in place.

it is the satndard function used while programming for AVR in C. It consistes of header files for utilizing the features of AVR like Interrupts, EEPROM, I2C, SPI, UART etc. For more info go to AVR-libc home http://www.nongnu.org/avr-libc/

AVR-DUDEi is an open source utility to download/upload/manipulate the ROM and EEPROM contents of AVR microcontrollers using the in-system programming technique (ISP). For more info try this : http://www.nongnu.org/avrdude/

That is all about what AVR specific tools you need to do your stuff but first thing you need is some editor where you can type your code. I use gEdit as a text editor on my machine. Below is the command to install gEdit.

Installing gEdit Text editor

After this process get complete you have gEdit install on your machine. Now you can run gEdit by typing �gedit� on your terminal. Now there is an utility called embedded terminal which can be plugged in with gEdit so that you can run commands right from the editor�s bottom pane.

Now follow these simple steps to embed the terminal with gEdit.

1. Run gEdit by typing gedit on terminal
2. Noe in gEdit goto menu Edit >> Preferences >> Plugins tab choose Embedded terminal

Now we have our Text editor Done !!! Lets move onto installing avr specific utilities

Installing avr - gcc

Installing avr - libc

Installing avr - dude

Few Final Steps…

1. Write your code inside editor.

2. After writing your code go to embedded terminal at bottom pane and change your path to the directory where the source files and MAKE file is stored.(My case /home/deveshsamaiya/Documents/LCD/)

3. On embedded terminal prompt type make clean ; this will remove all the previosly compiled project, object files. it is quite necessary if the source is newer.

4. Now time to compile your code and to find Bugs. Run command make all in terminal. This will find any error in the source if the source is error free it will create the iHex file and other interface files.

5. Now suppose your source is compiled successfully without error/warnings. Now we need to transfer the iHex file into AVR flash.

Here comes the role of AVRdude which is already installed as disscussed earlier.

First you need to specify the type of programming harware you are using for transferring the code. If u r using parallel port BSD programmer modify programmer as bsd in MAKE file. I used a serial programmer so i wrote programmer as ponyser similarly u can use different names for programmers like USBasp etc. we will disscuss the role of MAKE file in AVR-gcc after doing this.

Finally issue command make program to transfer the data onto flash.

IF the above last process get completed successfully then you are done your AVR Micro is ready to perform the programmed task.
Below are some settings for MAKE file (programmer and PORT), i used programmer as ponyser and port as /dev/ttyS0 its com1.

Download Sample make file here

Your Name

Your Email

Speak your mind - Comments and/or Questions

Best viewed at Firefox 1024x768 resolution