I am using a Mega2560 with ERW 1.0.1f. My sketch is approx 51k, SRAM used approx.3.5k. In order to save SRAM I am using extensively sprintf_P and Serial.print(F(. It seems that my sketch has now grown to a size that the compiler/linker cannot longer handle it. Whenever I add code, I get the following error:
c:/program files (x86)/arduino/arduino erw 1.0.1f/hardware/tools/avr/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/avr6/crtm2560.o: In function __vector_default': (.vectors+0x88): relocation truncated to fit: R_AVR_13_PCREL against symbol __vector_34' defined in .text section in c:/program files (x86)/arduino/arduino erw 1.0.1f/hardware/tools/avr/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/avr6/crtm2560.o
In order to work around this error I am converting sprintf_P into sprintf and Serial.print(F( in ordinary Serial.print(). The downside is that my SRAM usage is growing. Furthermore this work-around isn't very successful in the long term as I will long have run out of SRAM before I have used up a more significant share of the program memory.
I have seen similar error messages reported with the other boards. I have also seen the recommendation to use the latest WINAVR /avrdude.conf (I tried this and it made no difference)
Does somebody know how I can overcome this restriction? Thanks in advance for any assistance.
There is no difference between using the standard IDE and the "enhanced". In actual fact, but I might not have observed that correctly, the standard IDE started to show this error a little earlier (meaning when my sketch was slightly smaller. In other words, when the error first appeared and I realised that replacing PSTR based commands into SRAM based onces, I checked with the normal IDE. The error appeared- and I think it did even with the version I had just "repaired" to work with the enhanced version. In any case, the error is with both.
I have the Same problem. It occurs if I make some innocent modifications in my code, for example if I replace some text like...
prog_char PROGMEM Cmd_073[]="HTTPServerPort";
..in..
prog_char PROGMEM Cmd_073[]="PortInput";
The following error occures:
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+0x7c): relocation truncated to fit: R_AVR_13_PCREL against symbol __vector_31' defined in .text section in c:/program files (x86)/arduino-1.0.1/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr6/crtm2560.o
My code is only 77Kbyte.
Arduino version=1.0.1, Windows-7, Board=ATMega2560
Paul_Tonkes:
I have the Same problem. It occurs if I make some innocent modifications in my code, for example if I replace some text like...
prog_char PROGMEM Cmd_073[]="HTTPServerPort";
..in..
prog_char PROGMEM Cmd_073[]="PortInput";
The following error occures:
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+0x7c): relocation truncated to fit: R_AVR_13_PCREL against symbol __vector_31' defined in .text section in c:/program files (x86)/arduino-1.0.1/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr6/crtm2560.o
My code is only 77Kbyte.
Arduino version=1.0.1, Windows-7, Board=ATMega2560
This was similar to the problem/solution I found. Once I located the offending line, I changed the length of the string and it compiled. (note: I hate this type of fix!)
if (prefs.get("build.mcu").equals("atmega2560"))
optRelax = ",--relax";
This solved this problem:
c:/users/gregor/desktop/arduino/arduino-1.5.4-r2-windows/arduino-1.5.4/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr6/crtm2560.o: In function `__vector_default':
(.vectors+0x28): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_10' defined in .text section in c:/users/gregor/desktop/arduino/arduino-1.5.4-r2-windows/arduino-1.5.4/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr6/crtm2560.o