Go Down

Topic: Solution to PCREL error for avr25/ATTiny84/ATTiny85/ATTiny88. (Read 13 times) previous topic - next topic

Tom Carpenter

Jul 31, 2012, 03:45 pm Last Edit: Jan 11, 2013, 10:20 am by Tom Carpenter Reason: 1
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.
~Tom~

Coding Badly


Tom Carpenter

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.
~Tom~

Coding Badly


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.

Tom Carpenter

#4
Aug 04, 2012, 12:52 pm Last Edit: Sep 01, 2012, 01:41 am by Tom Carpenter Reason: 1
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)
~Tom~

Go Up