Programming Wireless: Arduino UNO works, Mega 2560 fails

I have an Xbee shield from http://openmicros.org/index.php/articles/88-ciseco-product-documentation/163

After som configuration I get the programming to work from th openmicros.org Xbee compatible board called XRF with an Arduino UNO.

Then I plug the Xbee shield to an Arduino Mega 2560 ant test communication. I tested with programming Communication-> ASCII sketch that just prints out the ASCII table. ( From the exampes provided from Arduino IDE). The Rs232 communication work better than with the Arduino UNO. This proofs that there is no hardware error och configaration faults.

Next step is to program the Arduino MEGA 2560 from the XBee Sheild. I test with the simple blink.ino.
I see the pin13 LED flash a pattern equal to the pattern on a Arduino UNO. This indicates that a Reset is performed.
Then the program start to upload.

The problem is that it will never get “Upload done”. It is stuck.

Looking in the board.txt one differance is that protocol is arduino for Arduino UNO and wiring for Arduino Mega 2560.

Downloading wiring and try to do a download from that platform. Work uploading to Arduino UNO but NOT to arduino Mega 2560.

Trying a Arduino Mega 2560 clone board. Same problem.

Looking at the specification and see that the Arduino Mega 2560 do NOT use a externat curcuit for USB to Arduinio programming.

What is the differance from Arduino UNO to Arduino Mega 2560 that causes problem with uploading to the Arduino?

Is there a way that I can program the Arduino Mega 2560 without using the USB and input the code thru some other pin(s).

cabbagecreek: The problem is that it will never get "Upload done". It is stuck.

One problem that can cause a 'stuck' upload on the Mega is having three '!' characters in a row. Check your strings to be sure you don't have "!!!" In any of them.

tested with a simple empty sketch

setup() {}
loop(){}

Same problem here. If the !!! problem is in code it must be somewhere else in the Arduino 1.5.2 IDE or its libraries.

The wired thing is that it compiles and uplods with USB.

I make a c# program that searches for !!! and something in hex that looks like "!!!"

I be back!

could not find any !!! in any binary file in the arduino 1.5.2 IDE directory.

I have heard mention that the Arduino 1.5.2 IDE should only be used for the Arduino DUE. For the UNO or MEGA you should try Arduino 1.0.5.

The Arduino IDE 1.0.5 did not change a thing..

I tried to add all loging that is availabe and created this loggs:

Programming with Arduino IDE 1.0.5 and the USB cable connected as COM71 and uploading Blink.ino:

Binary sketch size: 1 632 bytes (of a 258 048 byte maximum)
C:\Program Files (x86)\Arduino\hardware/tools/avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega2560 -cwiring -P\\.\COM71 -b115200 -D -Uflash:w:C:\Users\JOHNNY~1\AppData\Local\Temp\build3777620201733586904.tmp\Blink.cpp.hex:i 

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\hardware/tools/avr/etc/avrdude.conf"

         Using Port                    : \\.\COM71
         Using Programmer              : wiring
         Overriding Baud Rate          : 115200
avrdude: wiring_open(): releasing DTR/RTS
avrdude: wiring_open(): asserting DTR/RTS
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] 
avrdude: Recv: . [1b] 
avrdude: Recv: . [01] 
avrdude: Recv: . [00] 
avrdude: Recv: . [0b] 
avrdude: Recv: . [0e] 
avrdude: Recv: . [01] 
avrdude: Recv: . [00] 
avrdude: Recv: . [08] 
avrdude: Recv: A [41] 
avrdude: Recv: V [56] 
avrdude: Recv: R [52] 
avrdude: Recv: I [49] 
avrdude: Recv: S [53] 
avrdude: Recv: P [50] 
avrdude: Recv: _ [5f] 
avrdude: Recv: 2 [32] 
avrdude: Recv: t [74] 
avrdude: stk500v2_getsync(): found AVRISP programmer
         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
          ( data deleted to reduce post lenth)
                                  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 : Wiring
         Description     : Wiring
         Programmer Model: AVRISP
avrdude: Send: . [1b] . [02] . [00] . [02] . [0e] . [03] . [90] . [86] 
avrdude: Recv: . [1b] 
avrdude: Recv: . [02] 
(deleted alot ocf programmer data)
avrdude: Recv: . [0e] 
avrdude: Recv: . [13] 
avrdude: Recv: . [00] 
avrdude: Recv: . [12] 
### | 100% 0.26s

