Arduino among others has a really nice feature… The bootloader. Once you burn it on the chip you can upload your code without the need of an external programmer.
I have started using it for my AVR projects but i came across on some issues so i compiled a COMPLETE list of what you need to do it, in order not to search again for the obvious…
Programmer used AVR910 (or compatible) with avrdude. In the avrdude commands I assume that the
programmer is AVR910, COM port=COM3 and baud rate=115200. Adjust to your programmer.
Have in mind that you might use also -x devcode=0x35 for AVR910
ATMEGA8
The default fuses of ATMega8 are (pdf and locally tested):
High Fuse: 0xd9
Low Fuse: 0xe1
Lock: 0x3f
Programming the bootloader. Chip erase (-e maybe needed in some cases)
- Unlock the bootloader (TEST: try with -e)
avrdude -c avr910 -P com3 -b 115200 -p atmega8 -U lock:w:0xff:m
(fails with avrdude: verification error, first mismatch at byte 0x0000 0xff != 0x3f)
- Program the fuses
avrdude -c avr910 -P com3 -b 115200 -p atmega8 -U hfuse:w:0xca:m -U lfuse:w:0xdf:m
- Burn the bootloader (TEST: try with -D disable auto erase)
avrdude -c avr910 -P com3 -b 115200 -p atmega8 -U flash:w:ATmegaBOOT.hex
- Lock the bootloader
avrdude -c avr910 -P com3 -b 115200 -p atmega8 -U lock:w:0xcf:m
(fails with avrdude: verification error, first mismatch at byte 0x0000 0xcf != 0x0f)
But it works….
ATMEGA168
The default fuses of ATMega168 are (pdf and locally tested):
High Fuse: 0xd9
Low Fuse: 0xe1
Lock: 0x3f
Programming the bootloader. Chip erase (-e maybe needed in some cases)
- Unlock the bootloader
avrdude -c avr910 -P com3 -b 115200 -p atmega168 -U lock:w:0x3f:m
- Program the fuses
avrdude -c avr910 -P com3 -b 115200 -p atmega168 -U hfuse:w:0xdd:m -U lfuse:w:0xff:m -U efuse:w:0x00:m
- Burn the bootloader
avrdude -c avr910 -P com3 -b 115200 -p atmega168 -U flash:w:ATmegaBOOT_168_ng.hex
- Lock the bootloader
avrdude -c avr910 -P com3 -b 115200 -p atmega168 -U lock:w:0x0f:m
And now the good part:
Once you burn the bootloader to a chip you can use this excellent program to upload any hex file to your ATmega with Arduino uploader
References
- http://www.arduino.cc/en/Tutorial/Bootloader
- http://arduino.cc/en/Hacking/Bootloader
- http://arduino.cc/en/Hacking/Bootloader?from=Main.Bootloader
- (settings based on http://arduino.cc/en/Hacking/Bootloader?from=Main.Bootloader 09/01/2009)
Updated: July 2013
Notes:
FUSEBITS: internal 1MHz clock, EESAVE enabled:
M8 L:0xE1 H:0xD1
M88,M168 L:0x62 H:0xD7 E:0xF9
M328 L:0x62 H:0xD1 E:0xFF
Leave a Reply