Pages: [1]   Go Down
Author Topic: Bug with !!! Using Mega 2560  (Read 10030 times)
0 Members and 1 Guest are viewing this topic.
Rochester, NY
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is an apparent bug with the Mega 2560. So far it has been found to not occur with a Duemilanove, but three different Mega 2560s have gotten it to occur.

When the code contains three or more exclamations it will prevent the sketch from being able to complete uploading. Note that there is no compile errors. However eventually there may be a timeout from avrdude.

An example set of code that causes this behavior is:
Code:
int IncrementingInteger = 1345;
int AlarmTriggerInteger = 1355;
boolean BooleanAlarmTriggered = false;

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

void loop() {
  delay( 5000 );
  IncrementingInteger = IncrementingInteger + 1;
  Serial.print( "Incrementing integer: " );
  Serial.println( IncrementingInteger );
  Serial.print( "Alarm trigger integer:" );
  Serial.println( AlarmTriggerInteger );
  if ( BooleanAlarmTriggered == false ) {
    if ( IncrementingInteger == AlarmTriggerInteger ) {
      BooleanAlarmTriggered = true;
      Serial.println( "Alarm has gone off!!!" );
    }
  }
}

Removing just one of the exclamation marks from the Serial.println ( "Alarm has gone off!!!" ); will allow the sketch to upload normally and it will work as expected. I was unable to find reference to this problem otherwise.

Devices used:
Arduino Mega 2560 with Arduino IDE 0022 on a Windows 7 64bit. - Problem occurs.
Duemilanove with Unknown IDE Version on a Windows 7 64bit. - No problem.
Second Arduino Mega 2560 with Arduino IDE 0022 on OSX. - Problem occurs.
Third Arduino Mega 2560 with Arduino IDE 0021 on Ubuntu 10.04 64bit - Problem occurs.

This was originally raised in thread:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1294452951/0#0

If any further information is needed, please let me know.
« Last Edit: January 09, 2011, 09:49:22 am by fillibar » Logged

Leighton Buzzard, UK
Offline Offline
Edison Member
*
Karma: 21
Posts: 1339
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

just tried it on a UNO
works fine
uploaded ok and serial monitor is showing

Alaarm trigger integer xxx
Incrementing integer xxx
Alarm has gone off!!!
« Last Edit: January 10, 2011, 05:03:06 am by mmcp42 » Logged

there are only 10 types of people
them that understands binary
and them that doesn't

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17261
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If repeatable by others, this has got to be one of the strangest bugs ever reported.  ;D

Somehow my gut says there is something else going on, but I'm just a hardware guy, so don't take what I think to the bank.  smiley-wink

Lefty
Logged

Leighton Buzzard, UK
Offline Offline
Edison Member
*
Karma: 21
Posts: 1339
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

a long time ago in a far off computer room
when operating systems were compiled from punch cards every night...

we had a strange bug then
only went wrong on the 17th of the month as I recall

turned out that the bit pattern of the digits as it went past looked like the pattern for some sort of reset

... just wondering

mebbe the clever (ha ha) boot loader is using !!! as a delimiter
I dunno ignore rambling
« Last Edit: January 10, 2011, 04:05:20 pm by mmcp42 » Logged

there are only 10 types of people
them that understands binary
and them that doesn't

Rochester, NY
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It has to be my original background in Software QA coming to haunt me like normal...

Case in point, I often use POV-Ray for some other work and have found 2 bugs there that were unknown because nobody used it in ways I did (debug file data getting overwritten instead of appended and failure rendering images 41000x41000 pixels). Go figure.

I saw the mention about the Google Code issues section (oops) and have now posted this there with all the information everyone has helped me get (and links to the posts). It is issue 459.
http://code.google.com/p/arduino/issues/detail?id=459
« Last Edit: January 10, 2011, 10:27:45 pm by fillibar » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17261
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You know !!! rings a bell now. I seem to recall the brand new bootloader used in the 2560 boards, called opti something, included a monitor function that activated with a !!! command, maybe. Possibly the bootloader is jumping to it's monitor function waiting for only valid monitor commands. Might be something you just have to live with for awhile and if fixed will require reburning a 'fixed' bootloader into your 2560.

As an experiment why don't you try ! ! ! (spaces) instead of !!! and see if that works. I don't own a mega2560 or I would try it.

Lefty
« Last Edit: January 11, 2011, 12:25:43 am by retrolefty » Logged

Rochester, NY
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Having spaces between the exclamation marks works just fine. I just removed the extra exclamation marks since it was just a happy debug note that I got the alarm working.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Looks like lefty was right and they are already aware of the issue:

http://code.google.com/p/arduino/issues/detail?id=392
Logged

Rochester, NY
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Would you look at that! Apparently the search function on the issues site does not like "!!!" (which is how I checked if a bug already existed). It just lists all. But I did a search just now for Mega and found that existing one and mine. I will add a comment to mine indicating the prior bug. Now I REALLY feel redundant.
Logged

USA
Offline Offline
Full Member
***
Karma: 2
Posts: 213
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes we are aware of this bug. I wrote the bootloader that is in the mega. I have fixed the bug and the fix has been submitted.  If anyone wants the lastest bootloader source and cant find it, send me a private message. I can also send you a hex file ready to program into the chip

The bug is ONLY in the 2560 bootloader (stk500v2) not in the optiboot which is the new uno.

The 2560 requires st500v2 protocol to be able to handle above 128K.

Lefty is correct, spaces will fix the problem. The bootloader watches for "!!!" (no spaces) to switch to monitor mode

For more info about the bootloader and what the "!!!" does, refer to

http://www.avr-developers.com/bootloaderdocs/index.html

Mark
« Last Edit: January 17, 2011, 11:36:13 am by msproul » Logged

Pages: [1]   Go Up
Jump to: