Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MEGA2560 needs --relax option when linking #270

Closed
FredericG-BE opened this issue Jun 3, 2015 · 4 comments
Closed

MEGA2560 needs --relax option when linking #270

FredericG-BE opened this issue Jun 3, 2015 · 4 comments
Labels
importance: board specific OS: all status: Arduino IDE incompatibility Somethig that is not exactly the same as the arduino ide status: fixed in 2.4 status: workaround documented A workaround has been confirmed to solve this issue.

Comments

@FredericG-BE
Copy link

See https://code.google.com/p/arduino/issues/detail?id=729
http://www.atmel.com/webdoc/AVRLibcReferenceManual/FAQ_1faq_funcptr_gt128kib.html

When compiling with Arduino IDE:
C:\ProgramFiles\Arduino\hardware\tools\avr\bin\avr-gcc -Os -Wl,--gc-sections,--relax -mmcu=atmega2560 -o ....

When compiling with Eclipse:
"C:/ProgramFiles/Arduino/hardware/tools/avr/bin/avr-gcc" -Os -Wl,--gc-sections -mmcu=atmega2560 -o ...

I changed the line in platform.txt to
compiler.c.elf.flags=-Os -Wl,--gc-sections,--relax
and all seems fine...

@jantje
Copy link
Member

jantje commented Jun 4, 2015

Wierd. The word "relax" is nowhere found in the platform nor the boards.txt file in arduino ide 1.6.1.
It looks like a hardcoded thing.
Note that your solution is only ok if you actually use a mega. I assume other boards will make bigger elf files with this option.
I guess it is the right time to think about adding an option to extend the linker and archiver command line.
Next to opening an issue at arduino's

@FredericG-BE
Copy link
Author

Indeed, the option that I added to platform.txt is just to keep me going and to demonstrate that it indeed fixes the issue I was facing; removing it and it comes back. I also suspect that this option comes at a price.

@jantje jantje added the status: Arduino IDE incompatibility Somethig that is not exactly the same as the arduino ide label Jun 4, 2015
@jantje
Copy link
Member

jantje commented Jun 27, 2015

I had an issue with a mega and I wanted to be sure it was not related to this --relax option so I thought about a good workaround.
What I did was add these lines to the boards.txt containing the mega.
mega.compiler.c.elf.flags={compiler.warning_flags} -Os -Wl,--gc-sections,--relax
megaADK.compiler.c.elf.flags={compiler.warning_flags} -Os -Wl,--gc-sections,--relax
These lines are ignored by the arduino IDE so it is a safe workaround.

@jantje
Copy link
Member

jantje commented Sep 16, 2015

I build a additional framework in the plugin that allows me to add
mega.compiler.c.elf.flags={compiler.warning_flags} -Os -Wl,--gc-sections,--relax
megaADK.compiler.c.elf.flags={compiler.warning_flags} -Os -Wl,--gc-sections,--relax
in the plugin.
I tested it on my system and it works fine
I'm not sure we will make the framework part of the release @rlogiacco is working on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
importance: board specific OS: all status: Arduino IDE incompatibility Somethig that is not exactly the same as the arduino ide status: fixed in 2.4 status: workaround documented A workaround has been confirmed to solve this issue.
Projects
None yet
Development

No branches or pull requests

2 participants