cancel
Showing results for 
Search instead for 
Did you mean: 

To know how to declare an array in D2 domain SRAM in STM32H743 Microcontroller using STM32CUBEIDE.

kgang
Associate II

Hello,

I am using STM32CUBEIDE and STM32H743 microcontroller. I want to allocate an array in D2 domain SRAM

I tried the following approach:

1) In the linker script (STM32H743_RAM.ld) i created a separate section called dmabuffer

as follows

.dma_buffer :

{  

 *(.dma_buffer)

} >RAM_D2

2)In the main.c file declared the array as

uint32_t dmabuffer[1024] __attribute__ ((section(".dma_buffer")));

in main() function

tried loading some value in the dmabuffer

as dmabuffer[0]=0x12345671;

dmabuffer[1]=0x12312311;

3) Uncommented the line /* #define DATA_IN_D2_SRAM */ in the system_stm32hxx.c assuming the D2 domain SRAM is not active by default.

4)But still the array is not being initialised in D2 domain SRAM starting at address( 0x30000000) it is being initialised at D1 Domain SRAM

Looking forward ,

To know any more changes or suggestion on how to declare an array in D2 domain SRAM in STM32H743 microcontroller

Regards,

krishna.

4 REPLIES 4

Would need to add code in startup.s to copy the initialization data from Flash into RAM, using marker symbols you defined in the linker script.

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

Why do you say it is being initialised at D1 Domain SRAM ?

Do you see the dmabuffer name in the .map file ? What is its address ?

PMath.4
Senior III

Clive is as always correct. Attached is my update to the startup file to load into DTCMRAM. Just change the symbols to match

In startup.s

/* Copy the data segment initializers from flash to DTCMRAM */
  movs  r1, #0
  b  LoopCopyDTCMDataInit
 
CopyDTCMDataInit:
  ldr  r3, =_siDTCMData
  ldr  r3, [r3, r1]
  str  r3, [r0, r1]
  adds  r1, r1, #4
 
LoopCopyDTCMDataInit:
  ldr  r0, =_sDTCMData
  ldr  r3, =_eDTCMData
  adds  r2, r0, r1
  cmp  r2, r3
  bcc  CopyDTCMDataInit
  ldr  r2, =_sDTCMbss
  b  LoopFillZeroDTCMbss
/* Zero fill the DTCMbss segment. */
FillZeroDTCMbss:
  movs  r3, #0
  str  r3, [r2], #4
 
LoopFillZeroDTCMbss:
  ldr  r3, = _eDTCMbss
  cmp  r2, r3
  bcc  FillZeroDTCMbss

In loader file

   /* used by the startup to initialize data */
  _siDTCMData = LOADADDR(.DTCMData);
 
.DTCMData : {
  . = ALIGN(4);
  _sDTCMData = .;        /* create a global symbol at DTCMData start */
   . = ALIGN(4);
  *stm32h7xx_it.o (.data .data*)
   _eDTCMData = .;        /* create a global symbol at DTCMData end */
   } >DTCMRAM AT> FLASH
 
 /* Uninitialized DTCM data section */
. = ALIGN(4);
 
.DTCMbss : {
  . = ALIGN(4);
  _sDTCMbss = .;        /* create a global symbol at DTCMbss start */
   . = ALIGN(4);
   _eDTCMbss = .;        /* create a global symbol at DTCMbss end */
   } >DTCMRAM
   

kgang
Associate II

Thanks PMath.4