Compiler options

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

after I compile my project I get the message below. Which of these lines must I watch when I try to make it fit in a 4kB MCU (mega48)?

Is there debug information compiled into my .hex file? How do I optimize the code for raw size? Which compiler options are recomended?

Greetings,
Børge

Size after:
main.elf :
section size addr
.data 6 8388864
.text 4196 0
.bss 46 8388870
.noinit 0 8388916
.eeprom 0 8454144
.debug_aranges 100 0
.debug_pubnames 1287 0
.debug_info 4099 0
.debug_abbrev 1396 0
.debug_line 4675 0
.debug_str 1051 0
Total 16856

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ya, that's something I would like to know aswell. What parts of the comilation can be left out. And how does one go about writing custom startup code

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The Flash memory of your AVR will be composed of the .text and .data sections. The RAM memory of your AVR will be composed of the .data, .bss and .noinit sections. The EEPROM memory of your AVR will be composed of the .eeprom section.

(The above statements are true for most cases where a "generic" configuration is used. But your individual choice of linker configuration and the addition of extra memory sections could change the composition of the various memory types.)

Debug information is stripped out of the binary before it is stored in the HEX file.

If you're using the default Makefile that comes with the latest release of WinAVR, then a summary is listed which makes memory usage clearer. It will look something like:

AVR Memory Usage:
-----------------
Device: atmega128

Program:  114950 bytes (87.7% Full)
(.text + .data + .bootloader)

Data:       2651 bytes (64.7% Full)
(.data + .bss + .noinit)

EEPROM:     1315 bytes (32.1% Full)
(.eeprom)

Using the optimization option "-Os" seems to produce the best balance of code size and execution time in most cases. However, each user is encouraged to try using each of the possible optimization levels to see which option produces the best result.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks a lot for pointing me to that makefile!

I got more warnings and a better memory report now. But with the atmega48 being a 4kB device, isn't this wrong:

AVR Memory Usage:
-----------------
Device: atmega48

Program:    3980 bytes (48.6% Full)
(.text + .data + .bootloader)

Data:         52 bytes (10.2% Full)
(.data + .bss + .noinit)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you guys have a look at this "sticky" article in the forum?

https://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=27164

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Jörg!

The report makes a lot more sense now

Børge

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Question:

Does the latest WinAVR release no longer report this summary information:

AVR Memory Usage: 
----------------- 
Device: atmega48 

Program:    3980 bytes (48.6% Full) 
(.text + .data + .bootloader) 

Data:         52 bytes (10.2% Full) 
(.data + .bss + .noinit) 

This was a very old thread I located... but I can't seem to get that to display at the end of compiling.

James

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You will need to update your makefile - base it off the example makefiel which comes with the latest WinAVR. The size reporting system was moved from one tool to another, and so the updated makefile is required to invoke the right tool with the right command line options to show the size report.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dean,

I've done that & just get a summary report that looks like this:

Size after:
main.elf  :
section            size      addr
.data               778   8388864
.text             25680         0
.bss                973   8389642
.noinit               0   8390615
.eeprom              84   8454144
.stab              1032         0
.stabstr            132         0
.debug_aranges       60         0
.debug_pubnames    5272         0
.debug_info        7900         0
.debug_abbrev       797         0
.debug_line        6574         0
.debug_str         4590         0
Total             53872

Is there anything else you need to do to get that combined breakdown view with percentage use and all? I've downloaded the latest WinAVR released 4/21/2006, and have tried using the default makefiles in both the "sample" directory and the "mfile" directory.

If I un-install WinVAR 4/21/06 and re-install WinAVR 1/25/06 I get this...

Size after:
AVR Memory Usage
----------------
Device: atmega128

Program:   26526 bytes (20.2% Full)
(.text + .data + .bootloader)

Data:       1751 bytes (42.7% Full)
(.data + .bss + .noinit)

EEPROM:       84 bytes (2.1% Full)
(.eeprom)

Thanks,
James

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0