2025-09-03 2:08 AM
Hello,
I'm working on a firmware which currently run in USB vendor interface (bInterfaceClass = 0xFF) and it's working.
Now I want to add MassStorage. My Firmware is a bit older so I add all usb composite parte by my self (in usbd_core ...) . I defined USE_USBD_COMPOSITE and set :
#define USBD_CMPSIT_ACTIVATE_MSC 1
#define USBD_CMPSIT_ACTIVATE_CUSTOMHID 1
#define USBD_MAX_CLASS_INTERFACES 2U
#define USBD_MAX_SUPPORTED_CLASS 2U
#define USBD_MAX_CLASS_ENDPOINTS 2U
(I use custom HID class for the Vendor interface and I edited USBD_CMPSIT_CUSTOMHIDDesc )
I set Msc first 'cause I read that some OS prefer.
Init function :
void MX_USB_DEVICE_Init(void)
{
#ifdef STM32H7xx
HAL_PWREx_EnableUSBVoltageDetector();
#endif //STM32H7xx
/* Init Device Library, add supported class and start the library. */
if (USBD_Init(&hUsbDeviceHS, &HS_Desc, DEVICE_HS) != USBD_OK)
{
DEBUG_PRINTF("[MX_USB_DEVICE_Init] USB failed to init \r\n");
}
//register classes
MassStorage_InstID = hUsbDeviceHS.classId;
USBD_RegisterClassComposite(&hUsbDeviceHS, &MassStorageDevice, CLASS_TYPE_MSC,MassStorage_EpAdress);
Usb_InstID = hUsbDeviceHS.classId;
USBD_RegisterClassComposite(&hUsbDeviceHS, &Usb_STM32xx, CLASS_TYPE_CHID, Usb_EpAdress);
if (USBD_CMPSIT_SetClassID(&hUsbDeviceHS, CLASS_TYPE_MSC, 0) != 0xFF)
{
if(RegisterStorage(&hUsbDeviceHS, &MassStorage_fops_HS) != USBD_OK)
{
DEBUG_PRINTF("[MX_USB_DEVICE_Init] register MassStorage interface failed to init \r\n");
}
}
//register interfaces
if (USBD_CMPSIT_SetClassID(&hUsbDeviceHS, CLASS_TYPE_CHID, 0) != 0xFF)
{
if (Usb_RegisterInterface(&hUsbDeviceHS, &Usb_fops_HS) != USBD_OK)
{
DEBUG_PRINTF("[MX_USB_DEVICE_Init] register Usb interface failed to init \r\n");
}
}
}
But when I run I feel like the first interface start (Msc) and then stop responding when the second try to start and when nothing works.
Does anyone have any idea what I'm doing wrong?
2025-09-03 2:14 AM
I didn't specify, but it's a Vendor type with two bulk endpoints (1 IN and 1 OUT).