I'm using Nick Gammon's excellent Atmega bootloader programmer to restore a gone-bad Mega 2560.
Runs perfectly per the instructions here
http://www.gammon.com.au/forum/?id=11635 and gives all the expected readouts ("Example output for Mega2560"), but despite reporting success I'm still unable to upload to the Mega. Readout here:
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 = 0xEF
Clock calibration = 0x9F
Bootloader address = 0x3E000
Bootloader length = 7434 bytes.
Type 'V' to verify, or '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
Written.
Verifying ...
No errors found.
Writing fuses ...
LFuse = 0xFF
HFuse = 0xD8
EFuse = 0xFD
Lock byte = 0xEF
Clock calibration = 0x9F
Done.
Type 'C' when ready to continue with another chip ...
The only clue is that the lock byte is reported as 0xEF (both at the start and at the end of the readout), which differs from the 0xCF on Nick's webpage, and differs again from the 0x2F in the signatures structure of the code. However, if I've read the datasheet correctly (table 28-3), BLB1 mode 2 ("SPM is not allowed to write to the Boot Loader section") is set with either 0x2F or 0xEF.
Does the opening 0xEF mean I can't write the bootloader and, if so, any ideas for how I get out of this?