2024-11-28 04:46 PM - last edited on 2024-11-28 11:41 PM by SofLit
Symptom:
STM32H7S78-DK board includes a 32MB PSRAM (APS256XXN-OBR-BG() connected to HEXASPI. Somehow only the first 4MB is accessable.
How to reproduce the error:
Use the template project provided in "STM32Cube_FW_H7RS_V1.1.0\Projects\STM32H7S78-DK\Templates\Template_XIP" add the following code in the app's main.c:
/* USER CODE BEGIN 0 */
#include <stdbool.h>
bool TestExRam()
{
unsigned char* address = (unsigned char*)0x90000000;
int ramSize;
ramSize = 32*1024*1024; // failed at 0x90400000 which means only 4MB RAM is accessible.
//ramSize = 4*1024*1024; // passed test.
unsigned char* begin = address;
unsigned char* end = begin + ramSize;
unsigned char* p = begin;
char c = 0;
while(p < end) {
*p = c;
p++;
c++;
}
// Check whether the data is correct:
c = 0;
p = begin;
while(p < end) {
if (c != *p) {
// error!
return false;
}
c++;
p++;
}
return true;
}
/* USER CODE END 0 */
// Call the test function in user code section 2:
/* USER CODE BEGIN 2 */
/* Initialize LD1 */
BSP_LED_Init(LD1);
if (!TestExRam()) {
Error_Handler();
}
/* USER CODE END 2 */
A fault error will be generated when the RAM access loop goes beyond 0x90400000.
Any advice or insights to address this issue would be greatly appreciated.
Thank you!
David
2024-11-29 04:11 PM
The problem is solved.
Two issues were identified and resolved to fix the external memory error.
1. The App's linker file STM32H7S7L8HXH_ROMxspi1_RAMxspi2.ld (located in: STM32Cube_FW_H7RS_V1.1.0\Projects\STM32H7S78-DK\Templates\Template_XIP\STM32CubeIDE\Appli\) required an update to the external memory size.
The original value was:
__EXTRAM_SIZE = 0x00400000
It was updated to:
__EXTRAM_SIZE = 0x02000000
2. The external memory size specified in the STM32CubeIDE Configuration Editor located at Middleware and Software Packs -> EXTMEM_MANAGER -> Memory 2 -> Memory Size needed correction.
The original setting was 32MB, which was changed to 256MB.
It was noted that the editor interprets the value in megabits (Mbit), not megabytes (MB).
After updating the linker file and the .ioc file with the corrected memory size, regenerating the code, and rebuilding the project, the external RAM (32MB) worked as expected.
Best regards,
David