cancel
Showing results for 
Search instead for 
Did you mean: 

How to use STM32CubeIDE or STM32CubeMX to automatically add settings for RAM_D2 and RAM_D3 in LD fil

RajeevAroraCrcEvans
Associate III

Hi All,

Requesting help with below.

I am using latest version of STM32CubeIDE. The microcontroller in use is STM32H743BITx.

I have concerns with regards to:
1. Whether to add ALIGN(4) even inside the FLASH sections present in STM32H753BITX_FLASH.ld (attached)

2. The file generated by STM32CubeMX (ran from within STM32CubeIDE) generated a STM32H753BITX_FLASH.ld file in the project folder. It does not contain sections that reside in RAM_D2 and RAM_D3. Attached the STM32H753BITX_FLASH.ld.txt file for reference. Is there a way available with STM32CubeMX (preferably) or with STM32CubeIDE to add the necessary RAM sections in the LD file for STM32H743BITx?

3. I observe that macro DATA_IN_D2_SRAM is disabled and hence concerned about how clocks to RAM_D1, RAM_D2 and RAM_D3 are being enabled. I am also unable to figure out any valid assignment to register AHB2ENR which would enable the clock to the three RAM sections.

In file system_stm32h7xx.c please refer to below section starting at line number 79.

The macro DATA_IN_D2_SRAM is disabled

/************************* Miscellaneous Configuration ************************/

/*!< Uncomment the following line if you need to use initialized data in D2 domain SRAM (AHB SRAM) */

/* #define DATA_IN_D2_SRAM */

Then from line number 267

#if defined(DATA_IN_D2_SRAM)

/* in case of initialized data in D2 SRAM (AHB SRAM), enable the D2 SRAM clock (AHB SRAM clock) */

#if defined(RCC_AHB2ENR_D2SRAM3EN)

RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN | RCC_AHB2ENR_D2SRAM3EN);

#elif defined(RCC_AHB2ENR_D2SRAM2EN)

RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN);

#else

RCC->AHB2ENR |= (RCC_AHB2ENR_AHBSRAM1EN | RCC_AHB2ENR_AHBSRAM2EN);

#endif /* RCC_AHB2ENR_D2SRAM3EN */

 

tmpreg = RCC->AHB2ENR;

(void) tmpreg;

#endif /* DATA_IN_D2_SRAM */

 

Please help resolve my above concerns.

Thanks!

Rajeev

18 REPLIES 18

Hi @RajeevAroraCrcEvans ,

maybe i understand your "problem" : is ram clk enabled - or not ?

Just from my H743 program, in  system_stm32h7xx.c :

  RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN | RCC_AHB2ENR_D2SRAM3EN);

 All ram areas enabled , default.

So dont worry about...

I use ITC for stack and heap, D2 for circular DMA (always running), D1 for all other:

AScha3_0-1707683766396.png

 

If you feel a post has answered your question, please click "Accept as Solution".

Your understanding is correct. You can do this in the Keil linker, but you cannot do this in the STM32CubeIDE linker. There is not an equivalent keyword to ANY there. All you can do is specify them individually.

If you feel a post has answered your question, please click "Accept as Solution".

Hi @AScha.3 
Thanks for sharing the inputs.
I am novice to STM32CubeIDE environment. Until now I've been using the Keil compiler.

Concern: Before I send the HEX (for testing) I want to ensure that all the used RAM sections are receiving clock.

I need to code for a new board/PCB-with-microcontroller that is currently not available with me. I can only send the generated HEX file to one of my teammates in a different country (for occasional) testing.

I tried looking in the ELF file, and I only observe below. I even tried searching with RAM_D1 but the search did not produce any result. Am I missing something in settings due to which I do not observe information similar to the snippet that you have shared?

RajeevAroraCrcEvans_0-1707708358983.png

Below is the snippet from the system_stm32h7xx.c file. The code part has a greyed background which means that the code part is disabled.

This means that even line number 270 is disabled (which is the code line that you have shared in your response).

RajeevAroraCrcEvans_1-1707708594013.png

Now if I try finding the macro (DATA_IN_D2_SRAM) used on line number 267 the macro is commented out.

Thus I am unable to understand which part of code (generated by STM32CubeMX and being compiled using STM32CubeIDE) is enabling the clocks to the RAM_D2 and RAM_D3 sections.

Also, my code currently does not call below macro. Does your code call the below macro in main() or some place else?

RajeevAroraCrcEvans_2-1707709795006.png

 

Hi @Tesla DeLorean 

Additional response:
I believe there are two modifications/options and that I should add/enable one.
As you suggested I can either add code to file startup_stm32h753bitx.s (the one present on the right is the update):

RajeevAroraCrcEvans_0-1707721959287.png

Or alternately enable the macro DATA_IN_D2_SRAM present in file system_stm32h7xx.c (the one present on the right is the update):

RajeevAroraCrcEvans_1-1707722173786.png

I shall first try with updating the Code in above C file. If it does not work, then only I'll add the code to the above .S file.


Previous response:
I am compiling code using STM32CubeIDE and the code was generated using STM32CubeMX.
I only find below references for Reset_Handler. I do not find the line number 7 that is present in the snippet you shared. Which file should I look for the code snippet that you have shared?

RajeevAroraCrcEvans_0-1707712211505.png

 

Hi,

as i wrote:

 

Just from my H743 program, in  system_stm32h7xx.c :

 

  RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN | RCC_AHB2ENR_D2SRAM3EN);

 

 more detail:

 

#if defined (DATA_IN_D2_SRAM)
  /* in case of initialized data in D2 SRAM (AHB SRAM) , enable the D2 SRAM clock ((AHB SRAM clock) */
#if defined(RCC_AHB2ENR_D2SRAM1EN)
  RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN | RCC_AHB2ENR_D2SRAM3EN);
#else
  RCC->AHB2ENR |= (RCC_AHB2ENR_AHBSRAM1EN | RCC_AHB2ENR_AHBSRAM2EN);
#endif /* RCC_AHB2ENR_D2SRAM1EN */

 

 

All ram areas enabled , if you have some data defined, to be in D2-ram, is default.

So just define the data to ram you want to use - it will work. Thats it.

If you feel a post has answered your question, please click "Accept as Solution".

In the same file could you please check for whether below macro is defined or not:

DATA_IN_D2_SRAM

The solution seems to be one out of below. I am unaware how to copy the link to the post and share it here, hence sharing the snippet.

RajeevAroraCrcEvans_0-1707725972340.png

 

Also  in  system_stm32h7xx.c :

AScha3_0-1707727332537.png

 

If you feel a post has answered your question, please click "Accept as Solution".

There are many ways to approach this, you need the memory to be enabled before use. ARM would prefer you to do this in SystemInit() prior to the C runtime initializing and unpacking.

Keil builds tables for the various Load Regions, whereas ST's GNU implementation it needs the linker script to assign symbols, and startup.s to unpack all the regions with specific code. Arduino's GNU builds some tables to automate this.

You can't use RAM thats not enabled for the initial stack pointer, you'd need to pick a working memory, and then change it.

The D2 RAM is also further from the MCU, so will be slower, not really desirable for something with heavy use like the stack, which would be much more efficient in TCM, and wouldn't was cache resources.

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