cancel
Showing results for 
Search instead for 
Did you mean: 

How to use external SDRAM as an data memory?

Pavankumar1_
Associate II

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.

4 REPLIES 4

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.

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

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

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.

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

Back linking to your other thread on this topic area.   https://community.st.com/t5/stm32-mcus-embedded-software/how-to-use-sdram-for-bss-and-data-region/td-p/618725

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