Thanks CrossRoads
I have great progress / success, but not certain that it is correct, and don't know how to check it.
Did a search on the verification error that I was seeing after upload and verification of the bootloader :
avrdude: verification error, first mismatch at byte 0x1e000
0xff != 0x0d
and found this page :
http://arduino.cc/forum/index.php?topic=126667.0In the third post ( reply # 2 ) Andre_1949 mentions using different fuses.
Changed my avrdude batch file to use the fuses mentioned in the above linked post, to:
cd\
cd\ArduinoBuilder\code\Blink
avrdude -v -p atmega2560 -c usbasp -U lfuse:w:0xc2:m -U hfuse:w:0x99:m -U efuse:w:0xff:m -U lock:w:0x3f:m -U flash:w:Blink.hex
and it uploads and works - LED flashes as expected.
I think that avrdude, as used by the Arduino IDE for 'Upload using Programmer', first reads the fuses, erases the chip, writes the hex file, and then writes the fuses back again. So if the fuses were incorrect before the upload, they will still be incorrect after the upload.
I think that I have confirmed this as follows :
This does not affect an upload of the Bootloader hex file using avrdude from the command line, as the fuses are contained in the hex file.
Any other command line upload fails because I was writing the wrong fuse values, as in :
avrdude -v -p atmega2560 -c USBasp -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xFD:m -U lock:w:0x0F:m -U flash:w:Blink.hex
Arduino IDE upload over USB was fine, because it utilised the bootloader and does not affect the fuses ( fuses that were in the bootloader hex file ).
Arduino IDE 'Upload using Programmer' fails, because the wrong fuses are being read from, and re-written to the board.
Also, after uploading from command line ( and changing the fuses, I can now upload from IDE 'using Programmer' and that also now works ( because it is now reading valid fuses, and re-writing those same valid fuses back at the end of the process ).
So the question now stands : am I using the correct fuse settings for the Mega 2560 R3 board ?