Skip to main content
Visitor II
December 12, 2023
Question

How to use SDRAM for bss and data region?

  • December 12, 2023
  • 2 replies
  • 1625 views

I am using STM32H747I-DISCO board, I want to use external SDRAM for bss and data region and I called the SDRAM initialization function inside the SystemInit() function and I tried with the debugger point it will go to hard fault when debugger point hit the SDRAM initialization function. and Checked the SDRAM initialization by read and write it is working fine, please anyone suggest how to use external SDRAM for bss and data memory. 

    This topic has been closed for replies.

    2 replies

    Super User
    December 12, 2023

    Why, what does this buy you?

    SDRAM is volatile, so your program will be lost on reset. You can store it in flash and load it to SDRAM at program start, but that buys you nothing.

     

    Broadly speaking, you can do this but you need to initialize the SDRAM before you first use it. I would recommend getting a normal working application running which uses SDRAM and then take that initialization and put it into this program.

     

    Similar/duplicate:

    https://community.st.com/t5/stm32-mcus-embedded-software/how-to-use-external-sdram-as-an-data-memory/td-p/618477

     

    Graduate II
    December 12, 2023

    Look at what exactly is Hard Faulting

    There's some chicken-egg situations here, your code in SystemInit() can't be dependent of static structure initialization in to RAM. You usually want to define things as "static const" so they live at fixed addresses in FLASH, and will not be modified by your code.

    Watch also things like where your stack pointer (SP) lives. This needs to be in viable memory when you start, so 0x20002000 for example, and not 0xC0100000

    Some of ST's own examples basically have a "bare-metal" register level approach to peeking/poking values into RCC, GPIO and FMC

    This isn't your board, but an example of that method

    https://github.com/STMicroelectronics/STM32CubeF4/blob/master/Projects/STM324x9I_EVAL/Examples/ADC/ADC_TriggerMode/Src/system_stm32f4xx.c#L269

    More on-point

    https://github.com/STMicroelectronics/STM32CubeH7/blob/master/Projects/STM32H747I-DISCO/Examples/ADC/ADC_DualModeInterleaved/Common/Src/system_stm32h7xx.c#L383