2024-09-25 09:54 AM
I have created a new project and built it. The build analyser shows:
I then added the following at file scope:
int8_t position[ 4096 ]; // Default zero initialized array
The build analyser then shows:
The 4k increase in RAM usage makes sense, but not the 4K increase in FLASH.
The console shows:
The build analyser also shows:
Why is 4k being added to the .bss section in FLASH for the position object?
Solved! Go to Solution.
2024-09-26 07:08 AM
I created a new project with the same configuration and copied my application code into it.
There is now no .bss in the FLASH area, as expected.
The only changes I have made to both projects are those related to peripheral configuration. The linker files are both the same and are the template files provided when the projects were created.
I can only think that something happened when I moved the project from Mac to Windows (where I am running a later version - 1.16.0).
2024-09-25 10:10 AM - edited 2024-09-25 11:25 AM
Probably an issue with build analyzer
Would perhaps look at what OBJCOPY, OBJDUMP or FROMELF can report about the structure and content of the ELF file.
The Linker Script should be able to partition the initialized and uninitialized portions, and the startup code should be able to do the copying from FLASH and zeroing, based on what the linker generated and the symbols it created.
2024-09-25 10:15 AM
You are right, it shouldn't.
Which CubeIDE version are you using? And which CPU (obviously one with a small amounts of memory)? Can you post your .ioc file (if you used CubeMX to create your project) and/or a minimal (presumably "C") program that shows this issue. Then others can see if they can replicate your results.
2024-09-25 11:17 AM - edited 2024-09-25 11:30 AM
Which chip ?
You set something strange...
on F103C8 :
I tried just to add your 4K position array, and yes, it needs 4KB ram, bss is there, nothing in flash:
with optimizer on -O2 .
The linker script should have it in ram - did you change it ?
.bss :
{
/* This is used by the startup in order to initialize the .bss section */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM
2024-09-26 07:08 AM
I created a new project with the same configuration and copied my application code into it.
There is now no .bss in the FLASH area, as expected.
The only changes I have made to both projects are those related to peripheral configuration. The linker files are both the same and are the template files provided when the projects were created.
I can only think that something happened when I moved the project from Mac to Windows (where I am running a later version - 1.16.0).