Go Down

Topic: print("!!!") Bug? (Read 2095 times) previous topic - next topic

mech2you

If i use this code here below and change the print line to Serial.print("!!!"); then i canĀ“t upload the Code to the Arduino Mega 2560 rev 3.


void setup() {
  // put your setup code here, to run once:
 Serial.begin(9600);
 Serial.print("test"); // Serial.print("!!!"); //Crash!!! upload over USB not working (Arduino Mega 2560 Rev.3)
}
void loop() {
  // put your main code here, to run repeatedly:

}


PaulS

The bootloader has a debug mode that is entered by keying in !!!. When your code contains those same characters, the bootloader goes into debug mode. The rest of the data stream is not stuff that the debug mode recognizes, and it never gets the "exit debug mode" command, so the upload simply fails. The moral of the story? Don't use excessive punctuation in your code.

mech2you

Good to know because in the reference book is nothing about that  :)

https://www.arduino.cc/reference/en/language/functions/communication/serial/print/



AWOL

The moral of the story? Don't use excessive punctuation.
Fixed it.

pert

This problem only occurs if your board has a very old version of the Mega bootloader. So it would either need to be a vintage Mega board or else some clone/derivative/counterfeit where the manufacturer is using the bootloader from a decade ago.

If you have an ISP programmer or a spare Arduino board you can use as an "Arduino as ISP", then you can connect it to your Mega and do a Tools > Burn Bootloader. That will install the modern Mega bootloader, which doesn't have the problem with the !!!.

Fun fact: with the old bootloader when it has this problem the verbose output spells out "bootloader huh?" over and over.

Go Up