cancel
Showing results for 
Search instead for 
Did you mean: 

If we initialize an array would it be stored in a different partition of RAM in comparison with the condition under which we do not initialize the array ? initialized array: float Data_Set_X[15000]={0}; uninitialized: float Data_Set_X[15000];

STork.1
Associate III

the problem is that When I define the arrays like this :

float Data_Set_X[15000];

 float Data_Set_Y[15000];

 float Data_Set_Z[15000];

I get the RAM overflow error which is: `.bss' will not fit in region `RAM' Timer-Blink-Test_CM7 C/C++ Problem

when I initilaze at least one of the arrays or three of them , the error will be disappeared.

float Data_Set_X[15000]={0};

 float Data_Set_Y[15000];

 float Data_Set_Z[15000];

in linker script file it is written that:

/* Specify the memory areas */ 

MEMORY

{

RAM_EXEC (rx)   : ORIGIN = 0x24000000, LENGTH = 256K   

RAM (xrw)   : ORIGIN = 0x24040000, LENGTH = 256K     

}

/* The startup code goes first into RAM_EXEC */

/* The program code and other data goes into RAM_EXEC */

/* Constant data goes into RAM_EXEC */

/* Initialized data sections goes into RAM, load LMA copy after code */

and there is a separated part of the RAM for /* Uninitialized data section */ according to the linker script.

the RAM size is 1MB and around 800KB is accessible for the user. MCU has dual core and I use the M7 Core. this core can access to a 512KB RAM area as it is mentioned in the Linker Script file. the whole size of these three arrays are 180KB

I have attached the linker script file to this message.

Thank you!

2 REPLIES 2
KnarfB
Principal III

Accoding to your .ld file: Uninitialized data goes to .bss, initialized global data finally goes to .data. Actually, initialized global data is copied from RAM_EXEC to RAM at startup before entering main. This copying makes more sense for a (persistent) FLASH and I wonder why this RAM to RAM copying is done at all.

Edit: this might be helpful https://interrupt.memfault.com/blog/how-to-write-linker-scripts-for-firmware