Skip to main content
Inbara
Associate
January 19, 2023
Question

I'm trying to generate code for a STM32U558 USB device The USB initialization function MX_USB_Device_Init is empty

  • January 19, 2023
  • 6 replies
  • 1700 views

STM32CubeMx version 6.7.0

STM32Cube_FW_U5_V1.1.1

STM32Cube_FW_U5_V1.1.1\Projects\B-U585I-IOT02A\Applications\USBX\Ux_Device_HID_CDC_ACM\Ux_Device_HID_CDC_ACM.ioc

Copying the ioc file to a new location, double clicking and clicking "generate code" shows the same problem

This topic has been closed for replies.

6 replies

Mohamed Aymen HZAMI
ST Employee
January 30, 2023

Hello @Inbara​ and welcome to the community,

Could you please specify the used board?

Mohamed Aymen

Inbara
InbaraAuthor
Associate
January 31, 2023

Hi,

Thanks for your reply

I'm using my own hardware, but my problem is not with the HW but with the SW generation phase

Using a sample ioc file for a B-U585I-IOT02A board has the same issue

Also, it would be very useful if there was a usb device sample that can be used without cleaning out the application code

Thanks!

Mohamed Aymen HZAMI
ST Employee
January 31, 2023

Can you please share your .ioc file ?

Mohamed Aymen

Inbara
InbaraAuthor
Associate
January 31, 2023

STM32Cube_FW_U5_V1.1.1\Projects\B-U585I-IOT02A\Applications\USBX\Ux_Device_HID_CDC_ACM\Ux_Device_HID_CDC_ACM.ioc

Mohamed Aymen HZAMI
ST Employee
January 31, 2023

It's not empty, this is what the function contains in the app_usbx_device.c file:

/**
 * @brief MX_USB_Device_Init
 * Initialization of USB device.
 * Init USB device Library, add supported class and start the library
 * @retval None
 */
void MX_USB_Device_Init(void)
{
 /* USER CODE BEGIN USB_Device_Init_PreTreatment_0 */
 /* USER CODE END USB_Device_Init_PreTreatment_0 */
 
 /* USB_OTG_HS init function */
 MX_USB_OTG_FS_PCD_Init();
 
 /* USER CODE BEGIN USB_Device_Init_PreTreatment_1 */
 HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80);
 HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x10);
 HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x20);
 HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 2, 0x10);
 HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 3, 0x10);
 /* USER CODE END USB_Device_Init_PreTreatment_1 */
 
 /* Initialize the device controller driver*/
 _ux_dcd_stm32_initialize((ULONG)USB_OTG_FS, (ULONG)&hpcd_USB_OTG_FS);
 
 /* USER CODE BEGIN USB_Device_Init_PostTreatment */
 /* USER CODE END USB_Device_Init_PostTreatment */
}

Mohamed Aymen

Inbara
InbaraAuthor
Associate
February 8, 2023

Sorry, what I needed was MX_USBX_Device_Init

In any case I found the answer

The MX_USBX_Device_Init function is not generated, it has to be written manually