Arduino‎ > ‎

Arduino Tips

Burning the Bootloader

I can't remember the exact fuse bits and avrdude command lines, so here it is (presumably you need to change the programmer and serial device name). This is for the classic Arduino Diecimilia with a ATmega168:

With avrdude:
avrdude -c avrisp2 -p m168 -P usb -U lock:w:0x3f:m -U lfuse:w:0xff:m -U hfuse:w:0xdd:m -U efuse:w:0x00:m
avrdude -c avrisp2 -p m168 -P usb -U flash:w:ATmegaBOOT_168_diecimila.hex
avrdude -c avrisp2 -p m168 -P usb -U lock:w:0x0f:m
Reading the fuse bits:
avrdude -c avrisp2 -p m168 -P usb -U lock:r:-:h -U lfuse:r:-:h -U hfuse:r:-:h -U efuse:r:-:h
Some fuse bits:

 Environment Low High Extended Lock  Remarks
 ATmega 168 16 MHz Arduino FF DD 00 0F Brown-out 2.7V, Boot-Section 1024 Bytes/Reset/protected
 ATmega 168 16 MHz FF DF     00 3F Brown-out disabled, Boot-Section not protected
 ATmega 328P 16 MHz Arduino FF DA 05 0F Brown-out 2.7V, Boot-Section 1024 Bytes/Reset/protected
 ATmega 328P 16 MHz FF DA 05 3F Boot-Section not protected
 ATmega 644 16 MHz Sanguino FF DC 05  0F Brown-out 2.7V, Boot-Section 1024 Bytes/Reset/protected
 ATmega 644 16 MHz FF DC 05 3F Boot-Section not protected

Engbedded has a good fuse calculator


DTR Reset

In some cases (e.g. when using avrude directly from whithin the Eclipse-IDE) the reset line is not triggered, because the DTR line is not pulsed. When this happens, you can't use the Arduinos auto-reset feature (it only works exactly one time).
 
After reading this article http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1201441300, i moved arduino/hardware/tools/avrdude to avrdude.org, wrote this Perl-script and stored it under the name avrdude (don't forget to make it executable). This script triggers the DTR line and then executes avrdude.org with the supplied parameters. Now auto-reset should always work. The script determines the serial port from the -P avrdude parameter.
#!/usr/bin/perl -w
use Device::SerialPort;
use FindBin qw($Bin);
foreach (@ARGV)
{
    if ($_ =~ /-P(\/dev\/.+USB.+)/)
    {
        print (STDERR "Resetting DTR on " . $1 . "\n");
        Device::SerialPort->new($1)->pulse_dtr_on(100);
        last;
    }
}
select(undef, undef, undef, 0.1);
print (STDERR "Executing avrdude\n");
system($Bin . "/avrdude.org " . join(" ", @ARGV));