Go Down

Topic: How to crash the upload with a single line (Read 983 times) previous topic - next topic

lukeskymuh

Hi,

I just got crazy because my the upload stopped each time i tried to upload it.
With a lot of tests I found out that a single line caused the crash. Here it is the code:

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

void loop() {
  Serial.print("execute!!!!!!");
}

Try to upload this code onto your arduino and tell me if you get the message "Upload Done" or it also crashes.
Does anyone knows why it crushes?

My System: Win7, Arduino 1.0 and 0022, MEGA 2560

retrolefty

Easy one. There is a feature (or some would call a bug) in the mega bootloader that anytime it sees three ! marks in a row it goes to a monitor mode and hangs waiting for monitor commands that will never occur. This feature is kind of useless and not really supported by the IDE but remains a problem if your source code has 3 or more ! anywhere in the compiled code. So your solution is to change:

Serial.print("execute!!!!!!");

to

Serial.print("execute!");

Lefty

spycatcher2k

Serial.print("execute!!!!!!");  <-- This line is causing the error - 3 ! in a row causes the bootloader to enter a nonresponsive mode.
Mrs Drew
-=-
UK Based PCB Manufacturing - PM for details
I will design & code for you, but I will also charge you (PM me)
Use Google or search this site BEFORE asking!

lukeskymuh

Thank you guys.

I needed hours to find this bug.
Do you know if there will there be some update to correct the bug or an debugger warning or error to  prevent others to get the same problem?

retrolefty


Thank you guys.

I needed hours to find this bug.
Do you know if there will there be some update to correct the bug or an debugger warning or error to  prevent others to get the same problem?


As far as I recall the mega2560 bootloader has at least two 'serious' bugs, the !!! one and it doesn't handle watchdog timer interrupts correctly if you want to use the WDT function. I know these bugs are archived in the arduino developers database but I don't have a clue if a fix is ready or not and if so when it will be released.

Lefty

Go Up