ELECTRONS.PSYCHOGENIC.COM NEWS   RAVES & RANTS   GAMES   CONTACT US    
HOME ACCOUNT PRIVATE MESSAGE  
Main Menu

Login

Electrons :: Articles :: AVR :: Let's build a toolchain
Let's build a toolchain
Description: This article focuses on building a GNU toolchain for microcontroller development on a Linux System.

  • 1. Building a GNU AVR toolchain
Building a GNU AVR toolchain

A toolchain is defined as bundle of Tools (Software Programs) that are must for developing a particular hardware target. They are known as "Tool Chain", as output of one tool is input for another.

Let's have a look on main components of toolchain:

  1. Text Editor: Purpose for entering source code.
  2. Compiler and Linker: Converts source code into Executable.
  3. Libraries: Interface to Operating systems.

In this article we are more concern about building a GNU toolchain for microcontroller and then using that toolchain for developing programs and porting on the same. I have done this work on Fedora4, but I hope it will work on Redhat also

Reasons for choosing GNU/Linux as our platform:

  1. Free Free, yes most of the tools like assembler compilers are freely available.
  2. More opportunity to play with code and experiment, as code is also available.
  3. Quality programs are available to transfer machine code to microcontroller.
  4. Most of microcontrollers (especially from Atmel and Microchip) provide good support for GNU/Linux

We divide our whole process into two stages.
Stage1: Building the Toolchain for microcontroller
Stage2: Developing hardware circuit for downloading and burning code onto Flash memory.

Stage1: Build Toolchain for Microcontroller

  1. Download necessary packages for building our Toolchain.
    1. binutils-2.15.tar.bz2: Though you can download latest version, we download this for our experiment.
      Remember if you are downloading first time don't download patch.(Download Place:http://ftp.gnu.org/gnu/binutils)
      It holds source code for various tools like assembler, linker. Let's dwelve into some details to know what exactly this "binutil" is Bin+Utils binary files placed by collection of utilities.
      Components of binutils : (Selected component)
      1. as :-->"as" is the family of assemblers, it is use to assemble output of GNU C compiler gcc for use by linker ld.
      2. ld :--> "ld" is GNU linker combines a number of object and achieves files, relocates their data and ties up symbol reference.
      3. nm:-->"nm" lists symbol from object files.
      4. objdump:-->"objdump" displays information about one or more object files.
      5. size:-->"size" gives the total size of each of object file.
      6. ar:-->"ar" creates, modifies and extracts from achieves.
    2. gcc-core-3.4.2.tar.bz2: Before downloading this package check your gcc version (you can do this by easily, just type "gcc -v" on shell) and download according to it. (Download Place: http://ftp.gnu.org/gnu/gcc/gcc-3.4.2/)
      This package consists of GNU C compiler source.
    3. avr-libc-1.0.4.tar.bz2: It is C runtime library for AVR family of microcontrollers, for use with GNU other tools like binutils,GCC etc. (Download Area: http://savannah.nongnu.org/download/avr-libc/).
  2. After downloading ready to compile and install binutils.For this purpose either you can use a script file or use the following commands in their respective order as given below(They work properly for us they work...)

    Determine your current directory.(you can find it by typing "pwd").It is good if it is /usr/local/src,though it can be any directory, but i assume you extract all these above mentioned packages in /usr/local/src.
    So now you are in Linux shell, Go on typing these commands..

    root# mkdir /usr/local/avr  (Directory avr is created in /usr/local)
    root# cd binutils-2.15      (Hope this time you are in /usr/local )
    root#mkdir avrodj           (This time you are in /usr/local/binutils-2.15)
    root# cd avrobj
    root#../configure --target=avr --prefix=/usr/local/avr --disable -nls 
                                (Purpose of configure of is to generate files 
                                that controls compilation and installation process)
    root# make                 (This is utility in Linux that has inbuilt rules 
                               to do a task. One can say it builds the program)
    root# make install
    

    It has many options for which you refer (GCC-Complete Reference Tata McGraw Hill..), here we are touching only those options that are necessary here. Target option list what our target is .in this case it is "avr" prefix option is use to indicate root directory of gcc binary installation. --disable option is used to disable some option.

  3. After compiling and installing binutils, we need GCC which has capability of generating assembly code AVR so we have build and install same.
    Back on shell and type following commands:
    root#	export PATH=$PATH:/usr/local/avr/bin  
           (Purpose to set environment variable for 
           GCC binaries for setting path Atmel AVR)
    
    root# cd gcc-3.4.2
           (Whatever may be your gcc version)
    
    root# mkdir avrobj
    
    root# cd avrobj
    
    root# ../configure --target=avr --prefix=/usr/local/avr \
            --disable --nls --enable -language=c
    	(--enable -language compile only that language 
    	that is selected by this option)
    
    root# make 
    root# make install
    
  4. Now final step is to build our Avr C library
    
    root# cd avr-libc-1.0.4
    root# export PREFIX=/usr/local/avr
    root# sh ./doconf
    root# ./domake
    root# cd build
    root# make install
    

That's it finally we installed "Pure GNU" development environment for AVR microcontroller. Congratulations!!!!

Stage 2 and beyond

I will leave stage 2, hardware programming code onto Flash memory, to other articles on this site.

Enjoy !

--
Amit.

Level: Article
Additional Article Data
Level: Article

Comments
The comments are owned by the poster. We aren't responsible for their content.

Jump to section
News

All contents are Copyright (C) 2004-2005 Psychogenic Inc -- All rights reserved