Go Down

Topic: Upload Timeout Error on Mega 2560 - Not Sure What Changed (Read 255261 times) previous topic - next topic

camilozk

I am having the same problem with my mega 2560

It says:

-----------------------------------------------------------------------------------------------------------
Arduino: 1.6.4 (Windows 7), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Sketch uses 6,916 bytes (2%) of program storage space. Maximum is 253,952 bytes.

Global variables use 468 bytes (5%) of dynamic memory, leaving 7,724 bytes for local variables. Maximum is 8,192 bytes.

avrdude: ser_open(): can't open device "\\.\COM8": Access is denied.
avrdude: ser_drain(): read error: The handle is invalid.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
-----------------------------------------------------------------------------------------------------------

or it remains uploading forever...


I checked the firmware info and I have rev 0001. Arduino website says that there is no need to update the firmware if you have rev 0001.

I also replaced the avr folder of my IDE 1.6.4 with the avr folder of 0023. Also nothing...


I am out of ideas!

fhpa

Hi everybody,

i often had the same problem: ...timeout...

By chance I found in one of my programs a line where I can switch the error on or off...

I show you a small part of my program. (The whole program has more than 2000 lines)

Please look to the comment-lines:

void parameter_holen(){
  Serial.println(server);
  if (client.connect(server,80)){ // Verbindung zum Server aufbauen
    Serial.println("Parameter vom Server holen...");
    http_request("parameter");
    parameter_auslesen();
  }else{

    // If i uncomment the following line, i can't upload the program due to the timeout-error
   
    //Serial.println("Parameter holen: Keine Serververbindung gefunden...");

    resetFunc();
  } 
}


I think the timeout-error has also to be seen in combination with the rest of the program.

For me it is a very strange behavior of the IDE.

Good luck for all of you seeing the timeout error!

davidutn

A mi me pasaba igual y no sabia la razón... la cosa era que en alguna parte del código tenia una línea de este tipo...

      Serial.println("ENVIAR LLAMADA DE EMERGENCIA...!!!");

"LA SOLUCIÓN" fue quitar los símbolos de exclamación y listo...

      Serial.println("ENVIAR LLAMADA DE EMERGENCIA..");

PRUEBEN ESTO Y ESPERO LES HAYA AYUDADO EN SOLUCIONAR SU PROBLEMA.

tg1929

I had the same problem with my Ethermega 2560. I could not upload under windows 8.1. I also tested on Linux and had the same problem.
I remembered the last change I made to the working board was to break the RST-EN link which prevents the board resetting when the serial link is established. This was causing unwanted resets in my application.
I reconnected the link and my sketches now upload correctly.

eleff

Does anyone know how to test if the 8U2 is the culprit?

ardn00bo

I have the same issue as Ragnar.

Ragnar did you solve this?

Nick Gammon,

Setup
------
OS = Mac El Capitan 10.11 + CH341 driver for Mega 2560 clone
Arduino IDE = 1.6.6 10/14/15 4:07 build
ISP = SparkFun Redboard
Mega 2650 = Chinese Clone 16AU 1446*
Bootloader Sketches = http://www.gammon.com.au/bootloader

Steps
------
1. Prepare RedSpark Redboard as an ISP to program a Mega 2560 Chinese clone
2. Run Nick Gammon's Atmega Board Programmer (Github 10/22/15 pull) to program bootloader onto 2560. I downloaded the GitHub code on 0ct 22, 2015.
3. Arduino IDE upload sketch to the 2560 ONCE.   Sketch runs on board.

In order re-upload a sketch without a time out, I must run 1-3 again. It's independent of the contents of the sketch (it can be the default empty setup() loop() routines).

This is painful.

Is something getting clobbered in the bootloader (ie lock bits) when the sketch is uploaded?

What info can I provide to help debug this?

Related
---------
See following:
[Topic: Bootloader only works once? ] http://forum.arduino.cc/index.php?topic=49277.0

Message #17

Gene Buckle Says

-U lock:w:3F:m to the avrdude command line before the flash write and
-U lock:w:0F:m to the avrdude command line after the flash write cures the problem.


Other
------
* Reading other posts - this may also affect official Arduino Mega 2560's, but I can get my official board serial port to be detected under Mac OS 10.11 El Capitan. See [Topic: El Capitan - Arduino IDE serial port problems] https://forum.arduino.cc/index.php?topic=351999.15

nickgammon

#111
Oct 26, 2015, 09:08 pm Last Edit: Oct 26, 2015, 09:09 pm by Nick Gammon
Quote
In order re-upload a sketch without a time out, I must run 1-3 again. It's independent of the contents of the sketch (it can be the default empty setup() loop() routines).
Optiboot on the 328 does not alter the lock bits at all, as I discovered. Possibly the Mega bootloader does, I haven't looked at the source of it. If it does it would (probably) be doing what is in the boards.txt file. Judging by my copy in IDE 1.6.5 it would look like this:

Code: [Select]
mega.bootloader.tool=avrdude
mega.bootloader.low_fuses=0xFF
mega.bootloader.unlock_bits=0x3F
mega.bootloader.lock_bits=0x0F


I think we need to confirm whether or not the lock bits are being changed. Use my board programmer (which you already know how to use) to observe the lock bits (without changing anything) immediately after reprogramming the bootloader.

