Skip to main content
Graduate
December 5, 2023
Question

Extremely Large Binary Size When Using DTCMRAM

  • December 5, 2023
  • 3 replies
  • 2786 views

Hi, I am working on a project with the STM32H730. In order to make full use of the onboard memory I have the project set up to load some objects into DTCMRAM. This works, however the binary size is huge, like 403 MB, and subsequently is crashing cube programmer:

Screen Shot 2023-12-05 at 9.08.12 AM.png

It seems like something is going wrong here and a huge amount of unnecessary information is getting stored in the binary file. 

Can you recommend a way to fix this while still using DTCMRAM for data?

Here is the DTCMRAM section of my linker file, and how I am allocating objects to DTCMRAM:

/* Define output sections */

SECTIONS

{

  /* The startup code goes first into FLASH */

  .isr_vector :

  {

    . = ALIGN(4);

    KEEP(*(.isr_vector)) /* Startup code */

    . = ALIGN(4);

  } >FLASH

  

  .dtcm_ram : {

    . = ALIGN(4);

_sDTCMData=.;        

 

*(.dtcm_ram)

 

.=ALIGN(4);

_eDTCMData=.;        /* create a global symbol at DTCMData end */

   

  } >DTCMRAM

Screenshot 2023-12-05 at 1.12.44 PM.png

 

    This topic has been closed for replies.

    3 replies

    Graduate II
    December 5, 2023

    You need to split the .BIN files into sections. Or use .HEX or .ELF which has the meta-data for discontinuous / sparse data regions.

    Secondarily you need to manage RAM initialization in startup.s, or make the sections NOLOAD

    See how startup.s unpacks and clears the RAM via statics it stores in the ROM/FLASH section.

    Graduate II
    December 5, 2023

    See how the AT> directive is used here, where CCMRAM is like DTCMRAM, in this linker script (.LD) file

    ...
     /* used by the startup to initialize data */
     _sidata = LOADADDR(.data);
    
     /* 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 AT> FLASH
    
     _siccmram = LOADADDR(.ccmram);
    
     /* CCM-RAM section
     *
     * IMPORTANT NOTE!
     * If initialized variables will be placed in this section,
     * the startup code needs to be modified to copy the init-values.
     */
     .ccmram :
     {
     . = ALIGN(4);
     _sccmram = .; /* create a global symbol at ccmram start */
     *(.ccmram)
     *(.ccmram*)
    
     . = ALIGN(4);
     _eccmram = .; /* create a global symbol at ccmram end */
     } >CCMRAM AT> FLASH
    
    
     /* Uninitialized data section */
     . = ALIGN(4);
     .bss :
     {
     /* This is used by the startup in order to initialize the .bss section */
     _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
    ...  
    EPala.2Author
    Graduate
    December 5, 2023

    Okay so does CCMRAM just replace DTCMRAM? It's like the same thing but denotes that initialization values aren't saved in the binary?

    Graduate II
    December 5, 2023

    It cannot be exactly the same, because it is not the same. Read the AN4891 and learn the differences. But a general advice is - put all the stacks and intensively accessed (like for DSP processing) variables in DTCM.

    Explorer II
    September 5, 2025

    Same thing happened to me, binary size 600+ Mbytes, but using D2 RAM. I need binary for bootloader, hence need to fix the issue. Nonetheless, the solution is using the noload directive like mentioned before in the thread. My working stm32h753vitx_flash.ld file included as attachment. If you remove the (noload) from .ethernet_data section the binary file size is 600+ Mbytes, with (noload) the size is as expected.

    .ethernet_data (NOLOAD) : /* inside SECTIONS section, before /DISCARD/ */
    {
     *(.RxDescripSection)
     *(.TxDescripSection)
     *(.dma_buffer) 
    } >RAM_D2

     

    Graduate II
    September 5, 2025

    Check the position of the COLON, I think it should be BEFORE (NOLOAD) not after it.

    You can inspect the .ELF with OBJDUMP or FROMELF, and confirm the section has "NOBITS"

    Explorer II
    September 5, 2025

    Does not compile if the colon is before (NOLOAD).

    stm32h753vitx_flash.ld:181: syntax error