Skip to main content
Visitor II
August 9, 2024
Solved

Hardfault when trying to access SDRAM on STM32h745i-DISCO

  • August 9, 2024
  • 1 reply
  • 1865 views

I am trying to wire a graphics application on an STM32H745i-DISCO board, and place the framebuffer in external SDRAM.

So I configured the FMC as follows:

MARTINLAZZARI_0-1723238752657.pngMARTINLAZZARI_1-1723238780457.pngMARTINLAZZARI_2-1723238797538.png

Then, under Cortex-M7 I set up the MPU:

MARTINLAZZARI_3-1723238954501.png

But when running the program and attempting to write to 0xD000 0000 I get a hard fault.

What am I missing?

 

 

    This topic has been closed for replies.
    Best answer by MARTIN LAZZARI

    Still, the initialization code for the SDRAM is chip-dependent, so I had to add the proper initialization code. This can be found in the BSP (board support package) drivers for the STM32H745i-DISCO.

    Here's an article on how to import the BSP into an existing project:

    https://community.st.com/t5/stm32-mcus/how-to-add-a-bsp-to-an-stm32cubeide-project/ta-p/49812

    Essentially, create a new project for the board that you are using, and import the files from the BSP folder. In this case, the files for the sd_ram and its specific component (MT48LC4M32B2). Once you add your files to your sources and include path, you can add the call to the initialization.

    At the end of the MX_FMC_Init function, call the initialization function for the specific SDRAM:

     

    /* USER CODE BEGIN FMC_Init 2 */

    if (BSP_SDRAM_Init(0) != BSP_ERROR_NONE)

    {

    Error_Handler();

    }

    /* USER CODE END FMC_Init 2 */

     

    1 reply

    Visitor II
    August 10, 2024

    OK, I added some initialization code for the SDRAM copied from here:

    https://community.st.com/t5/stm32-mcus/how-to-set-up-the-fmc-peripheral-to-interface-with-the-sdram/ta-p/49457

    and now I'm no longer getting a hardafult

     

    MARTIN LAZZARIAuthorAnswer
    Visitor II
    August 10, 2024

    Still, the initialization code for the SDRAM is chip-dependent, so I had to add the proper initialization code. This can be found in the BSP (board support package) drivers for the STM32H745i-DISCO.

    Here's an article on how to import the BSP into an existing project:

    https://community.st.com/t5/stm32-mcus/how-to-add-a-bsp-to-an-stm32cubeide-project/ta-p/49812

    Essentially, create a new project for the board that you are using, and import the files from the BSP folder. In this case, the files for the sd_ram and its specific component (MT48LC4M32B2). Once you add your files to your sources and include path, you can add the call to the initialization.

    At the end of the MX_FMC_Init function, call the initialization function for the specific SDRAM:

     

    /* USER CODE BEGIN FMC_Init 2 */

    if (BSP_SDRAM_Init(0) != BSP_ERROR_NONE)

    {

    Error_Handler();

    }

    /* USER CODE END FMC_Init 2 */