Skip to main content
Visitor II
December 11, 2023
Question

How to use external SDRAM as an data memory?

  • December 11, 2023
  • 1 reply
  • 2576 views

I am using STM32H747I-DISCO board where the stack and heap memory allocated in SRAM , but I want to use external SDRAM as stack and heap memory, can any one please help me how to configure  external SDRAM as main data memory instead of SRAM.

    This topic has been closed for replies.

    1 reply

    Graduate II
    December 11, 2023

    You don't want to use it for stack. You want to use TCM memory for stacks so as not to bog down everything with the highest latency memory available.

    For HEAP you're going to have to clean up syscalls.c so that _sbrk() allocator functions properly and has high/low water marks in SDRAM for the heap, and not use the stack pointer (SP) as the high water mark, as it's in an entirely different memory region/space.

    You should ideally bring up external memories in SystemInit() so they can be used by the run-time and constructors.

    Visitor II
    December 12, 2023

    Instead of SRAM I want to use external SDRAM in my application, how to change it in program level please suggest with some example.

    Graduate II
    December 12, 2023

    You'd want to bring up the memory, think Clock, GPIO, FMC/SDRAM peripheral in SystemInit(), this is somewhat antithetical to HAL/CubeMX, but it's the way it's supposed to be done, per ARM/CMSIS and decades of precedence.

    Modify startup.s  to address the different region, and copy the initialization.

    Modify the Linker Script (.LD) to describe the SDRAM section, what lives in it, and the "} >SDRAM AT> FLASH"

    Create symbols for the memory within the SDRAM, and the location the initialization data staged in FLASH.

    See how CCMRAM is dealt with here..   https://github.com/STMicroelectronics/STM32CubeF4/blob/master/Projects/STM324x9I_EVAL/Examples/ADC/ADC_TriggerMode/STM32CubeIDE/STM32F429NIHX_FLASH.ld

    I could write you some code, but there's some cost to doing that.