Sketch to upload a bootloader using a Uno

Following on from the ideas in the Optiloader sketch, I made my own version which will handle the Mega2560. This is because it programs a byte at a time, rather than trying to read the entire bootloader into RAM (where it would not fit).

Details, wiring and photos here:

Example of programming a Mega:

Sketch output:

Atmega chip programmer.
Written by Nick Gammon.
Entered programming mode OK.
Signature = 0x1E 0x98 0x01 
Processor = ATmega2560
Flash memory size = 262144 bytes.
LFuse = 0xFF 
HFuse = 0xD8 
EFuse = 0xFD 
Lock byte = 0xCF 
Bootloader address = 0x3E000
Bootloader length = 8192 bytes.
Type 'G' to program the chip with the bootloader ...
Erasing chip ...
Writing bootloader ...
Committing page starting at 0x3E000
Committing page starting at 0x3E100
...
Committing page starting at 0x3FE00
Committing page starting at 0x3FF00
Written.
Verifying ...
No errors found.
Writing fuses ...
LFuse = 0xFF 
HFuse = 0xD8 
EFuse = 0xFD 
Lock byte = 0xCF 
Done.
Type 'C' when ready to continue with another chip ...

Time to program: 3 seconds (one second to program a Uno).

There are instructions on my web site for how to process other .hex files so you can install bootloaders for other chips. At present it handles the ATmega168PA, ATmega328P and ATmega2560.

The sketch size is:

Binary sketch size: 17082 bytes (of a 32256 byte maximum)

Since the Optiboot loaders only take 512 bytes, there is room for a few more of them in the sketch for different processor types.

Wow!
Nice work Nick!

Very Impressive.

Just to let everyone know, I built up a ATMegaxx target board from Evil Mad Scientist as on Nick's website.
I converted the ATMegaFuseCalculator to compile on 00022.
I can now read Fuses and the same hardware setup allows me to Burn Bootloaders using WestFW's OptiLoader.

Thanks for the feedback.

I've modified the bootloader-uploader sketch to do the Atmega1284 now.

Nick: Thanks, perfect timing since I am going to start building some of Crossroads 1284 boards.

Good to hear. My research into the 1284 processor here:

(half-way down)