Really weird problem with Arduino Uno R3

Hello,

I'm facing a really strange issue with my project:

  • On Arduino MEGA: it works fine
  • On Arduino UNO: since some days, the board seems to reboot continuously when one specific line of code is not commented
  • When I try to isolate the code that is causing the error into another project, the code works fine...

The statement causing the error is in the file Serial.ino (WaveRiderLite.zip), line 122:

strcpy(commandParameterValue[0], pos9 + 1);

Where:

  • char commandParameterValue[5][200];
  • char * pos9;

I really don't understand what I am missing, since it works on another board... The most strange thing is that the program does not enter into the function serialParse() until a command has been sent through the serial port...

The possible explanations I find are:

  • the memory is corrupted somewhere and the size of my code is now big enough to crash the board
  • The binary is too big and overlaps the bootloader: not possible since my compiled code is only 5.706 bytes

Did you already have the same issue?

Thanks for your help
Serge

PS: only 1 Arduino board is needed; no wiring, no other shield.

WaveRideLite.zip (6.55 KB)

BigOnArduinoUno.zip (1.98 KB)

Most really weird problems with code that crashes after a while on an UNO but runs on a Mega for a long while is SRAM related; what is called memory leakage.

Read here: Arduino Playground - AvailableMemory

I had a look at the BigOnArduinoUno sketch, looks like SRAM is overallocated (2K on an Uno):

#define SERIAL_BUFFER_SIZE    255
char serialBuffer[SERIAL_BUFFER_SIZE + 1] = {"value=2^"};   //256 bytes
char commandParameterName[5][20];                           //100 bytes
char commandParameterValue[5][200];                         //1000 bytes
char commandResult[SERIAL_BUFFER_SIZE + 1];                 //256 bytes

Over 1600 bytes just in those four declarations. The core plus things like Serial need a couple hundred bytes, so it's looking pretty tight.

Hello Jack,

Thanks for your answer! I did not pay any attention to the SRAM size...

Bye
Serge