Pages: [1] 2   Go Down
Author Topic: Burning the Bootloader, Arduino Mega 2560 r3, unsolved issues  (Read 4344 times)
0 Members and 1 Guest are viewing this topic.
Switzerland
Offline Offline
Jr. Member
**
Karma: 1
Posts: 66
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi All,

I needed to burn the Bootloader onto Arduino Mega2560 r3
because I got this Message Error in Arduino IDE, V1.05:

Code:
avrdude: stk500v2_ReceiveMessage(): timeout
I checked several configurations and tried also with a PC Win7 without success.

So I ordered an USBasp AVR-ISP-Programmer and plugged it into my Mac mini OS X V10.8.4.

1 .First I tried to burn the Bootloader using the Arduino-IDE
Board: Arduino Mega 2560
Serial Port: (not visable!)
Programmer: USBasp

I got these messages (after approx. 3 mins):

Code:
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: verification error, first mismatch at byte 0x1e000
         0xff != 0x0d
avrdude: verification error; content mismatch

2. I used avrdude:

Code:
$ avrdude -c usbasp -P usb -p m2560 -U flash:w:stk500boot_v2_mega2560.hex -v

and I got this output:

Code:
avrdude: Version 5.11.1, compiled on Jul 26 2013 at 11:40:23
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/opt/local/etc/avrdude.conf"
         User configuration file is "/Users/luigi/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : 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
           flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 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 : 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.00s

avrdude: Device signature = 0x1e9801
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D8
avrdude: safemode: efuse reads as FD
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 "stk500boot_v2_mega2560.hex"
avrdude: input file stk500boot_v2_mega2560.hex auto detected as Intel Hex
avrdude: writing flash (261406 bytes):

Writing | ################################################## | 100% 102.45s



avrdude: 261406 bytes of flash written
avrdude: verifying flash memory against stk500boot_v2_mega2560.hex:
avrdude: load data flash data from input file stk500boot_v2_mega2560.hex:
avrdude: input file stk500boot_v2_mega2560.hex auto detected as Intel Hex
avrdude: input file stk500boot_v2_mega2560.hex contains 261406 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 68.49s



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

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.

Is there a way to solve these issues?

1. Issue
Code:
avrdude: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.

2. Issue

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


But nevertheless I'm now able to upload sketches to the Arduino Mega 2560 again.
« Last Edit: July 26, 2013, 08:47:46 am by flurin » Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8975
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

"input file stk500boot_v2_mega2560.hex contains 261406 bytes"

This looks way wrong to me.  The file size is 21k so I don't think it can contain 261k bytes.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Atlanta, USA
Offline Offline
Edison Member
*
Karma: 56
Posts: 1847
AKA: Ray Burne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You may wish to try accessing the monitor in the Mega2560 bootloader just to be sure the system is crashed.  You could have another issue...

http://avr-developers.com/bootloaderdocs/

Logged

Switzerland
Offline Offline
Jr. Member
**
Karma: 1
Posts: 66
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@johnwasser
Thanks for your reply.

I used the file:
/Applications/Arduino/Contents/Resources/Java/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex

The file size is 21 KB
« Last Edit: July 26, 2013, 09:16:09 am by flurin » Logged

Switzerland
Offline Offline
Jr. Member
**
Karma: 1
Posts: 66
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You may wish to try accessing the monitor in the Mega2560 bootloader just to be sure the system is crashed.  You could have another issue...

http://avr-developers.com/bootloaderdocs/



I'm not sure what you mean. But the Board works now again and I did a Loop-Back Test before I burned the Bootloader, it was okay.
Logged

Switzerland
Offline Offline
Jr. Member
**
Karma: 1
Posts: 66
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

"input file stk500boot_v2_mega2560.hex contains 261406 bytes"

This looks way wrong to me.  The file size is 21k so I don't think it can contain 261k bytes.

avrdude: writing flash (261406 bytes):

I think 261406 bytes is the flash memory size (256 KB = 262144 bytes)
Logged

Switzerland
Offline Offline
Jr. Member
**
Karma: 1
Posts: 66
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Update:

1. Issue solved. I've updated the USBasp-Firmware as described in

http://forum.arduino.cc/index.php?topic=149668.60

2. Issue: open, I'm investigating, any ideas?
Logged

Wahiawa, Hawaii
Offline Offline
God Member
*****
Karma: 34
Posts: 665
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

2. Issue: open, I'm investigating, any ideas?

The USBasp programmers are using an older protocol that does not properly support more than 64K flash.  You need a programmer that is using the stk500v2 protocol, like the AVRISPmkII.

The USBasp programmer will sort of work for burning bootloader, it will not verify correctly.  It will not work for uploading sketches.

