ATmega2560 custom board problem

Hi

On my latest board based on the ATmega2560 I've been struggling with getting software running on it, the Arduino bootloader won't upload without giving a mismatch and sketches directly programmed through a USBasp interface won't run at all.

When burning the bootloader it gives this error:

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

I have read through a bunch of thread about this verification error but most of the talks about "Arduino as ISP" and this is purely about uploading the bootloader to the MCU with a USBasp interface. I have another board based on the ATmega644PA which works with the same basic circuitry (see attachment) and it runs fine, both accepts and runs the bootloader and sketches when they are directly uploaded via the USBasp.

Is there any big difference between these MCUs and how they work that I have missed out on?

And why won't it run the simple "Blink" sketches I've uploaded, neither the standard "Blink" nor the one I wrote that flashes all digital pins shows anything on the MCU pins. I can read and verify the code written to the flash memory through eXtreme Burner - AVR which proves it has been written in the flash correctly.

What can be wrong? I'm leaning towards circuit fault or fuses set in a wrong way; but the circuitry have been used on another board with no problems so I don't really have a clue. And that board also runs the MCU with the default fuses set.

What can stop the MCU from running? Any fuses that needs to be set thats not set by default?

A funny thing is that after the bootloader fails writing to memory (takes about 5min before the IDE gives the error) the TXD0 line goes high...which proves somethings been programmed in and runs...nothing I've been able to mimic with my own code... :slight_smile:

Would appreciate as much help as I can get :slight_smile:

Cheers!

Correction: The capacitors at the crystal are 22pF on both the none working ATmega2560 and the working ATmega644PA one, not 27pF.

Do you know what fuse settings you last sent to the MCU?

spcomputing:
Do you know what fuse settings you last sent to the MCU?

Yes, the Fuses were all set to the Arduino standard for ATMega2560:

low fuses = 0xFF
high fuses = 0xD8
extended fuses = 0xFD

They were read via "eXtreme Bruner - AVR" in an attempt from my side to confirm that they were written at all.

What kind of fuses could stop the MCU from running you think?

Cheers

