cancel
Showing results for 
Search instead for 
Did you mean: 

How to assign RAM memories to data, bss, and stack and heap sections?

AIsma
Associate II

I am using the NUCLEO-144 (STM32H743ZI) board. It contains the following memory regions:

DTCMRAM (xrw)   : ORIGIN = 0x20000000, LENGTH = 128K

RAM_D1 (xrw)   : ORIGIN = 0x24000000, LENGTH = 512K

RAM_D2 (xrw)   : ORIGIN = 0x30000000, LENGTH = 288K

RAM_D3 (xrw)   : ORIGIN = 0x38000000, LENGTH = 64K

ITCMRAM (xrw)   : ORIGIN = 0x00000000, LENGTH = 64K

FLASH (rx)   : ORIGIN = 0x8000000, LENGTH = 2048K

All I would like to do is assign the data section to RAM_D2 and the bss section to RAM_D2. The issue is when I set the data section to RAM_D2 in the linker script, the application I build hard faults (InvState Error) on the following instruction in the startup script:

/* Call static constructors */

  bl __libc_init_array

The following is how I am assigning memory to data and bss sections:

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

 .data : 

 {

  . = ALIGN(4);

  _sdata = .;    /* create a global symbol at data start */

  *(.data)      /* .data sections */

  *(.data*)     /* .data* sections */

  . = ALIGN(4);

  _edata = .;    /* define a global symbol at data end */

 } >RAM_D2 AT> FLASH

  

 /* Uninitialized data section */

 . = ALIGN(4);

 .bss :

 {

  /* This is used by the startup in order to initialize the .bss secion */

  _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_D1

Is there an issue with alignment?

1 ACCEPTED SOLUTION
2 REPLIES 2

Some of the H7 SRAM needs its clock enabled before use, otherwise it will fault.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..