Goldilocks Arduino Board Profile Problem

An advanced Arduino-compatible board with ATmega1284P and ATmega32u2 MCUs for experienced users. More RAM than a Mega, but in a convenient Uno-style form factor. [Product page]
Post Reply
vicatcu
Posts: 7
Joined: Thu Aug 29, 2013 3:32 pm

Goldilocks Arduino Board Profile Problem

Post by vicatcu » Mon Mar 10, 2014 10:15 pm

Hi @johnb, @jonoxer, @feilipu, and others,

I think we've got a little bug hiding in the Arduino core files somewhere for the Mega1284p. Here's a very simple code snippet that inexplicably crashes within 10 seconds on Goldilocks (as well as my own Mega1284p based board), but which does not crash on an Arduino UNO (or other Mega328p-based board).

Code: Select all

void setup()
{
  // just to be able to monitor what is happening
  Serial.begin(9600);
}

//String dataString;   // defining it here seems to solve the problem
int val = 0;
void loop()
{
  String dataString = "";
  dataString += String(val*70);
  dataString += ",";
  dataString += String(255);
  dataString += ",";
  dataString += String(255);
  Serial.println(dataString);
  delay(250);
  val++;
}
My first thought was it was just a memory leak due to String objects being created and never destroyed in loop, but I was shocked when I was able to consistently reproduce the problem. It happens way too quickly to be attributable to stack overflow, not to mention the fact that it isn't reproducible on Mega328p based boards.

Also, notice that the crash does not happen on Goldilocks (or my board) if the dataString variable is declared globally (outside of the loop function). What do you all think? It is kind of boggling my mind.
Last edited by vicatcu on Tue Mar 18, 2014 2:21 am, edited 1 time in total.

vicatcu
Posts: 7
Joined: Thu Aug 29, 2013 3:32 pm

Re: Goldilocks Arduino Board Profile Problem

Post by vicatcu » Mon Mar 17, 2014 2:09 pm

I'm not crazy, right? Can other people reproduce this?

feilipu
Posts: 52
Joined: Fri Jul 19, 2013 6:17 am

Re: Goldilocks Arduino Board Profile Problem

Post by feilipu » Thu Mar 20, 2014 7:55 pm

Interesting. If so, not surprising.

There are quite a few limitations in Arduino support of 1284p, particularly around Interrupt support, that have been found.

After looking into the Arduino Github code, I realise there is nothing obvious that differentiates across the various MCU types in the String or Print libraries. It could be that something in the interrupt handling for Serial is blowing up, but it is difficult to tell without digging into the intricacies of C++. Out of my league I'm afraid.

Phillip

vicatcu
Posts: 7
Joined: Thu Aug 29, 2013 3:32 pm

Re: Goldilocks Arduino Board Profile Problem

Post by vicatcu » Mon Mar 24, 2014 4:51 pm

@feilipu, thanks for getting back to me, are you able to reproduce the problem?

hiduino
Posts: 12
Joined: Thu Aug 29, 2013 2:17 pm

Re: Goldilocks Arduino Board Profile Problem

Post by hiduino » Fri Jul 04, 2014 1:56 am

This appears to be a problem with the avrgcc code, not the Arduino core files. The Arduino IDE uses WINAVR-2008 which may have some memory leak issues using strings. You can update your Arduino IDE to use WINAVR-2010 (http://sourceforge.net/projects/winavr/files/WinAVR/)or the Atmel AVR Toolchain (http://www.atmel.com/tools/atmelavrtool ... ndows.aspx). You can search the Arduino forums on how to update these to the Arduino IDE.

Post Reply