cancel
Showing results for 
Search instead for 
Did you mean: 

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

cxf
Associate II

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

5 REPLIES 5
Julian E.
ST Employee

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.

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

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

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Thanks to Andrew Neil  and TDK.

I think i have chose the board(STM32N6570-DK Board) in the MX,like this:

cxf_0-1752799860173.png

 

but i still have this problem,why? 

this is my ioc file MX61504.ioc in the attach, please help me,thanks!