avrdude: 1632 bytes of flash written
avrdude: verifying flash memory against C:\Users\JOHNNY~1\AppData\Local\Temp\build3777620201733586904.tmp\Blink.cpp.hex:
avrdude: load data flash data from input file C:\Users\JOHNNY~1\AppData\Local\Temp\build3777620201733586904.tmp\Blink.cpp.hex:
avrdude: input file C:\Users\JOHNNY~1\AppData\Local\Temp\build3777620201733586904.tmp\Blink.cpp.hex contains 1632 bytes
avrdude: reading on-chip flash data:

Reading | avrdude: Send: . [1b] . [17] . [00] . [05] . [0e] . [06] . [80] . [00] . [00] . [00] . [81] 
avrdude: Recv: . [1b] 
avrdude: Recv: . [17] 
avrdude: Recv: . [00] 
(deleted olot of verifying data)
avrdude: Recv: . [ff] 
avrdude: Recv: . [cf] 
avrdude: Recv: . [0d] 
avrdude: Recv: . [00] 
avrdude: Recv: . [00] 
avrdude: Recv: 3 [33] 
### | 100% 0.19s

avrdude: verifying ...
avrdude: 1632 bytes of flash verified
avrdude: Send: . [1b] . [1f] . [00] . [03] . [0e] . [11] . [01] . [01] . [18] 
avrdude: Recv: . [1b] 
avrdude: Recv: . [1f] 
avrdude: Recv: . [00] 
avrdude: Recv: . [02] 
avrdude: Recv: . [0e] 
avrdude: Recv: . [11] 
avrdude: Recv: . [00] 
avrdude: Recv: . [19] 

avrdude done.  Thank you.

Programming with Arduino IDE 1.0.5 and the SRF/XRF connected as COM70 and uploading Blink.ino:

Binary sketch size: 1 632 bytes (of a 258 048 byte maximum)
C:\Program Files (x86)\Arduino\hardware/tools/avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega2560 -cwiring -P\\.\COM70 -b115200 -D -Uflash:w:C:\Users\JOHNNY~1\AppData\Local\Temp\build3777620201733586904.tmp\Blink.cpp.hex:i 

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\hardware/tools/avr/etc/avrdude.conf"

         Using Port                    : \\.\COM70
         Using Programmer              : wiring
         Overriding Baud Rate          : 115200
avrdude: wiring_open(): releasing DTR/RTS
avrdude: wiring_open(): asserting DTR/RTS
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] 
avrdude: Recv: 
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] 
avrdude: Recv: 
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] 
avrdude: Recv: 
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] 
avrdude: Recv: 
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] 
avrdude: Recv: 
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] 
avrdude: Recv: 
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

avrdude done.  Thank you.

By looking at this the avrdude si sending 1b,01,00,01,0e,01,14 and waits for a avrdude: Recv: . [1b] avrdude: Recv: . [01] avrdude: Recv: . [00] avrdude: Recv: . [0b] avrdude: Recv: . [0e] avrdude: Recv: . [01] avrdude: Recv: . [00] ... If it dont receive this it tries again 5 times and report this message

avrdude: stk500v2_ReceiveMessage(): timeout

This errormessage can be found all over internet with the Arduoino Mega 2560.

This page is Arduino troubleshooting: http://arduino.cc/en/Guide/Troubleshooting#toc1

On this page

The Arduino Uno and Mega 2560 use standard drivers (USB CDC) provided by the operating system to communicate with the ATmega8U2 on the board. Other Arduino boards use FTDI drivers to communicate with the FTDI chip on the board (or in the USB-serial convertor).

I have used the Arduino UNO and it is working but Not the Arduino Mega 2560!

The differance is that the Arduino UNO uses protocol Arduino (uno.upload.protocol=arduino in Board.txt) while Arduino MEGA 2560 uses protocol wiring (mega2560.upload.protocol=wiring in Board.txt).

Another thing that ias different is that Arduino UNO uses a optiboot bootloader (uno.bootloader.path=optiboot and uno.bootloader.file=optiboot_atmega328.hex in Board.txt) while the Arduino MEGA 2560 uses stk500v2 (mega2560.bootloader.path=stk500v2 and mega2560.bootloader.file=stk500boot_v2_mega2560.hex in Board.txt)