Logged

Switzerland
Offline Offline
Jr. Member
**
Karma: 1
Posts: 66
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the reply.
Generally I use the Arduino IDE to upload the sketches (3D-Printer firmware). I used the USBasp only to burn the bootloader. This works with the exception of the verifying issue. It seems to be a stupid error so my stupid solution is to use the avrdude -V option (Disable automatic verify check when uploading data).
« Last Edit: July 28, 2013, 01:48:31 am by flurin » Logged

Switzerland
Offline Offline
Jr. Member
**
Karma: 1
Posts: 66
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The USBasp programmers are using an older protocol that does not properly support more than 64K flash.  You need a programmer that is using the stk500v2 protocol, like the AVRISPmkII.

The USBasp programmer will sort of work for burning bootloader, it will not verify correctly.  It will not work for uploading sketches.

Is the "verification error" really a specific USBasp issue?

http://forum.arduino.cc/index.php?topic=177070.0

http://forum.arduino.cc/index.php?topic=115531.0
Logged

Wahiawa, Hawaii
Offline Offline
God Member
*****
Karma: 34
Posts: 665
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is the "verification error" really a specific USBasp issue?

Aside from actual wiring problems or clocking problems causing verification errors, any programmer that is not using the stk500v2 protocol will have issues dealing with more than 64K bytes of flash memory.  That includes ArduinoISP and USBtinyISP.

Logged

Switzerland
Offline Offline
Jr. Member
**
Karma: 1
Posts: 66
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

My latest tests with USBasp:

1. read the flash memory

Code:
avrdude -c usbasp -p m2560 -P usb -b 115200 -U flash:r:mega2560_flash.hex:i

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9801
avrdude: reading flash memory:

Reading | ################################################## | 100% 47.72s



avrdude: writing output file "mega2560_flash.hex"

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

I compared mega2560_flash.hex with stk500boot_v2_mega2560.hex
Starting with the address 0xE000 the data are the same.

2. verify the flash memory with mega2560_flash.hex

Code:
avrdude -c usbasp -p m2560 -P usb -b 115200 -U flash:v:mega2560_flash.hex:i

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9801
avrdude: verifying flash memory against mega2560_flash.hex:
avrdude: load data flash data from input file mega2560_flash.hex:
avrdude: input file mega2560_flash.hex auto detected as Intel Hex
avrdude: input file mega2560_flash.hex contains 261406 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 47.60s



avrdude: verifying ...
avrdude: 261406 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

It seems that USBasp is able to manage 256 KB flash memory if the file and flash size are the same (261406 bytes).
The verification error occurs only with automatic verify check.
« Last Edit: July 28, 2013, 03:19:17 pm by flurin » Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 137
Posts: 6805
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
any programmer that is not using the stk500v2 protocol will have issues dealing with more than 64K bytes of flash memory.
STK500v1 actually works OK with up to 64k WORDS of flash memory.
AVRDUDE is apparently "clever" and will use the "raw spi command" when the "Write memory" page doesn't support high memory.  But it's not so smart about "read", which is why you can sometimes get successful bootloader burning that fails to "verify."
I haven't kept track of all the myriad protocols that avrdude supports, but I would be surprised if "stk500v2" is the ONLY one that supports >64k of flash.

It would be nice to have a stk500v2 version of ArduinoISP...
Logged

Switzerland
Offline Offline
Jr. Member
**
Karma: 1
Posts: 66
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


It would be nice to have a stk500v2 version of ArduinoISP...

Nick Gammon has an ArduinoISP alternative that works with Mega2560:

http://www.gammon.com.au/forum/?id=11635

I didn't test it yet.

AVRDUDE is apparently "clever" and will use the "raw spi command" when the "Write memory" page doesn't support high memory.  But it's not so smart about "read", which is why you can sometimes get successful bootloader burning that fails to "verify."
I haven't kept track of all the myriad protocols that avrdude supports, but I would be surprised if "stk500v2" is the ONLY one that supports >64k of flash.

There is a difference how Arduino IDE and averdude write Hex files:

Arduino IDE:

:020000023000CC
:10E000000D9489F10D94B2F10D94B2F10D94B2F129

Record Type 2 (Extend Segment Address Record)
and 0x10 bytes per line

avrdude:

:020000040003F7
:20000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00

Record Type 04 (Extend Linear Address Record)
and 0x20 bytes per line

I'm wondering whether this may be the problem. Is there a way to define the Intel HEX format either for Arduino IDE or avrdude?
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 137
Posts: 6805
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Nick Gammon has an ArduinoISP alternative that works with Mega2560
Actually, he has an "optiloader" alternative, which is slightly different.
Logged

Pages: [1] 2   Go Up
Jump to: