Bug in Sketch crashes Avrdude?

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
stephanie
 
Posts: 295
Joined: Sat Dec 11, 2010 1:17 am

Bug in Sketch crashes Avrdude?

Post by stephanie »

I'm working on a project on one of my shiney new Mega 2560's I received from Adafruit last week, and I've just spent a crazy 30 minutes trying to figure out a really bizzare problem.

Overall the project can receive data from an XBee on Serial3 or from an ethernet shield. There are two functions that parse the received data and act on it. The parsed data can cause parts of the graphical display to be updated. All this works fine.

Today I just added a new data handler - it's the same function in both of the parse routines, literally copied & pasted then changed one variable - but when the function call is in one of the routines, it crashes the arduino bootloader so that avrdude never finishes the upload. With the preferences set to verbose upload, I can see the data coming back from the Arduino looks like the bootloader has dropped into its monitor routine, where it's waiting for direct debugging commands.

Code: Select all

  } else if(message.startsWith("outdoorTemp=")) {
    String buffer = message.substring(12);
    int tt = stringToNumber(buffer);
    outdoorTemp = tt;
    outdoorTempTime = now.secondstime() + 900;
//    updateOutdoor();
  }
In this code snippit, if I un-comment the last line, the sketch compiles ok but the sketch will not upload - avrdude or the bootloader crashes out.

Yet this code snippit works fine:

Code: Select all

  } else if(command.startsWith("outdoorTemp=")) {
    String buffer = command.substring(12);
    int tt = stringToNumber(buffer);
    outdoorTemp = tt;
    outdoorTempTime = now.secondstime() + 900;
    updateOutdoor();
  }
And here is the function being called:

Code: Select all

void updateOutdoor() {
  if(initialized) {
    GLCD.DrawBitmap(GoL, 5, 43, BLACK);
    GLCD.SelectFont(System5x7);
    GLCD.GotoXY(22, 43);
    if(golState) {
      GLCD.Puts("On ");
    } else {
      GLCD.Puts("Off");
    }
    GLCD.GotoXY(52, 43);
    GLCD.Puts("Outside ");
    if(outdoorTemp == 127) {
      GLCD.Puts("??\\");
    } else {
      GLCD.PrintNumber(outdoorTemp);
      GLCD.Puts("\\");
    }
  }
}
The function does work fine, everything works as expected when the function is called from the second code snippit above. It's just the first code snippit, that is causing this massive failure.

I've tested this on two Arduino Megas and verified that both Megas work just fine with other sketches, and this sketch works fine with that one line commented. If i uncomment the line however, then boom the sketch compiles but the upload fails.

The exact failure, as best I can see, is that partway through loading the sketch, the bootloader on the Arduino Mega is dropping into serial monitor mode, then the monitor gets confused by avrdude which is still trying to send the compiled sketch. So the arduino keeps responding over and over "Arduino Bootloader. Huh?" and avrdude keeps trying, and the two end up hung and I have to force-quit avrdude.

Any suggestions would be most appreciated!

davidbuzz
 
Posts: 2
Joined: Fri Nov 25, 2011 2:40 am

Re: Bug in Sketch crashes Avrdude?

Post by davidbuzz »

I was ( today) working on a large arduino application, and I had the exact same symptoms as you. ( see below )

The essence of the problem is: a specific sketch will not upload, most shetches upload fine, problem occurs across multiple pieces of hardware, when uploading with [Shift]->upload you see debug messages that imclude the 'Bootloader' being confused.

My solution: I found that a specific fprintf statement containing THREE consecutive exclaimation marks would no longer cause the problem if I only had two.

DO NOT PUT THIS IN YOUR SKETCHES!!! :

!!!

Booloader..Huh?


avrdude: Recv: B [42]
avrdude: Recv: o [6f]
avrdude: Recv: o [6f]
avrdude: Recv: t [74]
avrdude: Recv: l [6c]
avrdude: Recv: o [6f]
avrdude: Recv: a [61]
avrdude: Recv: d [64]
avrdude: Recv: e [65]
avrdude: Recv: r [72]
avrdude: Recv: > [3e]
avrdude: Recv: 3 [33]
avrdude: Recv: [20]
avrdude: Recv: H [48]
avrdude: Recv: u [75]
avrdude: Recv: h [68]
avrdude: Recv: ? [3f]
avrdude: Recv: . [0d]
avrdude: Recv: . [0a]

davidbuzz
 
Posts: 2
Joined: Fri Nov 25, 2011 2:40 am

Re: Bug in Sketch crashes Avrdude?

Post by davidbuzz »

turns out its a "known bug", which only affects 2560 chips, and has been fixed for some.

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

here's a description of what the !!! actually does for you:
http://www.avr-developers.com/bootloaderdocs/index.html

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”