Pages: 1 [2]   Go Down
Author Topic: Eclipse large HEX file size  (Read 7369 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2855
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmm, I don't know exactly what Eclipse is doing but it looks like it is precompiling the entire Arduino library. If so, it's likely compiling in all the floating-point support routines just in case they're needed, whereas the Arduino IDE only compiles in what a particular sketch needs.

--
The Quick Shield: breakout all 28 pins to quick-connect terminals
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That could make sense I'll do some testing around it and will include all files direct into a project w/o using a lib.
Keep you posted about the outcome (after my beauty sleep)
I am still wondering if I am the only guy using Eclipse and sees that something is wrong.
Logged

Portugal
Offline Offline
God Member
*****
Karma: 6
Posts: 962
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Its really touching a lot of files.
Logged

Kentucky, US
Offline Offline
Full Member
***
Karma: 1
Posts: 193
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm seeing the same problem with my shiny new Eclipse/WinAVR installation.  I was going to start a similar thread, and then I saw this one.  I'm anxious to find a solution since I like using the Eclipse environment.

Jim
Logged

TC4 Open Source Digital Thermometer and Temperature Controller
http://code.google.com/p/tc4-shield

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Results of the test:
Included the Arduino lib files into an Eclipse project. Added main.h and main.cpp as above.
Project properties according to the cook book (see post 1)
And voila: the HEX file size increased to 17kB.

I opened a thread in SourceForge to see if they have an idea which switches to set: https://sourceforge.net/projects/avr-eclipse/forums/forum/664382/topic/3844152

In between I tested a good concept idea (but far way to call it beta release) from this gentleman: http://code.google.com/p/avr-project-ide/wiki/Help. Same code, same compilers generate the expected 2.6kB like Arduino IDE.

Keep you posted and still happy for receiving any advice.
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 135
Posts: 6782
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Try adding -ffunction-sections and -fdata-sections to the compile flags.
I think this was the right idea, but there's a match set of options that you need to add to the link command.  Ummm:
"-Wl,--gc-sections"   or "--gc-sections" (depending on whether it uses some version of gcc as the linker command, or uses "ld" directly.)

the quoted compiler options cause each function and piece of data to be put in its own linker section.  The linker option causes any sections that aren't reference from some other section to be omitted.  Or something like that.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks,  case closed  smiley

the a.m. compiler options sorted it out.

Robert
Logged

Kentucky, US
Offline Offline
Full Member
***
Karma: 1
Posts: 193
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Robert -

Can you post the compiler and linker options that finally solved the problem for you?

Thanks.

Jim
Logged

TC4 Open Source Digital Thermometer and Temperature Controller
http://code.google.com/p/tc4-shield

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here are the compiler/linker settings in a nutshell. If that is too short then give a shout:

AVR Compiler
* Debugging:             Generate Debugging Info: No debugging info
* Optimization:       Optimization Level: to Size Optimizations
                              Other Optimization: -ffunction-sections -fdata-sections
* All options:      --I"...\Arduino-0019\hardware\arduino\cores\arduino"
                              -Wall -Os -fpack-struct -fshort-enums -ffunction-sections -fdata-sections
                              -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega328p -DF_CPU=16000000UL
        
AVR C++ Compiler
* Debugging:             Generate Debugging Info: No debugging info.
* Optimization:       Optimization Level: Size Optimizations
                              Other Optimization: -ffunction-sections -fdata-sections
* All options:      -I"...\Arduino-0019\hardware\arduino\cores\arduino"
                              -Wall -Os -fpack-struct -fshort-enums -ffunction-sections -fdata-sections
                              -funsigned-char -funsigned-bitfields -fno-exceptions -mmcu=atmega328p -DF_CPU=16000000UL
              
AVR C++ Linker
* Command:                         avr-gcc
* General:                        Other Arguments: -Wl,--gc-sections
* Command line pattern: ${COMMAND} --cref -s -Os ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} -lm ${FLAGS}
* All options:                  -Wl,-Map,<your *.map file>,--cref -Wl,--gc-sections -L"<your library path>" -mmcu=atmega328p
Logged

Kentucky, US
Offline Offline
Full Member
***
Karma: 1
Posts: 193
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, Robert.  Very much appreciated.  I'll give it a try and see if it also fixes my problem.

Jim
Logged

TC4 Open Source Digital Thermometer and Temperature Controller
http://code.google.com/p/tc4-shield

Kentucky, US
Offline Offline
Full Member
***
Karma: 1
Posts: 193
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Those settings worked for me as well, but....

I also had to compile/archive a new Arduino libcore.a that had the same optimizations (-ffunction-sections -fdata-sections).  After making a new core library using Eclipse/WinAVR, the HEX file from Eclipse for my sample was actually a few bytes smaller than that created using the Arduino IDE.

I will also pass along a particularly helpful (at least with regard to getting the Eclipse command line settings right) feature of the Arduino IDE:  if you hold the shift key while compiling, the IDE will create a command line listing in the console window.  Using this listing you can duplicate the Arduino environment as closely as you'd like in Eclipse.

Jim
« Last Edit: September 13, 2010, 11:54:25 pm by JimG » Logged

TC4 Open Source Digital Thermometer and Temperature Controller
http://code.google.com/p/tc4-shield

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 135
Posts: 6782
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I also had to compile/archive a new Arduino libcore.a that had the same optimizations
yeah; seems that very few "make" based compile environments remember to include the makefile itself in the dependency list for targets (is Eclipse actually Make based?  The principle still holds..)

The Arduino IDE rebuilds everything (libraries) whenever you switch boards, and nearly everything (core) for every build.  This is liable to get annoying as there is more to compile, but at least it's "safe."

You can also set "build.verbose" to true in your arduino preferences file, and you'll see the build command listing in your console window all the time...
Logged

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

Hi all,

I have the similar problem:

I tried to setup eclipse to compile arduino project and it's working, but blink sketch built with eclipse is about 10k... a little too big smiley

I used the core.a from an arduino ide compilation, is it sufficient or do I have to recompile a new one from eclipse with the same configuration ?

Thanks a lot.

Btw, why are you using eclipse ? Apart from code completion ?  smiley
Logged

Pages: 1 [2]   Go Up
Jump to: