Solution to PCREL error for avr25/ATTiny84/ATTiny85/ATTiny88.

Thank you very much, you saved my day :slight_smile:

I was debuging to very core of my project and I found the size limit, I used some hack I did know,
but then I found your solution - wow, how easy the world sometimes is. Thank you!

samv6271:
Hey Tom,

I'm having this same problem using the Arduino Uno Rev 3. It's advertised to allow me 32kB of memory, but when I exceed ~14kB it won't work. Nothing throws an error message, but the code won't work.

I procrastinated the problem by storing a large array in the PROGMEM, which allowed me to build up to 19kB successfully, but I can add no more without inciting a crash. However, I've reached that wall again.

You're running out of RAM. It's nothing to do with the program size or the compiler.

Thanks for this, it always astounds me when I'm having problems with Arduino/AVR related issues, I can cut and paste something like:

:/program files/arduino-
.0.1/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn85.o:(.init9+0x2): relocation truncated to fit: R_AVR_13_PCREL against symbol `exit' defined in .fini9 section in c:/program files/arduino-1.0.1/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr25\libgcc.a(_exit.o)

Into google and find an answer. Thanks much.

-tweedius

Hi all. Fist let me say I am very new to all this so If I am asking a dumb question forgive me.

I have been trying all day to program an atTiny84 with a 3x3 LED cube sketch i found, an I am having no luck. I have a post in the forum and some one was kind enough to send me a link to this post.

This is the sketch I am trying to use:

/*
    ledcube.pde - Example sketch for controlling an LED cube.
    Created by Gamaiel Zavala (gzip), 2009-2012
    MIT License. See accompanying LICENSE file for terms.
*/

#include <LedCube.h>

#define SIZE 3
#define COLS (SIZE*SIZE)

byte levelPins[SIZE] = {2,3,4};
byte colPins[COLS] = {0,1,5,6,7,8,9,10};

LedCube cube(SIZE, levelPins, colPins);

void setup ()
{
}

void loop ()
{
    delay(10);
    
    // light each light one at a time
    for(byte level=0; level<cube.getLevels(); level++)
    {
        for(byte col=0; col<cube.getCols(); col++)
        {
            cube.lightPulse(level, col, 100);
        }
    }
    
    // light one level at a time, increasing speed each time
    for(byte d=25; d>2; d-=2)
    {
        for(byte l=1; l <= cube.getLevels(); l++)
        {
            cube.lightLevel(l, d);
        }
    }
    
    // light each row on each level
    for(byte level=1; level<=cube.getLevels(); level++)
    {
        for(byte row=1; row<=cube.getLevels()*2; row++)
        {
            cube.lightRow(row, level);
        }
    }
    
    // light each plane
    for(byte i=3; i; i--)
    {
        for(byte row=1; row<=cube.getLevels()*2; row++)
        {
            cube.lightPlane(row, 10*i);
        }
    }
    
    // single random light at a time
    cube.randomLight(random(25,100),100);
    
    // random column drop
    for(byte x=0; x<=15; x++)
    {
        cube.lightDrop(random(0,cube.getCols()), random(50,150));
    }
    
    // circle around cube at a random level
    for(byte x=0; x<=5; x++)
    {
        cube.lightPerimeter(random(0,cube.getLevels()), random(1,5), random(25,100));
    }
    
    // light each face
    byte planes[] = {cube.getLevels()+1,cube.getLevels(),cube.getLevels()*2,1};
    for(byte i=5; i; i--)
    {
        for(byte p=0; p<sizeof(planes); p++)
        {
            cube.lightPlane(planes[p], 5*i);
        }
    }
    
    // random columns
    cube.randomColumn(25);
    
    // turn off a single column randomly
    cube.enableBuffer();
    for(byte c=0; c<30; c++)
    {
        cube.fillBuffer();
        cube.invertBuffer();
        cube.randomColumn();
        cube.drawBuffer(7);
    }
    cube.enableBuffer(false);
    
    // cols in and out
    for(byte c=1, d=0; c<=10; c++)
    {
        if(c%2 == 0)
        {
            for(d=0; d<20; d++)
            {
                cube.lightColumn(2,1);
                cube.lightColumn(4,1);
                cube.lightColumn(6,1);
                cube.lightColumn(8,1);
            }
        }
        else if(c%4 == 1)
        {
            for(d=0; d<30; d++)
            {
                cube.lightColumn(1,1);
                cube.lightColumn(3,1);
                cube.lightColumn(7,1);
                cube.lightColumn(9,1);
            }
        }
        else
        {
            for(d=0; d<70; d++)
            {
                cube.lightColumn(5,1);
            }
        }
    }
    
    // diamond and box
    byte diamond[] = {0,4,  1,1, 1,3, 1,4, 1,5, 1,7,   2,4};
    byte box[] = {
        2,0, 2,1, 2,2, 2,3, 2,5, 2,6, 2,7, 2,8,
        1,0, 1,2, 1,6, 1,8,
        0,0, 0,1, 0,2, 0,3, 0,5, 0,6, 0,7, 0,8
    };
    cube.lightSequence(box, sizeof(box), 200);
    cube.lightSequence(diamond, sizeof(diamond), 400);
    
    // helicopter effect
    byte topSeq[8] = {0,3,6,7,8,5,2,1};
    byte botSeq[8] = {8,5,2,1,0,3,6,7};
    for(byte loops = 0, delay = 50; loops<=8; loops++)
    {
        for(byte s=0; s<8; s++)
        {
            byte seq[] = {2,topSeq[s], 1,4, 0,botSeq[s]};
            cube.lightSequence(seq, sizeof(seq), delay);
        } 
        if(loops < 5) delay-=10;  else delay += 10;
    }
    
    // turn off one light at a time
    cube.enableBuffer();
    cube.fillBuffer();
    cube.drawBuffer(25);
    for(byte w=0, l, c, max = cube.getNumLights(); w<max; )
    {
        // lower bound is inclusive, upper is exclusive
        l = random(0, cube.getLevels());
        c = random(0, cube.getCols());
        
        if(cube.getBufferAt(l,c) == HIGH)
        {
            cube.lightOff(l,c);
            cube.drawBuffer(5);
            w++;
        }
    }
    cube.enableBuffer(false);
}

And this is the Error I get.

c:/arduino-1.0.1/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn84.o: In function `__vector_default':
(.vectors+0x16): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_11' defined in .text.__vector_11 section in core.a(wiring.c.o)
c:/arduino-1.0.1/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn84.o:(.init9+0x0): relocation truncated to fit: R_AVR_13_PCREL against symbol `main' defined in .text.main section in core.a(main.cpp.o)
c:/arduino-1.0.1/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn84.o:(.init9+0x2): relocation truncated to fit: R_AVR_13_PCREL against symbol `exit' defined in .fini9 section in c:/arduino-1.0.1/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr25\libgcc.a(_exit.o)
core.a(WMath.cpp.o): In function `randomSeed(unsigned int)':
C:\Users\techsupport\Documents\Arduino\hardware\tiny\cores\tiny/WMath.cpp:33: relocation truncated to fit: R_AVR_13_PCREL against symbol `srandom' defined in .text section in c:/arduino-1.0.1/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25\libc.a(random.o)

