Size after: does it tell me anything useful?

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

Hi Folks,

I often notice the "Size before:" and "Size after:" outputs when compiling but I have no idea what that stuff is. Does this tell me anything useful? Like how much ram I have available?

example #1:

Size after:
RGB_software_pwm.elf  :
section    size      addr
.text       594         0
.data         4   8388704
.bss          1   8388708
.stab      3096         0
.stabstr   2075         0
Total      5770

example #2:

Size after:
lcd_clock_0.4.elf  :
section     size      addr
.text       5240         0
.data         58   8388704
.bss          27   8388762
.stab      15936         0
.stabstr    6614         0
Total      27875

Thanks!

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

Are you running the latest WinAVR release? If so, you need to update your makefile to the latest revision, so that the properly formatted output is displayed. When working correctly, you should see an output similar to the following:

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

Program:    3166 bytes (2.4% Full)
(.text + .data + .bootloader)

Data:         19 bytes (0.2% Full)
(.data + .bss + .noinit)

Which gives you the FLASH and *global* SRAM usage of your application (Data value does not include the stack and local data usage).

- Dean :twisted:

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

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
$ avr-gcc -v
Using built-in specs.
Target: avr
Configured with: ../src/configure -v --enable-languages=c,c++ --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --disable-libssp --build=i486-linux-gnu --host=i486-linux-gnu --target=avr
Thread model: single
gcc version 4.2.2

Thanks Dean, I'll take a look at getting a new makefile.

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

What you are missing there is the -C option on the invocation of avr-size (along with --mcu=). But the standard avr-size does not have support for -C, it's added by a patch that Eric applies to the version in WinAVR but you could presumably apply this to the avr-size you are using in the Linux environment?

Otherwise just apply those same sums that the -C option would have done:

flash usage = (.text + .data + .bootloader) 
RAM usage = (.data + .bss + .noinit)

Cliff

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

Attached is the WinAVR bitutils patch which enables the new size functionality.

- Dean :twisted:

Attachment(s): 

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

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

Quote:
--host=i486-linux-gnu

This indicates you're using avr-gcc on a Linux computer.

The vanilla version of avr-size which comes with GNU Binutils does not support the -C command line option - it is added by way of a patch that was created specially for WinAVR.

If you installed your toolchain directly from source using Bingo's build scripts, then I think it will have automatically included the avr-size patch. On the other hand, if you installed it using the built-in package management systems of most mainstream Linux distributions, then chances are the patch in question was not included.

You can deduce all the relevant information from avr-size even without that patch, though:

1) Total Flash utilization
Take the sum of the following line items:
.text and .data

2) Total static RAM utilization (everything except for stack and heap usage)
Take the sum of the following line items:
.data and .bss

3) Total EEPROM utilization
The following line item:
.eeprom

For example, with the data you've shown us before:

Size after: 
RGB_software_pwm.elf  : 
section    size      addr 
.text       594         0 
.data         4   8388704 
.bss          1   8388708 
.stab      3096         0 
.stabstr   2075         0 
Total      5770 

The total Flash usage is the sum of .text (594 bytes) and .data (4 bytes): 598 bytes.

The total static RAM usage is the sum of .data (4 bytes) and .bss (1 byte): 5 bytes.

There is no EEPROM usage.

The other sections in your listing (.stab and .stabstr) both contain debugging information only, and have no impact on the final executable size.

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

Ok, thanks for info from all. I have applied the patch that Dean posted to binutils.

I did indeed install the toolchain from the Ubuntu repositories but had no trouble patching and compiling binutils. Instructions to follow for those interested. Does anyone know if this patch has been submitted upstream?

I have not dealt with my own makefile before. I downloaded this one.... somewhere. Any suggestions for acquiring/creating a new one for myself?

Patching binutils on Ubuntu
I'm using kubuntu 8.04 Hardy Heron. I'm not going to "support" these instructions so use at your own risk:

Downlaod binutils source code:

apt-get source binutils

Download the patch dean posted above into the binutils source directory that was just created.

Step into that directory and execute the patch:

cd binutils-2.18.1~cvs20080103/
patch -p0 < 30-binutils-2.18-avr-size.txt

Configure, make and install the package:

./configure
make
sudo make install
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't think that worked.... I've changed this line in my makefile:

ELFSIZE = $(SIZE) -A $(TARGET).elf

to this:

ELFSIZE = $(SIZE) -C $(TARGET).elf

Now when I try to compile I get this message during the size part of the build:

Size after:
avr-size: invalid option -- C
Usage: avr-size [option(s)] [file(s)]
 Displays the sizes of sections inside binary files
 If no input file(s) are specified, a.out is assumed
 The options are:
  -A|-B     --format={sysv|berkeley}  Select output style (default is berkeley)
  -o|-d|-x  --radix={8|10|16}         Display numbers in octal, decimal or hex
  -t        --totals                  Display the total sizes (Berkeley only)
            --common                  Display total size for *COM* syms
            --target=        Set the binary file format
            @                   Read options from 
  -h        --help                    Display this information
  -v        --version                 Display the program's version

avr-size: supported targets: elf32-avr elf32-little elf32-big srec symbolsrec tekhex binary ihex

When I look at my package manager I see that:
binutils = 2.18.1~cvs20080103-0ubuntu1
binutils-avr = 2.18.3

So it looks like I built the binutils package with the patch applied but not the binutils-avr package. When I download the source for binutils-avr it's not a full source... looks like a set of patches that I'm not sure how to use.

Any idea where I'm going wrong here?

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

Sorry, are you saying you have attempted to apply the patch that Dean posted above and then build your avr-size or not ?

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

I applied the patch and built binutils. I did not build binutils-avr which is a second package. Here are the contents of the binutils-avr source. Can anyone guide me in how to compile this?

~/compile/binutils-avr-2.18/debian$ ls *
changelog  copyright     dirs    newdevices.patch.old  rules
control    dbs-build.mk  gasp.1  README.debian         semantic.cache

patches:
dollars.patch  newdevices.patch  patch-newsections
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

barney_1 wrote:
Does anyone know if this patch has been submitted upstream?

I created the patch, and no I have not submitted it upstream. The patch is AVR-specific so I have strong doubts that the binutils project would accept it.

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

EW wrote:
barney_1 wrote:
Does anyone know if this patch has been submitted upstream?

I created the patch, and no I have not submitted it upstream. The patch is AVR-specific so I have strong doubts that the binutils project would accept it.

Well, debian (and by proxy ubuntu) have a separate package for binutils-avr that seems to just be a set of patches. Perhaps your patch could find a home there?

debian package:
http://packages.debian.org/lenny...

ubuntu package:
http://packages.ubuntu.com/hardy...