Cannot burn bootloader to Mega 2560

Hi,

I have a Arduino Mega 2560 where I need to burn a new bootloader, before I tried to burn a modified bootloader I wanted to see if I could burn the stock bootloader using the Arduino IDE.
I use an Olimex AVR-ISP500, and use the following programmer settings as per Arduino Bootloader with Olimex AVR-ISP500 | Ava High Altitude Balloon Project

avrisp.name=AVR ISP
avrisp.communication=serial
avrisp.protocol=stk500v2

After a long time of burning I receive the following error message:

avrdude: verification error, first mismatch at byte 0x1e000
         0xff != 0x0d
avrdude: verification error; content mismatch

Can anyone help me to figure out what is going wrong, and how I can fix it?

Edit:
I have just tried with a brand new out of the box Mega2560, resulting in the same error message.
The setup works just fine burning bootloaders to my Leonardo.

Check the protocol that the standard programmers use - I think it's something other than stk500v2.

alf_17:
After a long time of burning I receive the following error message:

avrdude: verification error, first mismatch at byte 0x1e000

0xff != 0x0d
avrdude: verification error; content mismatch

"long time",
If the programmer is running too slow that can cause verification errors. Your Olimex AVR-ISP500 default speed may be set too slow. The Arduino IDE does not have an option for changing programming speeds, but you can from command line with avrdude or from the avrdude.conf config file.

If you run avrdude from command line, try this:

avrdude -cstk500v2 -PCOM4 -pm2560 -v -B10

(change COM4 to what ever your serial device port is)
It's the option -B10 that will change the default programming speed. The programmer should save that in it's eeprom so that will become the new default programming speed. Which will allow it to work with the IDE.

CrossRoads:
Check the protocol that the standard programmers use - I think it's something other than stk500v2.

The AVRISP mkII programmer also uses the stk500v2. I have tried to change the stk500v2 to stk500v1, but then I can not burn to my leonardo, which I can do without problems with stk500v2.

hiduino:
"long time",
If the programmer is running too slow that can cause verification errors. Your Olimex AVR-ISP500 default speed may be set too slow. The Arduino IDE does not have an option for changing programming speeds, but you can from command line with avrdude or from the avrdude.conf config file.

If you run avrdude from command line, try this:

avrdude -cstk500v2 -PCOM4 -pm2560 -v -B10

(change COM4 to what ever your serial device port is)
It's the option -B10 that will change the default programming speed. The programmer should save that in it's eeprom so that will become the new default programming speed. Which will allow it to work with the IDE.

Burning a bootloader to a leonardo takes 2 minutes and completes without errors while burning to a Mega2560 returns the error after 12-13 minutes.
But thanks for the tips I will look into that.

hiduino:
If you run avrdude from command line, try this:

avrdude -cstk500v2 -PCOM4 -pm2560 -v -B10

(change COM4 to what ever your serial device port is)
It's the option -B10 that will change the default programming speed. The programmer should save that in it's eeprom so that will become the new default programming speed. Which will allow it to work with the IDE.

Now I have tried it, but with the same result as before.
I have also tried to upload the modified bootloader, resulting in the same verification error, but the bootloader has changed behaviour as per my changes.

alf_17:
Now I have tried it, but with the same result as before.
I have also tried to upload the modified bootloader, resulting in the same verification error, but the bootloader has changed behaviour as per my changes.

What was the output from the avrdude command? Did it actually complete or error out?
Your programmers clocking speed is still running too slow even for the Leonardo.

It would be more helpful if you post what you are seeing. You can also click on the IDE File->Preferences "show verbose output during upload"

hiduino:
What was the output from the avrdude command? Did it actually complete or error out?
Your programmers clocking speed is still running too slow even for the Leonardo.

It would be more helpful if you post what you are seeing. You can also click on the IDE File->Preferences "show verbose output during upload"

When running the avrdude command I get the following output:

C:\Users\alf_17>avrdude -cstk500v2 -PCOM18 -pm2560 -v -B10

avrdude: Version 5.10, compiled on Jan 19 2010 at 10:45:23
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"


         Using Port                    : COM18
         Using Programmer              : stk500v2
         Setting bit clk period        : 10.0
         AVR Part                      : ATMEGA2560
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page
      Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max
W   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---
-- ---------
           eeprom        65    10     8    0 no       4096    8      0  9000  90
00 0x00 0x00
           flash         65    10   256    0 yes    262144  256   1024  4500  45