I downloaded the zip file form this post and copied it to my hardware folder but still no luck.

Help. It's driving me mad.

Thanks

Download WinAVR here, extract the files (it's a zip file)

a) Find the "bin" folder in the extracted files.

b) Find a similar looking folder in your Arduino installation.

Copy all files from (a) to (b).

have you restarted the IDE?

Double check you put the ld file in this folder:
"\hardware\tools\avr\avr\bin"

Did you extract the ZIP file?

Did you definitely get the Windows version (not the Mac version by accident)?

This fix definitely applies to your problem, and should work.

@fungus, you don't need the whole folder, just the ld file.

True, but why not have the latest compiler, etc., as well?

fungus:
Download WinAVR here, extract the files (it's a zip file)

WinAVR download | SourceForge.net

a) Find the "bin" folder in the extracted files.

b) Find a similar looking folder in your Arduino installation.

Copy all files from (a) to (b).

The only BIN folder I find in the Arduino-1.0.3 dir is in the java folder. is that it?

kculm:
The only BIN folder I find in the Arduino-1.0.3 dir is in the java folder. is that it?

No. You want a folder with the same files in it as winavr's 'bin'.

Mine is: ./arduino-1.0.1/hardware/tools/avr/bin

fungus:

kculm:
The only BIN folder I find in the Arduino-1.0.3 dir is in the java folder. is that it?

No. You want a folder with the same files in it as winavr's 'bin'.

Mine is: ./arduino-1.0.1/hardware/tools/avr/bin

Yep, found it. I was looking in the wrong place. It looks like it works now. Thanks everyone's help.

Worked for me.
Thank you very much.

Cheers Tom. A nice quick fix!

Thank you, thank you, thank you, Tom. The Id patch worked perfectly with Arduino 1.0.4 on Mac os X 10.6.8. Now I can program my attiny85!

Mario

Dear Tom

