cancel
Showing results for 
Search instead for 
Did you mean: 

Compiled code size and flashed code size are different in STM32CUBEIDE v1.15.1

Simo_Sappo
Associate III

Hi everyone, I created an HID bootloader for the STM32G4xxx, it works and now I am trying to optimize the size. After compiling I can read this on the Build Analyzer a flash memory usage of 17.85 kB.Screenshot 2024-06-06 181018.png 

After compiling I get this:

Screenshot 2024-06-06 180859.png

 

When I flash this compiled code and read the flash memory I canclearly see that the memory usage is around 38 kB.  

Screenshot 2024-06-06 180946.png

I also used the STM32CubeProgrammer to look at the actual memory (I didn't manage to use this function directly on STM32CubeIDE) and I can see that more than 38 kB are used in the memory

Can somebody explain why? Am I missing something about the Build Analyzer function?

  

 

13 REPLIES 13

Yes, but as I said I looked in the flash memory with  the STM32 Programmer, and as you can also see I have code until 0x08009974, which is page 19 of the Flash memory. So the actual occupied memory size is more than 38 kB (each page is 2 kB in dual bank mode). 

Screenshot 2024-06-07 144125.png

 

Edit: I said single bank mode but I meant dual bank mode)


@Simo_Sappo wrote:

 I have code until 0x08009974,


Are there gaps?

Simo_Sappo
Associate III

Nope, until 0x08009974 there are no gaps, no "FFFF" is written before the one you see in the picture. I checked

Simo_Sappo
Associate III

I found the problem, somehow even if I set the Release mode as active (with the size optimization) it was still flashing the Debug version of the code which is not optimized for size. I discovered this only after deleting the Debug and Release folders and staring the flashing process again. Thank you everyone for your help