Skip to main content
Inbara
Associate
Jan 19, 2023 5:03 PM UTC
Question

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

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
Jan 30, 2023 4:13 PM UTC

Hello @Inbara​ and welcome to the community,

Could you please specify the used board?

Mohamed Aymen

Inbara
InbaraAuthor
Associate
Jan 31, 2023 10:36 AM UTC

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
Jan 31, 2023 2:17 PM UTC

Can you please share your .ioc file ?

Mohamed Aymen

Inbara
InbaraAuthor
Associate
Jan 31, 2023 3:27 PM UTC

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
Jan 31, 2023 3:52 PM UTC

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
Feb 8, 2023 5:01 PM UTC

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