Do you have any decoupling capacitors in your circuit (It's not on your schematics)? If not then it may not be running stable causing these types of errors.

hiduino:
Do you have any decoupling capacitors in your circuit (It's not on your schematics)? If not then it may not be running stable causing these types of errors.

Yes sorry just a mistake that I forgot to put it in the schematics I uploaded here. I have one 100nF close to the MCU between it and the ISP connector.

Cheers

You may need more than just one, at least three or four. They should be close to the 2560 chip as possible between the Vcc and GND pins.

hiduino:
You may need more than just one, at least three or four. They should be close to the 2560 chip as possible between the Vcc and GND pins.

I have prepared the PCB for all 4 so I'll populate them tonight and see if there is an improvement.

Thanks a lot, I'll get back with the results from running with all 4 decoupler caps.

Hi, have been trying with 4 decoupling caps now and no difference. The full verbose from the upload can be seen below.

C:\Program Files (x86)\arduino-1.0.4\hardware/tools/avr/bin/avrdude -CC:\Program Files (x86)\arduino-1.0.4\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega2560 -cusbasp -Pusb -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xD8:m -Ulfuse:w:0xFF:m 

avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\arduino-1.0.4\hardware/tools/avr/etc/avrdude.conf"

         Using Port                    : usb
         Using Programmer              : usbasp
avrdude: seen device from vendor ->www.fischl.de<-
avrdude: seen product ->USBasp<-
         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  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : usbasp
         Description     : USBasp, http://www.fischl.de/usbasp/

avrdude: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9801
avrdude: erasing chip
avrdude: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file "0x3F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3F:
avrdude: load data lock data from input file 0x3F:
avrdude: input file 0x3F contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude: reading input file "0xFD"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xFD:
avrdude: load data efuse data from input file 0xFD:
avrdude: input file 0xFD contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading input file "0xD8"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xD8:
avrdude: load data hfuse data from input file 0xD8:
avrdude: input file 0xD8 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xFF"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xFF:
avrdude: load data lfuse data from input file 0xFF:
avrdude: input file 0xFF contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified

avrdude done.  Thank you.

Continue verbose...

C:\Program Files (x86)\arduino-1.0.4\hardware/tools/avr/bin/avrdude -CC:\Program Files (x86)\arduino-1.0.4\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega2560 -cusbasp -Pusb -Uflash:w:C:\Program Files (x86)\arduino-1.0.4\hardware\arduino\bootloaders\stk500v2\stk500boot_v2_mega2560.hex:i -Ulock:w:0x0F:m 

avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\arduino-1.0.4\hardware/tools/avr/etc/avrdude.conf"

         Using Port                    : usb
         Using Programmer              : usbasp
avrdude: seen device from vendor ->www.fischl.de<-
avrdude: seen product ->USBasp<-
         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  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : usbasp
         Description     : USBasp, http://www.fischl.de/usbasp/

avrdude: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9801
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file "C:\Program Files (x86)\arduino-1.0.4\hardware\arduino\bootloaders\stk500v2\stk500boot_v2_mega2560.hex"
avrdude: writing flash (261406 bytes):

Writing | ################################################## | 100% 142.63s

avrdude: 261406 bytes of flash written
avrdude: verifying flash memory against C:\Program Files (x86)\arduino-1.0.4\hardware\arduino\bootloaders\stk500v2\stk500boot_v2_mega2560.hex:
avrdude: load data flash data from input file C:\Program Files (x86)\arduino-1.0.4\hardware\arduino\bootloaders\stk500v2\stk500boot_v2_mega2560.hex:
avrdude: input file C:\Program Files (x86)\arduino-1.0.4\hardware\arduino\bootloaders\stk500v2\stk500boot_v2_mega2560.hex contains 261406 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 137.52s

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

avrdude done.  Thank you.

Symtomps are as before, code seems to not run if the sketch is uploaded through the programmer anyway. I now have a working board again (after some fuse issues..) so give me all your suggestions. What is the best way to confirm that code is even executing?

Cheers

Hi.
Your problem seems like one I recently had too:

http://arduino.cc/forum/index.php/topic,156818.0.html

I tested the same USBasp programmer LCsoft Studio on my Arduino Mega2560 and sure enough it also fail verification. It appears the firmware on your USBasp programmer doesn't properly support the larger memory space on the 2560.

I did have another LCsoft Studio programmer that I upgrade to the 2011-05-28 firmware and it was successful on the verification test. So this works! An added benefit is that it also programs almost twice as fast.

hiduino:
I tested the same USBasp programmer LCsoft Studio on my Arduino Mega2560 and sure enough it also fail verification. It appears the firmware on your USBasp programmer doesn't properly support the larger memory space on the 2560.

I did have another LCsoft Studio programmer that I upgrade to the 2011-05-28 firmware and it was successful on the verification test. So this works! An added benefit is that it also programs almost twice as fast.

Sound great, is the programmer that worked an identical USBasp programmer? Should I configure one of my arduino boards to update my USBasp programmer immediately or do I have to buy another model of programmer?

Could you run the sketches or bootloader with the first one who fail the verification? I have tried to upload through another software, a small firmware i wrote in AVRStudio and it gives a verification error even though the code is less than 20 rows, it seems to fail verification even though I doesn't use a lot of memory?

Cheers

andyb:
Hi.
Your problem seems like one I recently had too:

http://arduino.cc/forum/index.php/topic,156818.0.html

Thanks for your feedback, did your firmwares run on the platform even though you got the verification fail error?

Cheers

Yes, actually, I was able to upload sketches even though it failed the bootloader verification.

To update the programmer's firmware you do need another programmer. However, you can use ArduinoISP as the programmer. So if you have a spare Uno just load the ArduinoISP sketch to it. You just need to connect up the Uno pins to the corresponding pins on the USBasp 10-pin header. Note you don't need the 10uF capacitor that some documentation says is needed to disable the auto-reset.

10-Pin header  to  Uno ArduinoISP
pin 5 RESET         D10
pin 1 MOSI          D11
pin 9 MISO          D12
pin 7 SCK           D13
pin 2 VCC           5V
pin 4 GND           GND

Then you will need to jumper J2 on your USBasp programmer. This will connect the programmers ATmega8A reset to the 10-pin header reset. I soldered a 2-pin header to mine, so I could jumper it easily.

I programmed it from avrdude on command line. Change the COM port to your Uno.

avrdude -c arduino -PCOM6 -b19200 -p atmega8 -v -U flash:w:usbasp.atmega8.2011-05-28.hex

Note you don't need to change the fuse bits.

Once you have programmed it don't forget to remove the J2 jumper for normal operation.

ICSP-10Pin.JPG

USBasp-Lcsoft2.jpg

Hi, so far I've tried the command line you wrote above which made it complain that it couldn't find the "wide configuration file".
If I gave it the path to the one in arduino (I only have AVRdude through Arduino) it stood for a few second and than gave me the error "stk500_getsync(): not in sync: resp=0x00". What am I doing wrong here?

Thanks for your help so far!

Cheers

bigal83:

andyb:
Hi.
Your problem seems like one I recently had too:

http://arduino.cc/forum/index.php/topic,156818.0.html

Thanks for your feedback, did your firmwares run on the platform even though you got the verification fail error?

Cheers

Yes, on mine the arduino bootloader was installed correctly, even though the error message appeared.
Have you tried to upload an arduino sketch via serial?

bigal83:
If I gave it the path to the one in arduino (I only have AVRdude through Arduino) it stood for a few second and than gave me the error "stk500_getsync(): not in sync: resp=0x00". What am I doing wrong here?

Looks like you may have specified the wrong COM# port. It should be whatever your Uno show up under in the IDE Tools->Serial Port menu.

The best way for me was to use the sketch from Gammon. Give it a try :slight_smile:

tsaG:
The best way for me was to use the sketch from Gammon. Give it a try :slight_smile:

Gammon Forum : Electronics : Microprocessors : Atmega bootloader programmer

Thanks, I'll try that later. Is that a sketch that you put on one adruino board to program a bootloader to another board? Specifically made for ATMega2560 it looks like?

Cheers