Skip to main content
Associate II
July 17, 2025
Question

there is no bsp function in STM32cubeIDE project files(generated by stm32cubeMX)?

  • July 17, 2025
  • 2 replies
  • 670 views

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!!!

2 replies

Julian E.
Technical Moderator
July 17, 2025

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

​In order 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.
cxfAuthor
Associate II
July 17, 2025

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!

TDK
Super User
July 17, 2025

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.

"If you feel a post has answered your question, please click ""Accept as Solution""."
TDK
Super User
July 22, 2025

This board doesn't seem to be supported by CubeMX for generating/including the BSP library. Probably because it's new.

"If you feel a post has answered your question, please click ""Accept as Solution""."