Skip to main content
Visitor II
August 17, 2026
Question

Should we use External Memory Manager or the official Flash/SRAM driver?

I'm currently developing with the STM32N6570-DK, using STM32N6 1.4.0 firmware, and using AI Studio and CubeMX to generate projects.

However, I've encountered a very confusing problem. In the program generated by AI Studio, after calling MX_EXTMEM_MANAGER_Init() in the FSBL, it calls functions like BSP_XSPI_NOR_Init() and BSP_XSPI_RAM_Init(). This seems to be an additional Flash and SRAM driver written separately by the official documentation.

  /* Initialize all configured peripherals */
MX_GPIO_Init();
MX_XSPI1_Init();
MX_XSPI2_Init();
MX_EXTMEM_MANAGER_Init();
/* USER CODE BEGIN 2 */
__HAL_RCC_AXISRAM2_MEM_CLK_ENABLE();
__HAL_RCC_AXISRAM3_MEM_CLK_ENABLE();
__HAL_RCC_AXISRAM4_MEM_CLK_ENABLE();
__HAL_RCC_AXISRAM5_MEM_CLK_ENABLE();
__HAL_RCC_AXISRAM6_MEM_CLK_ENABLE();
/** Workaround for an issue generated in STM32CubeN6 FW 1.4.0 **/
extern XSPI_NOR_Ctx_t XSPI_Nor_Ctx[XSPI_NOR_INSTANCES_NUMBER];
XSPI_Nor_Ctx[0].InterfaceMode = BSP_XSPI_NOR_OPI_MODE;
XSPI_Nor_Ctx[0].TransferRate = BSP_XSPI_NOR_STR_TRANSFER;
/** end of workaround **/

BSP_XSPI_NOR_Init_t xspiInit;
xspiInit.InterfaceMode = MX66UW1G45G_OPI_MODE;
xspiInit.TransferRate = MX66UW1G45G_DTR_TRANSFER;
BSP_XSPI_NOR_Init(0,&xspiInit);
BSP_XSPI_NOR_EnableMemoryMappedMode(0);
MODIFY_REG(XSPI2->CR, XSPI_CR_NOPREF, HAL_XSPI_AUTOMATIC_PREFETCH_DISABLE);

BSP_XSPI_RAM_Init(0);
BSP_XSPI_RAM_EnableMemoryMappedMode(0);
MODIFY_REG(XSPI1->CR, XSPI_CR_NOPREF, HAL_XSPI_AUTOMATIC_PREFETCH_DISABLE);
BSP_XSPI_RAM_Init(0);
BSP_XSPI_RAM_EnableMemoryMappedMode(0);
MODIFY_REG(XSPI1->CR, XSPI_CR_NOPREF, HAL_XSPI_AUTOMATIC_PREFETCH_DISABLE);

/* USER CODE END 2 */

 

But my understanding is that External Memory Manager officially states it already supports APS256XXN-OBR-BG and MX66UW1G45GXDI00, which are the Flash and SRAM used on the N6570-DK. Shouldn't it directly use the EMM without needing to import a separate driver?

 

Furthermore, the FSBL generated by AI Studio also implements some workarounds that appear to be problematic in version 1.4.0

Because the information online is so mixed, I really can't understand what the official recommended implementation method is now.

1 reply

hamitiya
ST Technical Moderator
October 1, 2026

Hello ​@Wayne Wang ,

Indeed, in version 1.4.0, BSP had an issue and a patch has been added in STM32Cube AI Studio. However, with version 1.4.1, this patch is not needed anymore.

 

For your question:

STM32Cube AI Studio uses BSP since it provides directly the optimal settings for a given hardware (in your case, STM32N6570-DK).

If you use External Memory Manager, you can avoid usage of BSP and manage yourself enablement and settings of your memories.

Be aware that using EMM also has incidence in the linker scripts generated by STM32CubeMX.

 

STM32Cube AI Studio, as an example, only uses EMM to enable External NOR FLASH (in order to use eXecute in place / XIP mode), not for External PSRAM.

 

 

Best regards,

Yanis

​In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.