Building Arduino Atmega8u2 firmware on Linux
I've had a few questions about how to build the HID firmware for the atmega8u2 under linux. Here's a guide for getting the avr tools installed to be able to build the firmware. I've tested this on Ubuntu 10.04.
Build and install binutils for the AVR
- wget ftp://sourceware.org/pub/binutils/releases/binutils-2.21.tar.bz2
- tar xjf binutils-2.21.tar.bz2
- cd binutils-2.21
- mkdir build
- cd build
- ../configure --target=avr
- make
- sudo make install
- cd ../..
Build and install libgmp (needed for gcc-4.5.3)
- wget ftp://ftp.gmplib.org/pub/gmp-5.0.2/gmp-5.0.2.tar.bz2
- tar xjf gmp-5.0.2.tar.bz2
- sudo apt-get install m4
- cd gmp-5.0.2
- ./configure
- make
- sudo make install
- cd ..
Install libmpfr and libmpc (needed for gcc-4.5.3)
- sudo apt-get install libmpfr-dev
- sudo apt-get install libmpc-dev
Build and install gcc-4.5.3 for AVR
- wget ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-4.5.3/gcc-4.5.3.tar.bz2
- tar xjf gcc-4.5.3.tar.bz2
- cd gcc-4.5.3
- mkdir build
- cd build
- CFLAGS="-g -O2" ../configure --target=avr --with-gcc --with-gnu-as --enable-languages=c,c++ --disable-nls --disable-libssp --with-dwarf2
- make
- sudo make install
- cd ../..
Build and install avr-libc
- wget http://download.savannah.gnu.org/releases/avr-libc/avr-libc-1.7.1.tar.bz2
- tar xjf avr-libc-1.7.1.tar.bz2
- cd avr-libc-1.7.1
- mkdir build
- cd build
- CFLAGS=-Os ../configure --build=`../config.guess` --host=avr
- make
- sudo make install
Do a test build of Arduino-usbserial
The Arduino-usbserial firmware is the default firmware that the UNO comes installed with on its atmega8u2. It implements a serial interface over USB. Build this firmware to check that your avr-gcc toolchain and avr-libc are working.
- cd Arduino/hardware/arduino/firmwares/arduino-usbserial
- edit the makefile and make sure that MCU = atmega8u2 and ARDUINO_PID = 0x0001
- make
- You should have an newly built Arduino-usbserial.hex file.
















I purchased a USB Host shield from 












