How big is the code?

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

This is a total noob's question and I feel bad that I have to ask. I have studied the available documentation and have played around with WinAVR for nearly a year now, and I still don't know how large the program is until the object file gets too large to fit in the device I'm trying to use.

So...for AVR's, this is a critical parameter, and I am sure its right in front of my nose - but where do I look to see the size of the program?

Again, I knoe that I should have seen this in the documentation. I waited nearly a year to ask.

--
"Why am I so soft in the middle when the rest of my life is so hard?"
-Paul Simon

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
C:\WinAVR-20070525\bin>avr-size -C idn2.elf
AVR Memory Usage
----------------
Device: Unknown

Program:   35720 bytes
(.text + .data + .bootloader)

Data:      37582 bytes
(.data + .bss + .noinit)

EEPROM:      189 bytes
(.eeprom)

and of course:

 avr-size --help 

Using the --mcu= option allows you to see percentages of memory usage if you are using avr-size from the winavr distribution.

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

farang wrote:
So...for AVR's, this is a critical parameter, and I am sure its right in front of my nose - but where do I look to see the size of the program?

Again, I knoe that I should have seen this in the documentation. I waited nearly a year to ask.


WinAVR comes with a standardized makefile that issues the command to tell you this on every build. The command you need is
avr-size -A 

--Mike

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

avr-size program

Are you using WinAVR? If so, then the avr-size program has been patched to output an AVR-specific report on size. avr-size -C -mcu=

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

Thank you for your replies. I feel pretty thick-headed right now because I don't understand what any of the above means :-(

I tried typing "avr-size -A
" into makefile, but I can't see any effect. Or was I supposed to type this into a command line?

Yes, I am using WinAVR. The following comes up at the end of the compilation process. It doesn't look like the code size to me, but is it?

Thank you in advance for any help.

Size after:
8515play.elf :
section size addr
.text 626 0
.bss 34 8388704
.stab 888 0
.stabstr 113 0
.debug_aranges 32 0
.debug_pubnames 106 0
.debug_info 288 0
.debug_abbrev 185 0
.debug_line 680 0
.debug_frame 96 0
.debug_str 174 0
Total 3222

--
"Why am I so soft in the middle when the rest of my life is so hard?"
-Paul Simon

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

The avr-libc manual is always a good point to start.

Regards
Sebastian

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

farang wrote:
It doesn't look like the code size to me, but is it?

Size after:
8515play.elf :
section size addr
.text 626 0
.bss 34 8388704
.stab 888 0
.stabstr 113 0
.debug_aranges 32 0
.debug_pubnames 106 0
.debug_info 288 0
.debug_abbrev 185 0
.debug_line 680 0
.debug_frame 96 0
.debug_str 174 0
Total 3222


Well it's true that is not as easy to read as the avr-size -C style output that Brian showed above but note in his output example how it determines the code usage simply by adding .text+.data+.bootloader? There's nothing to stop you doing the same manually with this output. As there is no .data or .bootloader it means your code size is 626 bytes.

Similarly for RAM usage Brian's display shows that avr-size -C does this by adding .data+.bss+.noinit - well in your case there only is memory used for .bss - so you are using 34 bytes of RAM

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

clawson, Thank you. I didn't have any idea what these things were, though I noticed that ".text" seemed to vary with code size.

S-Sohn Thank you for showing me the page. I had been through the document, but these terms did not register.

Thanks to you both! :D

--
"Why am I so soft in the middle when the rest of my life is so hard?"
-Paul Simon

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

You may also want to consult the .map file from time to time and "avr-nm -g -S --size-sort ..." can be useful