If I compile a sketch for the Arduino Mega:

Sketch uses 1804 bytes (0%) of program storage space. Maximum is 253952 bytes.
Global variables use 188 bytes (2%) of dynamic memory, 
leaving 8004 bytes for local variables. Maximum is 8192 bytes.

If I compile the same sketch for the Arduino Due:

Sketch uses 26304 bytes (5%) of program storage space. Maximum is 524288 bytes.

Why is the global variables part not supported for the Due, it seems to me it's quite important (even more than the sketch size).

Or can I enable this option somehow? (and if yes, how)

1 Answer 1


There is a difference in how the build system calculates the memory size for AVR and SAM. The platform.txt file contains the rule for calculating the size. There is a difference how this is done for SAM (Arduino Due).

The AVR size rules (https://github.com/arduino/ArduinoCore-avr/blob/master/platform.txt#L79) are:

## Compute size
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"

And the rules for SAM (https://github.com/arduino/ArduinoCore-sam/blob/master/platform.txt#L91) are:

recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"

They may be updated to give more information about the memory size. A good reference on the subject is http://www.support.code-red-tech.com/CodeRedWiki/FlashRamSize which shows that the output from size command for SAM contains much more information.

I assume that from the above information you see how this could be updated.


  • Thank you very much ... that output looks very much to what I get when I compile software for the STM32. However, I tried to find how to run arm-none-eabi-nm -S --size-sort -s project.axf, but I cannot find the axf file and there is - at least no menu option - to run arm-none-eabi-nm Commented Jul 23, 2019 at 20:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.