Optiloader Mega2560 support

Inspired by your loader westfw, I believe I have managed to make one that will program the Mega2560. Here is a sample of it in action:

Atmega chip programmer.
Written by Nick Gammon.
Entered programming mode OK.
Signature = 1E 98 01 
Processor = ATmega2560
Flash memory size = 262144
LFuse = FF 
HFuse = D8 
EFuse = FD 
Lock byte = CF 
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 0x3E200
Committing page starting at 0x3E300
Committing page starting at 0x3E400
Committing page starting at 0x3E500
Committing page starting at 0x3E600
Committing page starting at 0x3E700
Committing page starting at 0x3E800
Committing page starting at 0x3E900
Committing page starting at 0x3EA00
Committing page starting at 0x3EB00
Committing page starting at 0x3EC00
Committing page starting at 0x3ED00
Committing page starting at 0x3EE00
Committing page starting at 0x3EF00
Committing page starting at 0x3F000
Committing page starting at 0x3F100
Committing page starting at 0x3F200
Committing page starting at 0x3F300
Committing page starting at 0x3F400
Committing page starting at 0x3F500
Committing page starting at 0x3F600
Committing page starting at 0x3F700
Committing page starting at 0x3F800
Committing page starting at 0x3F900
Committing page starting at 0x3FA00
Committing page starting at 0x3FB00
Committing page starting at 0x3FC00
Committing page starting at 0x3FD00
Committing page starting at 0x3FE00
Committing page starting at 0x3FF00
Written.
Verifying ...
No errors found.
Writing fuses ...
LFuse = FF 
HFuse = D8 
EFuse = FD 
Lock byte = CF 
Done.
Type 'C' when ready to continue with another chip ...

Time taken: 3 seconds.

This was running on a Uno, connected up like this:

The sketch fitted into memory fine:

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

It includes the Optiboot for the 168, 328 and 2560 in the one sketch.

It might need a bit of peer review before it gets released onto the world.

Source at:

http://gammon.com.au/Arduino/Atmega_Board_Programmer.zip