Then upload a sketch. Then find what the new lock bits are. Please post this information here (copy and paste). You should see something like this:

Code: [Select]
Atmega chip programmer.
Written by Nick Gammon.
Version 1.35
Compiled on Oct 27 2015 at 07:04:41 with Arduino IDE 10605.
Attempting to enter ICSP programming mode ...
Entered programming mode OK.
Signature = 0x1E 0x98 0x01
Processor = ATmega2560
Flash memory size = 262144 bytes.
LFuse = 0xFF
HFuse = 0xD8
EFuse = 0xFD
Lock byte = 0xEF
Clock calibration = 0x5D
Bootloader address = 0x3E000
Bootloader length = 7474 bytes.


Now you can disconnect without programming (if you want). In the middle there is the lock byte (0xEF in my case). Or just verify:

Code: [Select]
Type 'Q' to quit, 'V' to verify, or 'G' to program the chip with the bootloader ...  V
Verifying ...
No errors found.
Done.
Programming mode off.
Type 'C' when ready to continue with another chip ...


Using that bootloader I have been using my Mega repeatedly yesterday. No problems at all.
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

ardn00bo

Hi Nick,

I want to try what you suggest, however, after many times of uploading the boot loader with a redboard , and switching power to the mega to upload a sketch, I introduce an issue.

Now the mega 2560 does't show any serial output (the USB serial driver is detected by my mac), and your board programmer says


Atmega chip programmer.
Written by Nick Gammon.
Version 1.35
Compiled on Oct 25 2015 at 15:55:45 with Arduino IDE 10606.
Attempting to enter ICSP programming mode ......................................................
Failed to enter programming mode. Double-check wiring!
Type 'C' when ready to continue with another chip ...


Despite the wiring to be the same.

What can I do to troubleshoot? MCU killed?

shooking

Hi Nick

Firstly, thanks for your bootloader program for 2560. Not sure on rules for posting other URLs - so I wont.

I replied on another post - in my case I have a cheap Chinese 340g / 2560 system. Essentially, most folks come to this conclusion:

1 - flash your bootloader (http://www.gammon.com.au/forum/?id=11635)
2 - load any sketch - only once
3 - attempt to anything else results in sync timeout ... goto 1.

My suspicion was the bootloader we being overwritten. At first I thought I had proved this with the aid of your verification code

take original board -> verify bootloader -> FAIL
attempt to load sketch -> FAIL
Use 1280 to upload your bootloader -> verify bootloader -> works
attempt to load sketch -> WORKS!

But then verify bootloader -> OK ??? So why you not load?

If I go back to my 1,2,3 sequence I can get to step 2.

That is - maybe the bootloader isn't being overwritten.

On other posts folks complain about DTR line (?) - they need to add a 100uF cap to it to help drop voltage? Apparently if one does not have the official design, the pseudo clones are not resetting properly, and so one cannot get them into sync.

I am hoping to trial this idea - once I can workout where to make the mod on my boards.

My guess is the 1,2,3 sequence would have to somehow avoid some other DTR related issue - but how.

Anyhow, really appreciate your bootloader and other excellent articles you publish on the net.

 

giantkiller

Back the truck up here.
You stated 'Not Sure What Changed'
As of when?
The current layers of computer OS, Java version, and IDE are at fault.
I will fore tell that you will see alot of mysteries pop up amongst users that are working on code at this versioning window.

The 2 camps are users that have 3d printers already working and those that are pushing code.
The code group is going to show alot of different errors in the coming days. They are the ones working with in their platform layer that needs compiles, uploading and run test. This layer is most susceptible to a lot of changes across the internal layers I mentioned previously.

18turbo

Yo lo he solucionado cambiando el cable USB, así de simple.

Tenía uno de impresora -que era bastante largo-. Cambié el cable USB por otro que tenía -un poco más corto- y ¡voilà!

Ahora me vuelve a funcionar todo bien.

Yo no sé si será una solución real, pero a mí me funcionó y vuelvo a tener mi clon de Arduino Mega funcionando.

Quería postearlo por si a alguien puede servirle.



--- ENGLISH -----

I had the same problem. After reading very much and not solution...


... change the USB cable...


.... and WORKS FINE!!!!!!!!!!!


I don't know why, but now my chinese Arduino Mega works...

jmanatee

--- ENGLISH -----

I had the same problem. After reading very much and not solution...


... change the USB cable...


.... and WORKS FINE!!!!!!!!!!!


I don't know why, but now my chinese Arduino Mega works...

Worked for me too

sundberg84

#117
Dec 13, 2015, 05:30 pm Last Edit: Dec 13, 2015, 05:39 pm by sundberg84
Hi!

I have the same issue, tried Win7 and WinXP computer, different usb cables but same result:

1 - flash your bootloader (http://www.gammon.com.au/forum/?id=11635)
2 - load any sketch - only once
3 - attempt to anything else results in sync timeout ... goto 1.

Did anyone came to a sollution with this problem?

dataino

Me to the same problem !!!


avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude:

And a the end   REMOVE ->>>> "!!!"



ERROR NO UPLOAD
Code: [Select]
Serial.print( F("[ !!! NOT FINDED !!!]") );

GOOD UPLOAD
Code: [Select]
Serial.print( F("[ NOT FINDED ]") );

nickgammon

Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

Go Up