Pages: [1]   Go Down
Author Topic: Bug in Arduino v1.0.1?  (Read 2563 times)
0 Members and 1 Guest are viewing this topic.
Maryland, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When I try to compile a sketch I have written, I get the following error message:

Error compiling.
c:/program files (x86)/arduino-1.0.1/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr6/crtm2560.o: In function `__vector_default': (.vectors+0xd8): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_54' defined in .text.__vector_54 section in core.a(HardwareSerial.cpp.o)


The code I am using contains the following function definition which is where the error is coming from:

Quote
boolean parseDelay(String str){
  ...
  byte fractions[3] = {48,48,48};
  ...  
  temp.getBytes(fractions,3);
  ...
  for(int i = 0; i < 2; i++){
    if(fractions < 48 || fractions > 57){
      Serial.println("4");
      return(false);
    }
    else {
      fractions -+ 48;
    }
  }
  ...
  temp2 = 10*fractions[0] + fractions[1];
  if(temp2 >15){
    return(false);
  }
  nextEventDelay += temp2;
  ...
}


I am pretty sure this is a bug and not just an error on my part because if I change the length of the fractions array to either 2 or 4 I get no error, and the sketch compiles properly.

I don't know enough to interpret the error message, and haven't found anything in the forum that mentions it, so I thought I would bring it up here.

Has anyone else seen this type of error?
Logged

Maryland, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In trying to debug my code, I came across the same error again. This time, with the functions array length at 4, I get the error message, but if I add in a line somewhere that writes a value to the serial monitor, or if I change the array length back to 3, the error goes away again.

Now I'm very confused.
Logged

Maryland, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oops!

So obviously I forgot my indices on the functions array, and -+ means nothing, so now it is fixed. If I get the error again when my code is free of such bugs, I will re-post.
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The problem seems to be more than a wrong error message because of a syntax error. I got the same error message during development. So far I've no clue where it comes from and this makes me nerveous. By comparison of a still well compiling and working revision of my project and one which produces this error message I found out that -- in my case -- it depends on the compiler settings. If the only change of -O1 into -Os (optimzation level one to optimization for minimum code size) the project runs and compiles well.

I use a makefile project, where the settings for compiler and linker and the set of compiled C files are taken one by one from the Arduino 1.0.1 IDE (command lines copied from the IDE's output window). My only modifications are enabling of some more output files (linker map file, assembler listings) and adding some more include folders. And for some reasons I tried different optimization levels (resulting in -O1 which made compilation fail).

The code size of the well working compilation with -Os is about 6 or 7 kByte (the value shown by avrdude at download) thus far below the absolute code size maximum of my ATmega2560. There seems to be a more  tricky problem with the linker. Is there a specific section, which must not grow beyond e.g. 8k or something like this?

By the way, getting thisproblem, I wondered in which way the linker would report section exceeded problems and purposely declared a much too large array in RAM, which definitely doesn't fit into my RAM. And got no problem indication from the linker at all! Is it really possible that it doesn't keep track of memory overflow?

Regards,
Peter
Logged

Pages: [1]   Go Up
Jump to: