2026-02-22 7:46 AM
I am using the STM32N6570-DK and I want to use the external PSRAM to declare a large variable buffer. Here is what I have done:
1. Initialized XSPI1 and the External Memory Manager. The PSRAM parameters I got from How to execute code from the external PSRAM using the STM32N6 .
2. Set the XSPI1 clock to 200MHz. Here is my system clock configuration:
Here is my main code from the FSBL. I also added a `gpio_toggle` to turn the user LED on before `MX_EXTMEM_MANAGER_Init()` as a debug indicator.
After adding the header and programming, the FSBL boots correctly — the user LED turns on — but then it gets stuck at `MX_EXTMEM_MANAGER_Init()` and never jumps into the `while` loop.
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MPU Configuration--------------------------------------------------------*/
MPU_Config();
/* Enable the CPU Cache */
/* Enable I-Cache---------------------------------------------------------*/
SCB_EnableICache();
/* Enable D-Cache---------------------------------------------------------*/
SCB_EnableDCache();
/* MCU Configuration--------------------------------------------------------*/
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART2_UART_Init();
MX_XSPI1_Init();
MX_XSPI2_Init();
HAL_GPIO_TogglePin(GPIOO, GPIO_PIN_1);
MX_EXTMEM_MANAGER_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_GPIO_TogglePin(GPIOO, GPIO_PIN_1);
HAL_Delay(1000);
}
/* USER CODE END 3 */
}**Questions:**
1. Did I configure something wrong? Is there anything else that needs to be configured?
2. Is there another way to place an image buffer into RAM?
**Tools used:**
- STM32CubeMX 6.16.1
- STM32CubeIDE 2.0.0
- STM32CubeProgrammer 2.21.0
Solved! Go to Solution.
2026-02-26 3:15 AM
hello
After debugging, I found the source of the error. Even though I configured XSPI1, the logic level of the XSPI pins was still 3.3V, but 1.8V is required for XSPI. What I did was set the IO range of VDDIO2 to 1.8V in HAL_MspInit().
void HAL_MspInit(void)
{
/* USER CODE BEGIN MspInit 0 */
/* USER CODE END MspInit 0 */
/* System interrupt init*/
HAL_PWREx_EnableVddIO2();
HAL_PWREx_EnableVddIO3();
/* USER CODE BEGIN MspInit 1 */
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWREx_ConfigVddIORange(PWR_VDDIO2, PWR_VDDIO_RANGE_1V8);
/* USER CODE END MspInit 1 */
}To use PSRAM as internal RAM, after configuring XSPI, you need to set it into memory map mode first. After that, just place the following function from my given file. I used the XSPI memory map example from ST Electronics' GitHub as my reference.
Configure_APMemory();
PSRAM_Init_Sequence();
MX_XSPI1_Init();
SystemIsolation_Config();
//MX_EXTMEM_MANAGER_Init();
/* USER CODE BEGIN 2 */
Configure_APMemory();
PSRAM_Init_Sequence();
2026-02-23 4:25 AM
Hi @pawatJoy
With the memories configured, you didn't configure the addresses and offsets in boot use case tab copying from the serial FLASH NOR (Memory 1) to the external PSRAM (Memory 2)
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.
2026-02-26 3:15 AM
hello
After debugging, I found the source of the error. Even though I configured XSPI1, the logic level of the XSPI pins was still 3.3V, but 1.8V is required for XSPI. What I did was set the IO range of VDDIO2 to 1.8V in HAL_MspInit().
void HAL_MspInit(void)
{
/* USER CODE BEGIN MspInit 0 */
/* USER CODE END MspInit 0 */
/* System interrupt init*/
HAL_PWREx_EnableVddIO2();
HAL_PWREx_EnableVddIO3();
/* USER CODE BEGIN MspInit 1 */
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWREx_ConfigVddIORange(PWR_VDDIO2, PWR_VDDIO_RANGE_1V8);
/* USER CODE END MspInit 1 */
}To use PSRAM as internal RAM, after configuring XSPI, you need to set it into memory map mode first. After that, just place the following function from my given file. I used the XSPI memory map example from ST Electronics' GitHub as my reference.
Configure_APMemory();
PSRAM_Init_Sequence();
MX_XSPI1_Init();
SystemIsolation_Config();
//MX_EXTMEM_MANAGER_Init();
/* USER CODE BEGIN 2 */
Configure_APMemory();
PSRAM_Init_Sequence();