cancel
Showing results for 
Search instead for 
Did you mean: 

stm32h7 dtcm ram overflowed

VYoun
Associate III

Hello,

I am relatively new in this field, and need assistance for my project at work.

Recently, in order to have more RAM, I switched from STM32F4 to STM32H7.

I saw that STM32H7 has 1MB of RAM, and decided to base our system on this MCU.

However, after compiling my code, I see that only DTCM RAM is used by the MCU and others are not used.

The DTCM RAM is now full and I can not move any further with my code.

How can I make use of RAM_D1 or RAM_D2 for my variables?

I am using CubeMX and Atollic Truestudio.

Please kindly help me as this is vital for my work. Any help is greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
alister
Lead

Despite its name, this link describes your situation: https://community.st.com/s/article/FAQ-DMA-is-not-working-on-STM32H7-devices.

Find your linker script (file with .ld extension). If there's more than one or you're not sure, open Tool Settings and navigate to the "General" leaf of "C Linker". The path of the linker script there is relative your build directory.

Read https://sourceware.org/binutils/docs/ld/Scripts.html#Scripts to learn its syntax.

Blocks and sizes of memory vary. Read RM0433 to learn how memory's arranged for your part and populate your MEMORY regions accordingly. As example, these are the blocks from my STM32H7 project's linker script:

MEMORY
{
  ITCMRAM (xrw)                   : ORIGIN = 0x00000000, LENGTH = 64K
  DTCMRAM (rw)                    : ORIGIN = 0x20000000, LENGTH = 128K
  AXI_SRAM_D1 (xrw)               : ORIGIN = 0x24000000, LENGTH = 512K
  SRAM1_D2 (xrw)                  : ORIGIN = 0x30000000, LENGTH = 128K
  SRAM2_D2 (xrw)                  : ORIGIN = 0x30020000, LENGTH = 128K
  SRAM3_D2 (xrw)                  : ORIGIN = 0x30040000, LENGTH = 32K
  SRAM4_D3 (xrw)                  : ORIGIN = 0x38000000, LENGTH = 64K
  BACKUP_SRAM_D3 (rw)             : ORIGIN = 0x38800000, LENGTH = 4K
 
<snip>
}

Probably you should move .data, .bss, heap (if you have any) and stack or initial stack (depending whether you're bare-metal or OS) to the region corresponding the one I've named AXI_SRAM_D1.

In that first link, there's discussion too about placing objects at specific memory locations. That's not pertinent yet. When you come to it though, read about the section attribute at https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#Common-Variable-Attributes.

View solution in original post

13 REPLIES 13
alister
Lead

Despite its name, this link describes your situation: https://community.st.com/s/article/FAQ-DMA-is-not-working-on-STM32H7-devices.

Find your linker script (file with .ld extension). If there's more than one or you're not sure, open Tool Settings and navigate to the "General" leaf of "C Linker". The path of the linker script there is relative your build directory.

Read https://sourceware.org/binutils/docs/ld/Scripts.html#Scripts to learn its syntax.

Blocks and sizes of memory vary. Read RM0433 to learn how memory's arranged for your part and populate your MEMORY regions accordingly. As example, these are the blocks from my STM32H7 project's linker script:

MEMORY
{
  ITCMRAM (xrw)                   : ORIGIN = 0x00000000, LENGTH = 64K
  DTCMRAM (rw)                    : ORIGIN = 0x20000000, LENGTH = 128K
  AXI_SRAM_D1 (xrw)               : ORIGIN = 0x24000000, LENGTH = 512K
  SRAM1_D2 (xrw)                  : ORIGIN = 0x30000000, LENGTH = 128K
  SRAM2_D2 (xrw)                  : ORIGIN = 0x30020000, LENGTH = 128K
  SRAM3_D2 (xrw)                  : ORIGIN = 0x30040000, LENGTH = 32K
  SRAM4_D3 (xrw)                  : ORIGIN = 0x38000000, LENGTH = 64K
  BACKUP_SRAM_D3 (rw)             : ORIGIN = 0x38800000, LENGTH = 4K
 
<snip>
}

Probably you should move .data, .bss, heap (if you have any) and stack or initial stack (depending whether you're bare-metal or OS) to the region corresponding the one I've named AXI_SRAM_D1.

In that first link, there's discussion too about placing objects at specific memory locations. That's not pertinent yet. When you come to it though, read about the section attribute at https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#Common-Variable-Attributes.

VYoun
Associate III

Thank you very much for your answer, it was really helpful.

I used the link that you mentioned and could bring everything into SRAM_D1, but my program stopped working after that.

I think the variables are not recognised anymore.

I am really confused.

> I used the link that you mentioned and could bring everything into SRAM_D1, but my program stopped working after that.

Not every RAM is the same.

Some regions are unreachable by DMA. Some are not regions are not connected to the I-Bus (e.g. DTCMRAM (rw)).

You might need to review the datsheet / Reference manual.

Perhaps re-thinking your application, and memory layout.

Eliminate unused data storage, reducing buffer sizes and operate on less data on-the-fly.

And last but not least, compiler optimization options.

VYoun
Associate III

Thank you very much for your reply.

I am not using DMA in my application.

I think I need to go through the reference manual to learn which blocks are connected to each RAM area.

I will use your suggestions, thank you again.

Best regards,

Vouria

And don't forget to review the map file.

Your heap/stack might be oversized.

Read AN4891 about the STM32H74x and STM32H75x system architecture.

There is no good rationale for having all of .bss, .data and heap in [edit] DTCM-RAM, unless your app's small.

VYoun
Associate III

Thanks everybody for your suggestions. I will go through the application note and reference manual.

But just to briefly confirm, I can only make use of the DTCMRAM for my code, is that true?

Your help is greatly appreciated, since I am under time pressure for my project.

Best regards,

Vouria

> I can only make use of the DTCMRAM for my code

See AN4891.

In your question, you had everything in DTCMRAM. As your app grew, it became full.

Normally you'd reserve DTCM-RAM for critical data and move .bss/.data/heap to AXI-SRAM as they grow too large. To place critical data in AXI-SRAM you'd use GCC's section attributes and suitable changes to your linker command file.

I see my earlier post incorrectly said don't use D1. Sorry I meant don't use DTCM-RAM. I'll edit that.

Hello,

Thank you very much, I will go through the document and will ask if there are any questions.

I tried to use D1 using the linker commands, and I succeeded. But then my program stopped working.

I think I need to go through the reference manual and the AN4891 to figure out how to use D1 correctly, so that the program does not stop working.

Best regards,

Vouria