cancel
Showing results for 
Search instead for 
Did you mean: 

allocation of global variable SD-RAM external memory.

thyu
Associate

The 'HAL_SDRAM_Write_8b' and 'HAL_SDRAM_Read_8b' functions were confirmed using STM32H723ZGT6 and IS42S16320D-6TLI.
(Check variable value changes with STM32CubeIDE's Memory Viewer and LiveWatch, no hardware problems)

All internal RAM has been used to implement the current application.
Additional feature implementation requests require variable allocation and access to external RAM.

I reviewed the STM32CubeH7 example and applied it to my project, but encountered a HardFault Handler.
(Modify STM32H747XIHX_FLASH.ld file in my Project)

Please let me know if there is anything else I need to check.
- Example path: \STM32Cube\Repository\STM32Cube_FW_H7_V1.11.1\Projects\STM32H747I-EVAL\Examples\FMC\FMC_SDRAM_DataMemory\STM32CubeIDE\CM7

 

Build Analyzer - Memory Regions

thyu_0-1718330446766.png

 

HardFault_Handler

thyu_1-1718330844869.png

 

Debug Message


STMicroelectronics ST-LINK GDB server. Version 7.5.0
Copyright (c) 2023, STMicroelectronics. All rights reserved.

Starting server with the following options:
Persistent Mode : Disabled
Logging Level : 1
Listen Port Number : 61234
Status Refresh Delay : 15s
Verbose Mode : Disabled
SWD Debug : Enabled
InitWhile : Enabled

Waiting for debugger connection...
Debugger connected
Waiting for debugger connection...
Debugger connected
Waiting for debugger connection...
-------------------------------------------------------------------
STM32CubeProgrammer v2.15.0
-------------------------------------------------------------------

Log output file: C:\Users\thyu\AppData\Local\Temp\STM32CubeProgrammer_a05560.log
ST-LINK SN : 49FF6E067789485425281567
ST-LINK FW : V2J42S7
Board : --
Voltage : 3.27V
SWD freq : 4000 KHz
Connect mode: Under Reset
Reset mode : Hardware reset
Device ID : 0x483
Revision ID : Rev Z
Device name : STM32H72x/STM32H73x
Flash size : 1 MBytes
Device type : MCU
Device CPU : Cortex-M7
BL Version : 0x93

Memory Programming ...
Opening and parsing file: ST-LINK_GDB_server_a05560.srec
File : ST-LINK_GDB_server_a05560.srec
Size : 64.81 KB
Address : 0x08000000

Erasing memory corresponding to segment 0:
Erasing internal memory sector 0
Download in Progress:

File download complete
Time elapsed during download operation: 00:00:01.737


Verifying ...

Download verified successfully

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

Hello,

You need to initialize the memory first (GPIO and FMC) in SystemInit() / system_stm32h7xx.c.

If you look at system_stm32h7xx.c provided in one of the STM32H747I-EVAL examples you can find the following:

SofLit_0-1718360314113.png

So look at SystemInit_ExtMemCtl() implementation. You need to activate de definition DATA_IN_ExtSDRAM.

Also there is an example how to locate the global variables in the external SDRAM in x-cube-perf-h7  related to the AN4891 STM32H72x, STM32H73x, and single-core STM32H74x/75x
system architecture and performance

Look at the project config 6 where the code is executed in ITCM and all variables are located in SDRAM:

SofLit_1-1718360536165.png

Advice: before starting to relocate your variables in SDRAM, you need to do some read/write tests to validate that the SDRAM access is correct and you don't get any read/write issues.

Hope it helps.

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

4 REPLIES 4

Your SystemInit() code needs to bring up the clocks, PLLs and SDRAM so code in startup.s can initialize the statics. Doing it in main() is too late.

The HardFault_Handler indicates that the memory you are touching is not functional.

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

Hello,

You need to initialize the memory first (GPIO and FMC) in SystemInit() / system_stm32h7xx.c.

If you look at system_stm32h7xx.c provided in one of the STM32H747I-EVAL examples you can find the following:

SofLit_0-1718360314113.png

So look at SystemInit_ExtMemCtl() implementation. You need to activate de definition DATA_IN_ExtSDRAM.

Also there is an example how to locate the global variables in the external SDRAM in x-cube-perf-h7  related to the AN4891 STM32H72x, STM32H73x, and single-core STM32H74x/75x
system architecture and performance

Look at the project config 6 where the code is executed in ITCM and all variables are located in SDRAM:

SofLit_1-1718360536165.png

Advice: before starting to relocate your variables in SDRAM, you need to do some read/write tests to validate that the SDRAM access is correct and you don't get any read/write issues.

Hope it helps.

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Let's try it that way.

Hello @thyu ,

Did you already solve your issue? if yes, please close this thread by clicking on Accept as solution the comment that answered your question.

Thank you.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.