AVR development using tools with UBUNTU 8.10

September 9, 2009 by admin
Filed under: Microcontrollers, electronics 

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 post, but first i will explain you what these above 4 packages actually are;

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

avr-binutils- 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.

avr-libc- 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-dude-

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..

gedit

This command will ask for your root pasword enter it !!! then it will start building dependency tree for the package.

gedit2After 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.

To install embedded terminal you need to run a command below…

embeddedterm

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

plugingedit

Now Press Close button and the command line is added with gEdit, so that now you can type, make and burn your code from a single window.

gEdit screenshot electroons.com

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

Installing AVR-gcc cross compiler ???

1. Run the command as shown in images below.

avrgcc

2. Enter sudo password.

3.Now AVR-Gcc is installed on your PC

Installing AVR-libc ???

1. Run the following commands as shown in the screen shot below.

installavrlibc

Installing AVR dude ???

avrdude

Now we are almost done with all the necessary tools installed…Lets see how to compile, debug and burn the source code…

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 a Sample MAKE File Here

If you have any queries and if found any trouble while developing AVR on ubuntu do ask by commenting here or my email id is: devesh@electroons.com

Thanx for visiting, i hope u enjoyed this articlea

Comments

4 Comments on AVR development using tools with UBUNTU 8.10

  1. Ketan kothari on Sat, 12th Sep 2009 3:37 pm
  2. Nice information About a quick start in linx…….
    GOOD JOB.

  3. mRin on Fri, 16th Oct 2009 6:21 pm
  4. hi, good tuto, I did everything I stand alone but is an error when running MAKE ALL comendo him and do not know how to fix it:

    mRin @-laptop: ~ / Documents / robot / test / IOTest $ make all

    ——– Begin ——–
    avr-gcc (GCC) 4.3.2
    Copyright (C) 2008 Free Software Foundation, Inc.
    This is free software, see the source for copying conditions. There is NO
    warranty, not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    make: *** No rule to make target `main.elf ‘, needed by` elf’. High.

    I hope you can help me.

  5. admin on Fri, 16th Oct 2009 11:04 pm
  6. check whether u have modified the target ‘C’ file in MAKE file as the name your source file or not.

  7. Florin Wacykiewcz on Mon, 16th Nov 2009 12:34 pm
  8. I just install it all the way you described on Ubuntu 9.10 and it works fine.

    Thank you!

Tell me what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!





Anti-Spam Protection by WP-SpamFree