This serves as a reference guide for installing the AVR toolchain on Red Hat 9 and is part of the development process for AVR Microcontrollers. I hope you find this handy. --Thomas Ng
Hardware Requirements:
Computer with RedHat 9 or Fedora Core 4/5 installed on it and 'root' access to the system.
Software Downloads:
GNU Binutils - (version 2.16.1) - http://sources.redhat.com/binutils/
GCC - (version 3.4.6, older stable version) - http://gcc.gnu.org/
AVR Libc - (version 1.4.4) - http://savannah.nongnu.org/projects/avr-libc/
UISP - Programmer (20050207) - http://savannah.nongnu.org/projects/uisp/
NOTE: Always install the latest software packages to ensure you have the latest bug fixes (unless otherwise noted)
Installation Steps
Setup your path and environment variables
$PATH
variable to include "/usr/local/avr
" and "/usr/local/avr/bin
." You will be installing the AVR toolchain to this directory, so if it doesn't already exist, make a folder called avr
in /usr/local/
Install GNU Binutils:
# bunzip2 -c binutils-2.16.1.tar.bz2 | tar xf -
# cd binutils-2.16.1
obj-avr
and CD into it. This is a good idea and helps you keep your source tree clean.# ../configure --target=avr \
--prefix= /usr/local/avr \
--disable-nls
# make && make install
Install GCC:
#bunzip2 -c gcc- core-3.4.6.tar.bz2 | tar xf -
# mkdir obj-avr
# cd obj-avr
# ../configure --prefix=/usr/local/avr \
--target=avr \
--enable-languages=c \
--disable-nls \
--with-dwarf2
# make && make install
Install AVR libc:
# gunzip -c avr-libc-1.4.4.tar.gz | tar xf -
# cd avr-libc-1.4.4
# ./configure --build=`./config.guess` \
--host=avr \
--prefix=/usr/local/avr
# make && make install
configure
script to make it install the AVR C libraries in the correct place. Here is the diff output incase you need to make the same change:#diff configure configure.orig
257c257
< ac_default_prefix=/usr/local
---
> ac_default_prefix=/usr/local/avr
Install UISP (programmer):
# gunzip -c uisp-20050207.tar.gz | tar xf -
# cd uisp-20050207
# mkdir obj-avr
# cd obj-avr
# ../configure --prefix=/usr/local/avr
# make && make install
Makefiles
PRG = demo # Change "demo" above to the name of your project with NO extension.
# You should not have to change anything below here, but go ahead and
# try to understand what is going on.OBJ = $(PRG).o
MCU_TARGET = atmega128
OPTIMIZE = -O2 # options are 1, 2, 3, sDEFS =
LIBS =CC = avr-gcc
# Override is only needed by avr-lib build system.
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
override LDFLAGS = -Wl,-Map,$(PRG).mapOBJCOPY = avr-objcopy
OBJDUMP = avr-objdumpall: $(PRG).elf lst text eeprom
$(PRG).elf: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)clean:
rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak
rm -rf *.lst *.map $(EXTRA_CLEAN_FILES) *~program: $(PRG).hex
uisp -dprog=stk200 -dpart=atmega128 -dlpt=/dev/parport0 --erase --upload if=$(PRG).hex
lst: $(PRG).lst%.lst: %.elf
$(OBJDUMP) -h -S $< > $@# Rules for building the .text rom images
text: hex bin srec
hex: $(PRG).hex
bin: $(PRG).bin
srec: $(PRG).srec%.hex: %.elf
$(OBJCOPY) -j .text -j .data -O ihex $< $@%.srec: %.elf
$(OBJCOPY) -j .text -j .data -O srec $< $@%.bin: %.elf
$(OBJCOPY) -j .text -j .data -O binary $< $@# Rules for building the .eeprom rom images
eeprom: ehex ebin esrec
ehex: $(PRG)_eeprom.hex
ebin: $(PRG)_eeprom.bin
esrec: $(PRG)_eeprom.srec%_eeprom.hex: %.elf
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@%_eeprom.srec: %.elf
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@%_eeprom.bin: %.elf
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@# Every thing below here is used by avr-libc's build system and can be ignored
# by the casual user.FIG2DEV = fig2dev
EXTRA_CLEAN_FILES = *.hex *.bin *.srecdox: eps png pdf
eps: $(PRG).eps
png: $(PRG).png
pdf: $(PRG).pdf%.eps: %.fig
$(FIG2DEV) -L eps $< $@%.pdf: %.fig
$(FIG2DEV) -L pdf $< $@%.png: %.fig
$(FIG2DEV) -L png $< $@