lancaster-university / microbit-v2-samples

CODAL build tools and sample programs for the micro:bit v2.x
MIT License
64 stars 83 forks source link

Add new target option to print/show the build size. #81

Open microbit-carlos opened 10 months ago

microbit-carlos commented 10 months ago

We should discuss if this is something we'd like to add, and if this is the right format to enable it (with an entry in the target.json file).

The size info is added by using the arm-none-eabi-size tool and the -Wl,--print-memory-usage linker flag.

With this change, and by setting the "show_size": true option in target.json, we get this additional info printed during builds:

$ python build.py

...

[ 99%] Linking CXX executable MICROBIT
Memory region         Used Size  Region Size  %age Used
             MBR:        2816 B         4 KB     68.75%
              SD:        105 KB       108 KB     97.22%
           FLASH:      127888 B       364 KB     34.31%
      BOOTLOADER:       25580 B        28 KB     89.22%
        SETTINGS:        4899 B         8 KB     59.80%
            UICR:           8 B          8 B    100.00%
          NOINIT:          16 B         16 B    100.00%
             RAM:      120768 B     122816 B     98.33%
Print total size info:
   text    data     bss     dec     hex filename
 239556  140823    8992  389371   5f0fb /Users/microbit-carlos/workspace/mbef/codal/microbit-v2-samples/build/MICROBIT
[ 99%] Built target MICROBIT
[100%] converting to bin file.
[100%] converting to hex file.
[100%] Built target MICROBIT_hex
[100%] Built target MICROBIT_bin
microbit-carlos commented 10 months ago

This PR, by default, won't print the size info:

But, this temp branch has been created in the codal-microbit-v2 repo to test it with the option enabled: