Utilizing the Build Analyzer in STM32CubeIDE

ST’s latest tool, STM32CubeIDE, is an Eclipse based IDE which provides an all-in-one development experience by integrating their previous TrueSTUDIO IDE with the STM32CubeMX code configurator. Among its many features are build and stack analyzers which help the developer keep an eye on memory consumption. These are very useful and provide vital information, but unfortunately are are not entirely straightforward to use.

I started by importing my project into STM32CubeIDE and building it. It built successfully, as shown below. Notice that the build output provides code size information, though not in a human-readable format. This is where the Build Analyzer comes in handy.

Unfortunately, after building the project, the Build Analyzer (the Memory Regions tab in particular) is not automatically populated with any code size information.

To get this information, we have to select the <project_name>.map file in the Debug folder. In the Project Explorer, expand the Debug folder and single-click on the .map file. If this file is not present, right-click on the Debug folder and chose Refresh.

stm32cubeide_debug_folder

UPDATE: The latest versions of STM32CubeIDE solve this issue by using the project name as the base name for the .elf file by default. Because this is also done for the .map file, both files will have the same base name and the Build Analyzer will be automatically populated (as @M.Yaqoob mentioned in the comments section below).

It should also be noted that manually selecting the .map file as mentioned above will cause the “FLASH” region in the Build Analyzer to report incorrect values (instead depicting the memory consumed by both Flash and RAM). The .elf file should be selected instead. This is useful when multiple build configurations are utilized for the application and you wish to examine a specific build’s memory consumption details. Simply choose the appropriate .elf file from the corresponding build directory (e.g. Debug, Release, etc.). Thanks to @wgoebel for pointing this out!

The Memory Regions tab should now be populated with memory usage statistics for the FLASH and RAM regions. Most useful is the Usage (%) column which visually shows how much memory is being consumed.

2 Likes

Hi,
To fix this permanently, you need to have your .map file name similar to your .elf file name.
In your example,
elf file name = STM32L476RG_NUCLEO.elf
map file name = ST_test.map

You can force your .map file name to STM32L476RG_NUCLEO.map by following these steps:

  1. Go to Properties>>C/C++ Build >> Settings >> Tool Settings >> MCU GCC Linker >> Miscellaneous
  2. Add the following flag: -Wl,-Map=STM32L476RG_NUCLEO.map

Enjoy

1 Like

Great tip!! Thanks for the contribution! :grinning:

ST Build analyzer is sometimes showing wrong usage in case selecting the map file;
in my case I have several build configurations (debug / release, device specific) in the same project, build analyzer tab
often shows wrong information (although map/elf file name are identical). Selecting the elf file of the selected build configuration usually works best.

Hello wgoebel, welcome to the Forum!

I have sent your question to our Product Specialist and as soon as I have his reply, I will relay it to you here.
Thanks!