00 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  90
00 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  90
00 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  90
00 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  90
00 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0
 0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0
 0 0x00 0x00

         Programmer Type : STK500V2
         Description     : Atmel STK500 Version 2.x firmware
         Programmer Model: STK500
         Hardware Version: 2
         Firmware Version Master : 2.10
         Topcard         : Unknown
         Vtarget         : 4.9 V
         SCK period      : 9.8 us
         Varef           : 4.9 V
         Oscillator      : 60.433 kHz

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude: Device signature = 0x1e9801
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D8
avrdude: safemode: efuse reads as FD

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D8
avrdude: safemode: efuse reads as FD
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

When enabling verbose during upload of the bootloader I get get no output (just a blank outputwindow), with verbose disabled I get the error as mentioned before:

avrdude: verification error, first mismatch at byte 0x1e000
         0xff != 0x0d
avrdude: verification error; content mismatch

The output from avrdude on command line looks good. It tells me that your programmer is communicating correctly to the m2560 mcu.

As for the IDE, the burn bootloader process will not display anything in the IDE until it finishes completely or fail. So you may need to wait longer for the output to show up. Can you try again and post the output. Hopefully it will point to some possible issue.

It may be that the programmer is not saving the default clocking rate. Can you also try the same avrdude command line but without the -B10 option and see if it will use a different programming clock rate. In particular if it is still using this "SCK period : 9.8 us" on the output.

hiduino:
It may be that the programmer is not saving the default clocking rate. Can you also try the same avrdude command line but without the -B10 option and see if it will use a different programming clock rate. In particular if it is still using this "SCK period : 9.8 us" on the output.

Sorry for the much to late reply, but I have been a bit occupied the last couple of months, but now I am back on getting the problem solved.
I tried out running the command without the -B10 option, and the output looks more or less the same except for the "Setting bit clk period : 10.0" part.

C:\Users\alf_17>avrdude -cstk500v2 -PCOM18 -pm2560 -v

avrdude: Version 5.10, compiled on Jan 19 2010 at 10:45:23
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"


         Using Port                    : COM18
         Using Programmer              : stk500v2
         AVR Part                      : ATMEGA2560
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page
      Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max
W   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---
-- ---------
           eeprom        65    10     8    0 no       4096    8      0  9000  90
00 0x00 0x00
           flash         65    10   256    0 yes    262144  256   1024  4500  45
00 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  90
00 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  90
00 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  90
00 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  90
00 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0
 0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0
 0 0x00 0x00

         Programmer Type : STK500V2
         Description     : Atmel STK500 Version 2.x firmware
         Programmer Model: STK500
         Hardware Version: 2
         Firmware Version Master : 2.10
         Topcard         : Unknown
         Vtarget         : 5.0 V
         SCK period      : 9.8 us
         Varef           : 5.0 V
         Oscillator      : 60.433 kHz

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.04s

avrdude: Device signature = 0x1e9801
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D8
avrdude: safemode: efuse reads as FD

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D8
avrdude: safemode: efuse reads as FD
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

Bump?

The "failure to verify" is something that can be caused by the programmer firmware not properly supporting more than 64k of flash. I've usually seen this on STK500v1 programmers, where the protocol itself doesn't support more than 64k (words), but it's pretty easy to imagine a firmware bug in a stk500v2 programmer that would cause similar behavior. You might check to see if there is a firmware update for your programmer.

westfw:
The “failure to verify” is something that can be caused by the programmer firmware not properly supporting more than 64k of flash. I’ve usually seen this on STK500v1 programmers, where the protocol itself doesn’t support more than 64k (words), but it’s pretty easy to imagine a firmware bug in a stk500v2 programmer that would cause similar behavior. You might check to see if there is a firmware update for your programmer.

Well I have now tried to update the firmware on the programmer to the latest version, but I still get the same “failure to verify”.

Another thing you can try is Nick Gammon's bootloader.

Or, get an Atmel AVR ISP MKii programmer.
http://www.mouser.com/ProductDetail/Atmel/ATAVRISP2/?qs=%2Fha2pyFadujqFzV%2bExzQOlFEGuFbE5zkYm9OzGvRqkjeoy23MLFzjw%3D%3D

CrossRoads:
Another thing you can try is Nick Gammon's bootloader.
Gammon Forum : Electronics : Microprocessors : Atmega bootloader programmer

This is for using another arduino for burning, which was what I was trying to avoid by using an Olimex AVR-ISP500 for the sake of simplicity in the setup.

CrossRoads:
Or, get an Atmel AVR ISP MKii programmer.
http://www.mouser.com/ProductDetail/Atmel/ATAVRISP2/?qs=%2Fha2pyFadujqFzV%2bExzQOlFEGuFbE5zkYm9OzGvRqkjeoy23MLFzjw%3D%3D

I have already thought of buying one of those, but I would prefer to get it working with my Olimex AVR-ISP500.

Got a link to the olimex programmer?

CrossRoads:
Got a link to the olimex programmer?

This is the one:AVR-ISP500