Go Down

Topic: Mega 2560 randomly hanging (Read 2256 times) previous topic - next topic

My Arduino Mega 2560 is randomly hanging while I try to upload. One the same program is uploaded without any glitches. Other times it just hangs. If I press the upload button again I am getting the error saying the the COM5 port is already in use. I either have to remove the USB and plug it in again(sometimes even this doesn't work I have to restart the PC). Then again it works fine .

Coding Badly


Stan09

Obviously, uploading a sketch.
I also have multiple issues like that.
I have a feeling there is some 'gray area' somehow related to MEGA bootloader.
Sketch is complicated enough, with Adafruit datalogger shioeld, LCD shield and QuadRAM shield.
It might be working perfectly well for days, than something happens and you cannot upload anymore.
Sometimes uploading another  simple sketch helps, sometimes it does not.
My common impression is that Arduino MEGA 2560 is very unstable board, hardly useful for anything more complicated than blinking LEDs :(
BTW, Ard DUE is even  worse.



retrolefty

#3
Dec 09, 2012, 05:01 pm Last Edit: Dec 09, 2012, 05:02 pm by retrolefty Reason: 1
The arduino mega boards use a bootloader that has a 'special but never used' feature that if it sees three !!! characters in a row in the data being sent to the board during a upload operation, the bootloader enters a 'monitor' mode waiting for user commands from the PC that will never come. So while it may not be your problem specifically, but it has trapped a lot of other people, so check to see if you have any !!! strings in the sketch code and change them.

Lefty

Stan09

Interesting. What exactly 3 characters? Any link to more detailed info on this?

retrolefty

#5
Dec 09, 2012, 06:34 pm Last Edit: Dec 09, 2012, 06:39 pm by retrolefty Reason: 1

Interesting. What exactly 3 characters? Any link to more detailed info on this?


The ! ASCII character, as in 0x21. So three 0x21 bytes sent in a row anywhere in the upload data stream locks up the bootloader waiting for user monitor commands from the PC which will never come. As far as more detailed info, there has been a lot posted in the forum over the years sense the original mega1280 board was released, but I'm not aware of any 'official' document posted on the arduino web site. There is mostly likely a old and mouldy bug report in the arduino developers bug reporting archive list wherever one finds that.

The source code for the mega bootloader is included in the IDE software distribution if you want to seek it out and read about this wonderful feature included in the mega bootloader code.

Lefty

pico

#6
Dec 10, 2012, 07:53 am Last Edit: Dec 10, 2012, 07:55 am by pico Reason: 1

The ! ASCII character, as in 0x21. So three 0x21 bytes sent in a row anywhere in the upload data stream locks up the bootloader waiting for user monitor commands from the PC which will never come.


Just as an update, the _latest_ Mega2560 bootloader is supposed to have fixed this particular problem. But that is no use to you if have a Mega with the old bootloader installed (unless you want to reflash the bootloader with the newer one.)

However, the latest version seems to have some new issues of  its own. Refer this thread:

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

WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

Nick Gammon

Quote
if it sees three !!! characters in a row


...

Quote
What exactly 3 characters?


Three !!! characters. Wasn't that part clear?
Please post technical questions on the forum, not by personal message. Thanks!

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

Nick Gammon

I'm sorry if I seemed a bit short. I meant, the character '!', three times. As in: !!!
Please post technical questions on the forum, not by personal message. Thanks!

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

Nick Gammon

I have the latest bootloader for the Mega2560, the one that fixes the watchdog problems. It also does not have the problems reported in the above thread. Running the test sketch:

Code: [Select]

void setup(){
  Serial.begin(9600);
}

void loop(){
  Serial.println("Hello world");
  delay(1000);
}


It commences executing immediately.
Please post technical questions on the forum, not by personal message. Thanks!

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

Nick Gammon

This file, I think:

https://github.com/arduino/Arduino-stk500v2-bootloader/blob/master/goodHexFiles/stk500boot_v2_mega2560.hex

Just confirmed it handles the "!!!" problem, it doesn't have a watchdog timer issue, and it doesn't have the problem with the 10-second wait. So, good to go!
Please post technical questions on the forum, not by personal message. Thanks!

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

Nick Gammon


However, the latest version seems to have some new issues of  its own. Refer this thread:


That thread doesn't actually say he has "the latest version".
Please post technical questions on the forum, not by personal message. Thanks!

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

pico

#12
Dec 10, 2012, 01:05 pm Last Edit: Dec 10, 2012, 01:11 pm by pico Reason: 1

That thread doesn't actually say he has "the latest version".


No, but I do have the latest version of the bootloader, and can report the problem occurs for that version interacting with IDE version 1.0.2 under Win XP sp 3.
WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

pico


and it doesn't have the problem with the 10-second wait. So, good to go!


Which version of OS and IDE are you using to test the bootloader interaction with?
WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

Nick Gammon

My test was on 1.0.1 and Mac OS/X.
Please post technical questions on the forum, not by personal message. Thanks!

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

Go Up