Open rnestler opened 8 years ago
weird, as we just shell out to avr-size --mcu=atmega32u4 -C --format=avr build-leonardo/blink.elf
i've no idea how the ide calculates it, but calling avr-size on the elf file the ide creates, reports the same size info as the ide does - not the same as the makefile.
potentially its an avr-size bug....?
i think this must be something different the IDE and Makefile are doing with linking or flags, not anything to do with avr-size, they're just creating different sized binaries.
as the 1.0.5 IDE and avr-size on its /tmp file report the same:
avr-size --mcu=atmega32u4 -C --format=avr blink.cpp.elf
AVR Memory Usage
----------------
Device: atmega32u4
Program: 4736 bytes (14.5% Full)
(.text + .data + .bootloader)
Data: 157 bytes (6.1% Full)
(.data + .bss + .noinit)
but the the makefile using the same 1.0.5 core, and avr-size report the same as each other, but different to the IDE - also the actual elf file on disk is different:
avr-size --mcu=atmega32u4 -C --format=avr build-leonardo/blink.elf
AVR Memory Usage
----------------
Device: atmega32u4
Program: 4304 bytes (13.1% Full)
(.text + .data + .bootloader)
Data: 154 bytes (6.0% Full)
(.data + .bss + .noinit)
the same happens with 1.6.12 - ide/builder make different size outputs to the makefile:
IDE:
Sketch uses 1,470 bytes (0%) of program storage space. Maximum is 253,952 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 8,183 bytes for local variables. Maximum is 8,192 bytes.
/tmp file created by the IDE (12448 bytes on disk):
/tmp/arduino_build_285509$ avr-size --mcu=atmega2560 -C --format=avr blink.ino.elf
AVR Memory Usage
----------------
Device: atmega2560
Program: 1470 bytes (0.6% Full)
(.text + .data + .bootloader)
Data: 9 bytes (0.1% Full)
(.data + .bss + .noinit)
makefile (12544 bytes on disk):
AVR Memory Usage
----------------
Device: atmega2560
Program: 1564 bytes (0.6% Full)
(.text + .data + .bootloader)
Data: 9 bytes (0.1% Full)
(.data + .bss + .noinit)
So it seems its not reporting the wrong size, its just creating binaries of different size to the IDE.
i think this must be something different the IDE and Makefile are doing with linking or flags, not anything to do with avr-size, they're just creating different sized binaries.
That's what I think as well. But the worst part is, that the Makefile will produce binaries which will destroy the Arduino bootloader! If you try to produce binaries which are bigger than 28,672 bytes, the Arduino IDE will give you an error, but the Makefile will generate a binary which corrupts the bootloader if you try to download it.
The Arduino-Makefile reports wrong memory usage compared to the Arduino IDE:
Arduino-Makefile:
For the same sketch the Arduino IDE shows:
Now the difference between the byte values is not that big, but the difference between the percentage values is.
The evil thing is, if the byte usage grows over the 28,672 bytes, make upload bricks the Arduino micro and I have to reprogram the bootloader! So the Arduino-Makefile doesn't seem to take the size of the bootloader into account and seem to break it when uploading.
Here are some relevant parts from the Makefile I use:
System: