How to measure the code size for M55?

Hi, I’m trying to understand the code size of the runtime(including tf-lite, CMSIS, etc, exclude common c/c++ lib).
I’m looking at the symbols from .map file, e.g:
.text start with

.vectors       0x0000000000000000      0x240 lib/liblibethos-u-ad.a(irqs.c.obj)

Then a bunch of tf-lite symbols,
Then there is a

 .text          0x0000000000019f14        0x0 lib/libcmsis-dsp.a(arm_mve_tables.c.obj)

Rest seems to be libstdc++.
So I guess the code size is roughly 0x0000000000019f14 ~= 104KB.
Am I interpreting it correctly?


The map file is the correct place to look for the code size from different parts. The quick answer is that there is no simple way to get how much code size each individual library is consuming. The easiest way, probably, is to write a script (Python or similar) to parse the map file and extract individual library elements.

To get high level understanding of the code footprint though, you can run:

    arm-none-eabi-objdump -h ./bin/ethos-u-inference_runner.axf

The code sections are only 1 and 8 as shown below:

      0 .text.at_itcm 0005b304  00000000  00000000  00010000  2**3
                      CONTENTS, ALLOC, LOAD, READONLY, CODE
      8 .bram.at_ddr  00003e40  11000000  70016630  00090000  2**3
                      CONTENTS, ALLOC, LOAD, READONLY, CODE

Which tells you in broad terms that the code size is 0x0005b304 + 0x00003e40 = 389444 bytes.

I am not entirely sure if looking at libstdc++ in isolation will also help as relevant parts of this lib is pulled in because there is functionality in existing sources (for example TensorFlow Lite Micro, our application code) that needs this. Some of the functions in standard library will request being inlined or some classes will be header based (for example some templated containers) only too, so it will be very difficult to get a clean split anyway.

To clarify the snippets:

.vectors       0x0000000000000000      0x240

The text starts with the interrupt table vector because that’s placed at address 0x0 by default - a table of 32-bit pointers with 144 elements => 576 bytes in size.

     .text          0x0000000000019f14        0x0 lib/libcmsis-dsp.a(arm_mve_tables.c.obj)

is actually for look up table/s from the CMSIS DSP library => it is RO-data and not executable code.

Hope this helps :slight_smile:

Cool. That’s very helpful.
Thank you so much.