Installing the GNU tools (avr-gcc) for AVRs
February 15, 2006
I have been using PIC Microcontrollers for my robotics tinkering for a few years. I have also been primarily a Linux user for the last year or two, and have been able to rely on Linux for my work (Web Developer), my school (Computer Science), and all my personal work (robotics, programming, and other nerdy stuff of that nature). I resisted the Atmel AVR Microcontrollers for some time, despite their growing popularity within the hobby robotics community, due to the countless hours I had invested in PICs. However, after learning that the AVRs were designed with C and the GNU tools in mind--a toolset that I use regularly for schoolwork and personal programming projects--I had to give it a further look.
I read through the datasheet of the ATMega8 and the ATiny15L devices, and found that my knowledge with PICs would not be in vain and realized I would be able to learn AVRs quickly and be able to use my good ol' gcc and gdb to do so. Although I have worked with PICs in Linux, I found some things to be much more tedious than worthwhile (such as using PWM in gpsim as opposed to MPLab in Windows)-- not to mention that I never did get my programmer working in Linux. As nerdy as it is, I absolutely despise having to reboot into Windows to do anything. So, the AVRs seemed like a good choice.
This is the first of (hopefully) several articles on the topic of programming AVR microcontrollers in Linux using C. This particular article is more like "installation notes" than an article. It shows the commands to install the tools to write, compile and debug AVR programs. The next article will discuss using these tools. I am not including the tools to actually program the chip at this time, however, I will in a future article (I'll be using avrdude with the AvrUsb500 programmer).
Setup the Environment
Make a directory for the programs and add the 'bin' path for the AVR tools to your PATH environment variable:su mkdir /usr/local/avr< mkdir /usr/local/avr/bin PATH="$PATH:/usr/local/avr/bin" export PATH exitYou may additionally want to add that path to your /etc/profile file:
PATH="$PATH:/usr/local/avr/bin" export PATH
Binary Utilities
Download the most recent release of the Binary Utilities from http://ftp.gnu.org/gnu/binutils/ (binutils-2.16.tar.gz). Extract binutils archive:tar -xzf binutils-2.16.tar.gz cd binutils-2.16Configure and install binutils:
../configure --target=avr --prefix=/usr/local/avr --program-prefix="avr-" make su make install exit
GNU C Compiler
Download most recent release of the GNU C Compiler (gcc) from ftp://ftp.gnu.org/gnu/gcc/ (gcc-core-4.0.2.tar.bz2). Extract gcc-core archive:tar -xvf gcc-core-4.0.2.tar.bz2 cd gcc-4.0.2Configure and install gcc:
mkdir obj cd obj ../configure --target=avr --prefix=/usr/local/avr --enable-language=c --program-prefix="avr-" make su make install exitNOTES: In this step, configure was run from a directory ('obj') that does not reside in the same directory as the source files. This is required. If you do not do this, you will get the following error: configure: error: Building in the source directory is not supported in this release. See http://gcc.gnu.org/install/configure.html for more details. If you get the following error, then you did not correctly get /usr/local/avr into you PATH variable (step 1): make[2]: avr-ar: Command not found
AVR C Library
Download most recent release of the AVR C Library from http://download.savannah.gnu.org/releases/avr-libc/ (avr-libc-1.4.3.tar.bz2). Extract the avr-libc archive:tar -xvf avr-libc-1.4.3.tar.bz2 cd avr-libc-1.4.3Configure and install avr-libc:
./configure --build=`./config.guess` --host=avr --prefix=/usr/local/avr make su make install exit
GNU Debugger
Download the most recent release of the GNU Debugger from http://www.gnu.org/software/gdb/download/ (gdb-6.4.tar.gz). Extract the gdb archive:tar -xzf gdb-6.4 cd gdb-6.4Configure and install gdb:
./configure --prefix=/usr/local/avr --program-prefix="avr-" make su make install exit
Categories:
Linux, Robotics & Electronics
Copyright © 2004 - 2010 Micah Carrick. All Rights Reserved.
8 Comments about "Installing the GNU tools (avr-gcc) for AVRs"
RSS Feed
The only thing your tutorial does not mention is where to unzip the files to, if that matters?
My issue is that I already had a version install and was hoping this process would over write it. I just installed gcc 4.4.2, but when I type gcc -v is tells me it is still 4.3.2
I'm having some issues with the old version of avr-gcc, hence the upgrade
thang you.
a problem occurred when executing the command. make sure u are using the correct programming method. current mode is ISP
verify that the device is placed in the correct socket, and that the ISP cable is connected properly.check that the programming frequency specified in the main page is well below 1/4th of the clock frequency of the device.
i have tried all that i could think of, i have checked the connections and the freq is below 1/4th of the device. i am using the USB HID mode for the device.
but that doesn't solve this problem
i have made the circuit for blinking LEDs program
please help me out
see the image in my blog for details www.shubhangr.blogspot.com
thank you
Can you say me what kind of simulator are you using, for example I have usisng the Proteus(ISIS) in Windows OS, but there is something like proteus in Linux, thanks for your help.
If I had to guess... and this is just a guess... I would say that you somehow missed the "--target=avr" option when building gcc.
this is a good tutorial.
i have a problem that maybe you could help me.
i've instal; avr-gcc on my ubuntu gutsy (7.10), i installed it along with avrlib, and avr-libc,
the problem is, when i try to compile i program, it failed with an error that says : invalid bfd target..
i've post my question on another site, they said there is something wrong with the binutils-avr..
could u tell me a solution how to fix this problem?
Leave a Comment about "Installing the GNU tools (avr-gcc) for AVRs"