I'm having the same problems at everybody in this thread but your fix unfortunately hasn't helped. I'm using Arduino Uno and ATtiny85. Here's my error:

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe: inf_mirror.cpp.elf section .text will not fit in region text
c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe: region text overflowed by 4440 bytes
c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn85.o: In function `__vector_default':
(.vectors+0x8): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_4' defined in .text.__vector_4 section in core.a(wiring.c.o)
c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn85.o:(.init9+0x0): relocation truncated to fit: R_AVR_13_PCREL against symbol `main' defined in .text.main section in core.a(main.cpp.o)
c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn85.o:(.init9+0x2): relocation truncated to fit: R_AVR_13_PCREL against symbol `exit' defined in .fini9 section in c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr25\libgcc.a(_exit.o)
inf_mirror.cpp.o: In function `__static_initialization_and_destruction_0':
C:\Program Files (x86)\Arduino/inf_mirror.ino:21: relocation truncated to fit: R_AVR_13_PCREL against symbol `Potentiometer::Potentiometer(unsigned char)' defined in .text._ZN13PotentiometerC1Eh section in Potentiometer\Potentiometer.cpp.o
C:\Program Files (x86)\Arduino/inf_mirror.ino:22: relocation truncated to fit: R_AVR_13_PCREL against symbol `Potentiometer::Potentiometer(unsigned char)' defined in .text._ZN13PotentiometerC1Eh section in Potentiometer\Potentiometer.cpp.o
inf_mirror.cpp.o: In function `AllOn()':
C:\Program Files (x86)\Arduino/inf_mirror.ino:1077: relocation truncated to fit: R_AVR_13_PCREL against symbol `digitalWrite' defined in .text.digitalWrite section in core.a(wiring_digital.c.o)
C:\Program Files (x86)\Arduino/inf_mirror.ino:1078: relocation truncated to fit: R_AVR_13_PCREL against symbol `shiftOut' defined in .text.shiftOut section in core.a(wiring_shift.c.o)
C:\Program Files (x86)\Arduino/inf_mirror.ino:1079: relocation truncated to fit: R_AVR_13_PCREL against symbol `shiftOut' defined in .text.shiftOut section in core.a(wiring_shift.c.o)
C:\Program Files (x86)\Arduino/inf_mirror.ino:1080: relocation truncated to fit: R_AVR_13_PCREL against symbol `digitalWrite' defined in .text.digitalWrite section in core.a(wiring_digital.c.o)
C:\Program Files (x86)\Arduino/inf_mirror.ino:1081: relocation truncated to fit: R_AVR_13_PCREL against symbol `delay' defined in .text.delay section in core.a(wiring.c.o)
inf_mirror.cpp.o: In function `Checker()':
C:\Program Files (x86)\Arduino/inf_mirror.ino:47: additional relocation overflows omitted from the output

Here's what I've done to try to fix it:

  1. Followed every step in Tiny85 PCREL error - #2 by Coding_Badly - Microcontrollers - Arduino Forum (I didn't have WinAVR previously so didn't have to replace anything, there was no tools folder)
  2. Downloaded the patch and replaced the ld.exe file in the hardware/tools/avr/avr/bin folder with the one from the patch zip

I definitely got the Windows version, not the Mac one.
I have restarted the IDE.

Let me know if I should post anything else, like my code (really long and essentially irrelevant to this problem if I understand correctly) or boards.txt. Thanks a bunch!

Does anybody have any tips for me? I'm making a birthday present for my little nephew for his party tomorrow and I'll be in quite a pickle if I can't get this sorted. Any help would be greatly appreciated!

icegooner:

  1. Followed every step in Tiny85 PCREL error - #2 by Coding_Badly - Microcontrollers - Arduino Forum (I didn't have WinAVR previously so didn't have to replace anything, there was no tools folder)

If you don't have WinAVR installed, how could you follow every step?

Navigate to this directory...
C:\Program Files (x86)\Arduino\hardware\tools\avr\avr\bin\

Is there a file named ld.exe in that directory?

Is the file dated 12/04/2008 or 3/14/2009?

I just set up Arduino IDE and did everything again according to instructions on a new computer (and there was stuff different between this and the one from before, like when I installed Arduino IDE on the previous one there was no tools directory, but now there was). And the ld.exe file was dated 03/14/2009.

Anyway, I've done everything and things are looking up, but there still one error (related to ld.exe).

e:/arduino in/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe: infmirror.cpp.elf section .text will not fit in region text
e:/arduino in/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe: region text overflowed by 4440 bytes

I've replaced the old ld.exe (dated 12/04/2008) with the one from the patch (dated 3/14/2009) but now this is the only error I get. Any ideas? :slight_smile:

EDIT: I've just discovered that now I'm just being dumb and I've exceded the ATtiny capacity... :stuck_out_tongue: So I'm all good now, I'll just have to try to shorten the code before the big birthday tomorrow. Thanks a bunch Coding Badly!

You are welcome. I'm glad you are back on track.

Thank you Tom !
My code is compiled perfectly on Attiny85 now !