NOTICE: This website will be shut down in the near future. Product content has moved to nxp.com. Forum content and FAQs have been moved to community.nxp.com. We encourage you to create a user account on nxp.com to use the new community forums and access NXP microcontroller content. We greatly appreciate your contributions and look forward to seeing you at our new web location.

 

Application Flash / RAM size

lpcxpresso-support's picture

Size information produced by build

As part of the build process, information on the size of your application will normally be displayed at the end of the build log in the Console view. This is done by a post-build step invoking the arm-none-eabi-size utility....

   text   data   bss    dec     hex   filename
  2624    524    32    3180     c6c   LPCXpresso1768_systick_twinkle.axf

[All numbers are in bytes.]

  • text - shows the code and read-only data in your application (in decimal)
  • data - shows the read-write data in your application (in decimal)
  • bss - show the zero initialized ('bss' and 'common') data in your application (in decimal)
  • dec - total of 'text' + 'data' + 'bss' (in decimal)
  • hex - hexidecimal equivalent of 'dec'

Typically,

  • the flash consumption of your application will then be text + data
  • the RAM consumption of your application will then be data + bss

Remember that the RAM consumption provided by this is only that of your global data. It will not include any memory consumed by your stack and heap when your application is actually executing.

You can also manually run the arm-none-eabi-size utility on both your final application image, or on individual object files.

To view the size of the image, right click over the .axf file in the Debug or Release subdirectory of your application project and select the Binary Utilities -> Size option. To view the size of an individual object file, select the appropriate .o file in the Debug\src or Release\src subdirectory of the project and again select the Binary Utilities -> Size option.

NOTE : Looking at the size of the AXF file on disk does not provide any information as to how much Flash/RAM space your application will occupy when downloaded to your MCU. The AXF file contains a lot more information than just the binary code of your application, for example the debug data used to provide source level information when debugging, that is never downloaded to your MCU.


Linker map files

The linker option "-map" option, which is enabled by default by the project wizard when a new project is created, allows you to analyse in more detail the contents of your application image. When you do a build, this will cause a file called <application>.map to be created in the Debug (or Release) subdirectory, which can be loaded into the editor view.

This contains a large amount of information, including:

  • A list of archive members (library objects) included and why
  • A list of discarded input sections (because they are unused and the linker option --gc-sections is enabled).
  • The location, size and type of all code, data and bss items that have been placed in the image.

Other utilities

The arm-none-eabi-nm utility can sometime be useful when looking at the size of your application, as it can produce some of the information provided in the linker map file but in a more concise form. For example:

arm-none-eabi-nm -S --size-sort -s project.axf

produces a list of all the symbols in an image, their sizes and their addresses, listed in size order. For more information on this utility, please see the GNU binutils documentation.

Note that you can run arm-none-eabi-nm as a post-build step, or else open a command shell using the status bar shortcuts.

5
Your rating: None Average: 5 (4 votes)
feedback