Upload .hex File to Mega 2560 Fails? HELP!

Dear member,

I want to upload a .hex file to the microcontroller Arduino Mega 2560 without using the IDE. I've therefore use the line used by the IDE to upload:

C:\arduino-1.0\hardware/tools/avr/bin/avrdude -CC:\arduino-1.0\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega2560 -cstk500v2 -P\\.\COM8 -b115200 -D -Uflash:w:C:\Users\Casper\AppData\Local\Temp\build8394104916657635061.tmp\sketch_may29a.cpp.hex:i

This works fine with an my Arduino UNO(with args modifications), but it fails on my Mega 2560. My question is why does it fail?

This is the output from the command line:

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:\Users\Casper\Desktop\GUIMenu_v2.8\ArduinoFiles/avrdude.conf"

         Using Port                    : \\.\COM8
         Using Programmer              : stk500v2
         Overriding Baud Rate          : 115200
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
         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 : STK500V2
         Description     : Atmel STK500 Version 2.x firmware
         Programmer Model: Unknown
avrdude: Send: . [1b] . [01] . [00] . [02] . [0e] . [03] . [90] . [85] 
avrdude: Recv: 
etc.
etc.
etc.

Any help is really appreciated because this is an important part of my project! Please leave a reply below :)

Casper

After long searching I found the solution and I will leave it here for you!

First: thank god for giving me this answer!

avrdude.exe seemed to be the problem. I used the arduino-1.0 IDE version and with that comes the avrdude.exe. In this version there is some kinda bug that does not allow or cannot provide support for uploading .hex files to the Arduino Mega 2560 apart from using the Arduino IDE. You'll need to download the 0023 version(here) of the Arduino IDE, which is an alpha version. It is therefore not fully stable but I haven't had any problems with it so far. Now use this avrdude.exe and avrdude.conf to upload (located in C:\Users\%username%\Downloads\arduino-0023\hardware\tools\avr\etc and C:\Users\%username%\Downloads\arduino-0023\hardware\tools\avr\bin)

This is an example of how I used it: C:\Users\Casper\Desktop\ArduinoFiles\avrdude -CC:\Users\Casper\Desktop\ArduinoFiles\avrdude.conf -v -v -v -v -patmega2560 -cstk500v2 -P\.\COM8 -b115200 -D -Uflash:w:C:\Users\Casper\Desktop\LIGHTSOFF.hex:i

C:\Users\Casper\Desktop\ArduinoFiles\avrdude -CC:\Users\Casper\Desktop\ArduinoFiles\avrdude.conf -v -v -v -v -patmega2560 -cstk500v2 -P\.\COM8 -b115200 -D -Uflash:w:C:\Users\Casper\Desktop\LIGHTSON.hex:i

I have the same problem, in fact i need to download a precompiled .hex file using avrdude.exe inside the arduino-1.0.1 using the cmd.exe. The solution with the arduino-0023 version works, but I find another solution using 1.0.1 version.

I find the solution here: http://false.ekta.is/2011/05/avrdude-5-10-arduino-mega-2560-command-line-uploading/ at the "critiacrof" user reply:

critiacrof 1 February, 2012 at 12:15 pm

Use -c wiring in stead of -c stk500v2 than it will work!

For example the downloading command that works for me is:

"C:\arduino-1.0.1\hardware\tools\avr\bin\avrdude.exe" -C "C:\arduino-1.0.1\hardware\tools\avr\etc\avrdude.conf" -v -p atmega2560 -c wiring -P\.\COM13 -b 115200 -D -Uflash:w:Blink.cpp.hex

Hope it help.