Pages: [1] 2 3   Go Down
Author Topic: Solution to PCREL error for avr25/ATTiny84/ATTiny85/ATTiny88.  (Read 12534 times)
0 Members and 1 Guest are viewing this topic.
Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1726
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So yeah, I have been trying to compile programs for an attiny84, and low and behold if the sketch is over 4kB, the mysterious PCREL error shows its ugly head.

Example Error:
Quote
arduino-1.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 /arduino-1.0.1/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr25\libgcc.a(_exit.o)
Notice the 'avr25' bit in the error above. This relates to the vast majority of the attiny series that are commonly used for arduino.

The issue was fixed as of WinAVR 20090313, but nobody at Arduino have decided including the latest version is sensible, so we are stuck at 20081205. So how to make it work?

I saw one solution which was to download and extract the latest version, and then have two folders, one for each, swapping back and forth if necessary. I didn't like that idea, so I decided to figure out exactly what files from the 2009 version are needed, and guess what, there is only 1!

I have attached a zip file which works for the file structure in windows. If you have this issue, you can just copy the 'hardware' folder inside the zip file into the arduino directory and it will replace the one file (ld.exe).
The fix doesn't affect the rest of the IDE, the newer version of ld.exe appears to compile programs the same way as the older one. As far as I can tell from the documentation, the PCREL patch was the only one applyed to the file between the two versions.

For MacOS, see Reply #4 to this thread to see how to apply the patch

EDIT:
Both ZIP files contain the same patch, but some people seem to be having trouble downloading the first one, i think because there are spaces in the name, so I have posted it again with a different name

The cure fixes both AtTiny85 and AtTiny84, as well as other avr25 MCUs.

* tiny8x pcrel patch.zip (336.16 KB - downloaded 335 times.)
* tinyPCRELpatch.zip (336.16 KB - downloaded 456 times.)
« Last Edit: January 11, 2013, 04:20:26 am by Tom Carpenter » Logged

~Tom~

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 208
Posts: 12936
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I didn't like that idea,

Why not?
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1726
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It just seemed like a pain having to switch between the two. Plus is is 112MB of additional files on the computer when really only on 40kB one is needed.
Logged

~Tom~

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 208
Posts: 12936
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


I've used the latest WinAVR for years without any problems.  You don't have to switch; just delete the old toolset.

In either case, I appreciate the work you've done.
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1726
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The following is how to apply the fix for MacOSX. This is based of AVR crosspack 20090319.

Extract ld.zip. This should give you a single extensionless file "ld".

Right-Click on Arduino.app
Click "Show Package Contents"
Due to MacOSx inability to merge folders, you will have to navigate to the correct folder yourself:
/Contents/Resources/Java/hardware/tools/avr/avr/bin/

Copy and replace "ld" with the version from the zip archive.

The zip is attached to this post.
(Known to work on:
-Snow Leopard
- Mountain Lion
for other versions, please let me know if it works ok)

* ld.zip (707.67 KB - downloaded 206 times.)
« Last Edit: August 31, 2012, 06:41:54 pm by Tom Carpenter » Logged

~Tom~

Offline Offline
Jr. Member
**
Karma: 1
Posts: 69
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Tom you are awesome!

I've been trying to resolve that issue on-and-off for about 2 months now and your insanely simple fix worked perfectly. Arduino needs to take care of that!

Thanks so much!
Logged

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

I too have been having to work around this issue for months on the Mac side (I've been using Windows for >4K programs) this worked perfectly on Mountain Lion. Thanks for your efforts here.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

it works. thank you.
Logged

0
Offline Offline
Full Member
***
Karma: 2
Posts: 125
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you Tom Carpenter. This was an easy fix for my >4k sketch.
Logged

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

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. 

I tried replacing 'ld.exe' from your zip file, but it did not solve my problem.  Any suggestions?
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1726
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The problem this thread covers only applies to ATTiny's. Atmega328s are a totally different breed of avr.

The issue you are facing is not due to the compiler, so you should start a new thread asking for help.
Logged

~Tom~

Czech Republic
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you very much, you saved my day  smiley

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!
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 146
Posts: 5532
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Madison, WI
Offline Offline
Newbie
*
Karma: 0
Posts: 25
No loafing.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
:/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
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 209
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
Code:
/*
    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.
Code:
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
Logged

Pages: [1] 2 3   Go Up
Jump to: