Arduino Bootloader

Bootloader Installation

Atmega168 w. internal clock (8MHz)

In order to use the ATmega168/328 with the Arduino SDK using the internal 8 MHz resonator, you have to equip it with a bootloader. In this case we can use the Arduino Lilypad bootloader because this board comes very close to a minimal Atmega168/328 board. The bootloader can be found in the Arduino directory:

arduino-1.0.2/hardware/arduino/bootloaders/lilypad

Flash the bootloader to the chip using AVRDude:

avrdude -p m168 -P /dev/ttyS0 -U flash:w:LilyPadBOOT_168.hex

After that, set the correct fusebits:

avrdude -p m168 -P /dev/ttyS0 -U lfuse:w:0x82:m -U hfuse:w:0xDD:m -U efuse:w:0x00:m

Try everything out:

avrdude -p m168 -P /dev/ttyS0 -nvF

And you should get:

avrdude: safemode: lfuse reads as 82
avrdude: safemode: hfuse reads as DD
avrdude: safemode: efuse reads as 0

Now start the Arduino IDE. Select 'Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega168' or 'LilyPad Arduino w/ ATmega168
'as your board and the matching '/dev/tty***' port as port.

Atmega168P w. external clock (16MHz)

In this case, we use the bootloader 'ATmegaBOOT_168_diecimila.hex' found at

arduino-1.0.2/hardware/arduino/bootloaders/atmega

Flash the bootloader to the chip using AVRDude:
(NOTE: Avrdude may not know this device. In that case, refer to Arduino_Bootloader)

avrdude -p m168 -P /dev/ttyS0 -U flash:w:ATmegaBOOT_168_diecimila.hex

After that, set the correct fusebits:

avrdude -p m168 -P /dev/ttyS0 -U lfuse:w:0xE0:m -U hfuse:w:0xDD:m -U efuse:w:0xFB:m

Avrdude may throw an error like:

avrdude: safemode: efuse changed! Was fb, and is now 3
Would you like this fuse to be changed back? [y/n]

In that case, just press ENTER.

Try everything out:

avrdude -p m168 -P /dev/ttyS0 -nv

And you should get:

avrdude: safemode: lfuse reads as E0
avrdude: safemode: hfuse reads as DD
avrdude: safemode: efuse reads as 3

Now start the Arduino IDE. Select 'Arduino Duemilanove w/ ATmega168' as your board and the matching '/dev/tty***' port as port.

Atmega328P w. external clock (16MHz)

In this case, we use the bootloader 'ATmegaBOOT_168_atmega328.hex' found at

arduino-1.0.2/hardware/arduino/bootloaders/atmega

Flash the bootloader to the chip using AVRDude:
(NOTE: Avrdude may not know this device. In that case, refer to Arduino_Bootloader)

avrdude -p m328p -P /dev/ttyS0 -U flash:w:ATmegaBOOT_168_atmega328.hex

After that, set the correct fusebits:

avrdude -p m328p -P /dev/ttyS0 -U lfuse:w:0xE0:m -U hfuse:w:0xDA:m -U efuse:w:0xFD:m

Avrdude may throw an error like:

avrdude: safemode: efuse changed! Was fd, and is now 5
Would you like this fuse to be changed back? [y/n]

In that case, just press ENTER.

Try everything out:

avrdude -p m328p -P /dev/ttyS0 -nv

And you should get:

avrdude: safemode: lfuse reads as E0
avrdude: safemode: hfuse reads as DA
avrdude: safemode: efuse reads as 5

Now start the Arduino IDE. Select 'Arduino Duemilanove w/ ATmega328' as your board and the matching '/dev/tty***' port as port.

Atmega328p w. internal clock (8MHz)

In this case, we use the bootloader 'ATmegaBOOT_168_atmega328_pro_8MHz.hex' found at

IMPORTANT:
This bootloader does not use the CTS-Pin as a reset line but the DTR-Line! Incorrect reset line wiring will cause the bootloader to work only once.

arduino-1.0.2/hardware/arduino/bootloaders/atmega

Flash the bootloader to the chip using AVRDude:

avrdude -p m328p -P /dev/ttyS0 -U flash:w:ATmegaBOOT_168_atmega328_pro_8MHz.hex

After that, set the correct fusebits:

avrdude -p m328p -P /dev/ttyS0 -U lfuse:w:0xE2:m -U hfuse:w:0xDA:m -U efuse:w:0xFD:m

Avrdude may throw an error like:

avrdude: safemode: efuse changed! Was fd, and is now 5
Would you like this fuse to be changed back? [y/n]

In that case, just press ENTER.

Try everything out:

avrdude -p m328p -P /dev/ttyS0 -nv

And you should get:

avrdude: safemode: lfuse reads as E2
avrdude: safemode: hfuse reads as DA
avrdude: safemode: efuse reads as 5

Now start the Arduino IDE. Select 'Arduino Pro or Pro Mini (3.3V, 8MHz) w/ Atmega328' as your board and the matching '/dev/tty***' port as port.

Adding Atmega328P to Avrdude

Open your '.avrduderc'.

Add this to the defines in the beginning of the file:

#define ATMEGA328P 0x86

At the part definitions, add the definition that can be found at

http://www.pololu.com/docs/0j31/all#5

You can also use the already modified '.avrduderc' from the repository at '/Etc/'