2025-07-17 12:43 AM
hi
i use STM32cubeMX to generate project files in STM32cubeIDE, and hope use some bsp function(like BSP_XSPI_NOR_Init) in this project, but no matter how i try, i can not find any bsp function in it.
who knows to solve this problem?
(Now I have to manually handle this issue by copy this function from other .c,and this method is very inconvenient )
thanks!!!
2025-07-17 12:53 AM
Hello @cxf,
I think what you are looking for is in the cubeN6 package in your local stm32cubeMX folder, for example:
C:\Users\YOUR_USER_NAME\STM32Cube\Repository\STM32Cube_FW_N6_V1.2.0\Drivers\BSP\STM32N6570-DK\stm32n6570_discovery_xspi.c
line 200:
int32_t BSP_XSPI_NOR_Init(uint32_t Instance, BSP_XSPI_NOR_Init_t *Init)
{
int32_t ret;
BSP_XSPI_NOR_Info_t pInfo;
MX_XSPI_InitTypeDef xspi_init;
/* Check if the instance is supported */
if (Instance >= XSPI_NOR_INSTANCES_NUMBER)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
/* Check if the instance is already initialized */
if (XSPI_Nor_Ctx[Instance].IsInitialized == XSPI_ACCESS_NONE)
{
#if (USE_HAL_XSPI_REGISTER_CALLBACKS == 0)
/* Msp XSPI initialization */
XSPI_NOR_MspInit(&hxspi_nor[Instance]);
#else
/* Register the XSPI MSP Callbacks */
if (XSPINor_IsMspCbValid[Instance] == 0UL)
{
if (BSP_XSPI_NOR_RegisterDefaultMspCallbacks(Instance) != BSP_ERROR_NONE)
{
return BSP_ERROR_PERIPH_FAILURE;
}
}
#endif /* USE_HAL_XSPI_REGISTER_CALLBACKS */
/* Get Flash information of one memory */
(void)MX66UW1G45G_GetFlashInfo(&pInfo);
/* Fill config structure */
xspi_init.ClockPrescaler = 0x03; /* XSPI clock = 200MHz / ClockPrescaler = 50MHz, then switch to 200MHz*/
xspi_init.MemorySize = (uint32_t)POSITION_VAL((uint32_t)pInfo.FlashSize);
xspi_init.SampleShifting = HAL_XSPI_SAMPLE_SHIFT_NONE;
xspi_init.TransferRate = (uint32_t)Init->TransferRate;
/* STM32 XSPI interface initialization */
if (MX_XSPI_NOR_Init(&hxspi_nor[Instance], &xspi_init) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
/* XSPI memory reset */
else if (XSPI_NOR_ResetMemory(Instance) != BSP_ERROR_NONE)
{
ret = BSP_ERROR_COMPONENT_FAILURE;
}
/* Check if memory is ready */
else if (MX66UW1G45G_AutoPollingMemReady(&hxspi_nor[Instance], XSPI_Nor_Ctx[Instance].InterfaceMode,
XSPI_Nor_Ctx[Instance].TransferRate) != MX66UW1G45G_OK)
{
ret = BSP_ERROR_COMPONENT_FAILURE;
}
/* Configure the memory */
else if (BSP_XSPI_NOR_ConfigFlash(Instance, Init->InterfaceMode, Init->TransferRate) != BSP_ERROR_NONE)
{
ret = BSP_ERROR_COMPONENT_FAILURE;
}
else
{
ret = BSP_ERROR_NONE;
}
}
else
{
ret = BSP_ERROR_NONE;
}
}
If you use the Nucleo board, you have the equivalent in the nucleo folder.
Have a good day,
Julian
2025-07-17 1:43 AM
thanks to Julian E
As you said : BSP_XSPI_NOR_Init is in the stm32n6570_discovery_xspi.c. I need to copy it to my project files manually.
But my problem is: can STM32cubeMX automatic add BSP in generation code stage?
or else i must manually add this file after every generation code stage.
thanks very much!
2025-07-17 6:42 AM
If you choose the nucleo board when you are creating the project using the Board Selector, the BSP will be added. If you choose the chip, it will not.
If you find this is not the case, please include your IOC file.
2025-07-17 8:11 AM
@TDK wrote:If you choose the nucleo board when you are creating the project using the Board Selector, the BSP will be added. If you choose the chip, it will not.
@cxf That makes sense: BSP = Board Support Package - so only makes sense when a known Board is selected.
2025-07-17 5:58 PM