cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 USB Composite CDC + MSC

deanos
Associate II
Posted on February 13, 2014 at 14:16

I'm in the process of building a USB composite CDC + MSC device on the STM32F4 Discovery board but am having trouble getting windows to recognise it.

Using USBlyzer all the descriptor info seems ok but windows will only recognise the CDC (virtual com port). The port gets enumerated and I can open and close it but data goes to the wrong endpoint no matter how I swap them around. Also, windows completely ignores the MSC unless I disable the CDC and then it works fine. Is there some trick to the descriptors to get both drivers to load (virtual com port + mass storage) or do I need a custom driver or .inf file. I've tried disabling the devices using USBDeview and reinstalling as well as different PIDs but no luck. I've posted my descriptors below but am happy to post code or the whole project if it will help. Thanks.

#define USBD_VID 0x0483
#define USBD_PID 0x5000
#define USBD_LANGID_STRING 0x409
#define USBD_MANUFACTURER_STRING ''STMicroelectronics''
#define USBD_PRODUCT_HS_STRING ''Composite Device HS Mode''
#define USBD_SERIALNUMBER_HS_STRING ''000000000001''
#define USBD_PRODUCT_FS_STRING ''Composite Device FS Mode''
#define USBD_SERIALNUMBER_FS_STRING ''000000000001''
#define USBD_CONFIGURATION_HS_STRING ''CDC/MSC Config''
#define USBD_INTERFACE_HS_STRING ''CDC/MSC Interface''
#define USBD_CONFIGURATION_FS_STRING ''CDC/MSC Config''
#define USBD_INTERFACE_FS_STRING ''CDC/MSC Interface''
__ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC] __ALIGN_END =
{
0x12, /*bLength */
USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/
0x00, /*bcdUSB */
0x02,
0xEF, /*bDeviceClass*/
0x02, /*bDeviceSubClass*/
0x01, /*bDeviceProtocol*/
USB_OTG_MAX_EP0_SIZE, /*bMaxPacketSize*/
LOBYTE(USBD_VID), /*idVendor*/
HIBYTE(USBD_VID), /*idVendor*/
LOBYTE(USBD_PID), /*idVendor*/
HIBYTE(USBD_PID), /*idVendor*/
0x00, /*bcdDevice rel. 2.00*/
0x02,
USBD_IDX_MFC_STR, /*Index of manufacturer string*/
USBD_IDX_PRODUCT_STR, /*Index of product string*/
USBD_IDX_SERIAL_STR, /*Index of serial number string*/
USBD_CFG_MAX_NUM /*bNumConfigurations*/
} ; /* USB_DeviceDescriptor */
/* USB device Configuration Descriptor */
__ALIGN_BEGIN static uint8_t USBD_CDC_MSC_CfgDesc[DESCRIPTOR_TOTAL_LENGTH] __ALIGN_END =
{
/* Generic part */
// CONFIGURATION DESCRIPTOR (9 bytes)
0x09, // bLength
USB_CONFIGURATION_DESCRIPTOR_TYPE, // bDescriptorType
DESCRIPTOR_TOTAL_LENGTH, 0x00, // wTotalLength
0x03, // bNumInterfaces
0x01, // bConfigurationvalue
0x00, // iConfiguration Description offset
0xC0, // bmAttributes, self powered
0x32, // Max. Power Consumption
// IAD
0x08, // bLength: Interface Descriptor size
0x0B, // bDescriptorType: IAD
0x00, // bFirstInterface
0x03, // bInterfaceCount
0x02, // bFunctionClass: CDC
0x02, // bFunctionSubClass
0x01, // bFunctionProtocol 
0x02, // iFunction
/*Interface Descriptor*/
0x09, /* bLength: Interface Descriptor size */
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: Interface */
/* Interface descriptor type */
0x00, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */
0x01, /* bNumEndpoints: One endpoints used */
0x02, /* bInterfaceClass: Communication Interface Class */
0x02, /* bInterfaceSubClass: Abstract Control Model */
0x01, /* bInterfaceProtocol: Common AT commands */
0x00, /* iInterface: */
/*Header Functional Descriptor*/
0x05, /* bLength: Endpoint Descriptor size */
0x24, /* bDescriptorType: CS_INTERFACE */
0x00, /* bDescriptorSubtype: Header Func Desc */
0x10, /* bcdCDC: spec release number */
0x01,
/*Call Managment Functional Descriptor*/
0x05, /* bFunctionLength */
0x24, /* bDescriptorType: CS_INTERFACE */
0x01, /* bDescriptorSubtype: Call Management Func Desc */
0x00, /* bmCapabilities: D0+D1 */
0x01, /* bDataInterface: 1 */
/*ACM Functional Descriptor*/
0x04, /* bFunctionLength */
0x24, /* bDescriptorType: CS_INTERFACE */
0x02, /* bDescriptorSubtype: Abstract Control Management desc */
0x02, /* bmCapabilities */
/*Union Functional Descriptor*/
0x05, /* bFunctionLength */
0x24, /* bDescriptorType: CS_INTERFACE */
0x06, /* bDescriptorSubtype: Union func desc */
0x00, /* bMasterInterface: Communication class interface */
0x01, /* bSlaveInterface0: Data Class Interface */
/*Endpoint 2 Descriptor*/
0x07, /* bLength: Endpoint Descriptor size */
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
CDC_CMD_EP, /* bEndpointAddress: (IN2) */
0x03, /* bmAttributes: Interrupt */
0x08, 0x00, /* wMaxPacketSize: */
0xFF, /* bInterval: */
/*Data class interface descriptor*/
0x09, /* bLength: Endpoint Descriptor size */
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: */
0x01, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints: Two endpoints used */
0x0A, /* bInterfaceClass: CDC */
0x00, /* bInterfaceSubClass: */
0x00, /* bInterfaceProtocol: */
0x00, /* iInterface: */
/*Endpoint 3 Descriptor*/
0x07, /* bLength: Endpoint Descriptor size */
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
CDC_OUT_EP, /* bEndpointAddress: (OUT3) */
0x02, /* bmAttributes: Bulk */
0x40, 0x00, /* wMaxPacketSize: */
0x00, /* bInterval: ignore for Bulk transfer */
/*Endpoint 1 Descriptor*/
0x07, /* bLength: Endpoint Descriptor size */
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
CDC_IN_EP, /* bEndpointAddress: (IN1) */
0x02, /* bmAttributes: Bulk */
0x40, 0x00, /* wMaxPacketSize: */
0x00, /* bInterval */
// -------- Descriptor for MSC class device ------------------------
// INTERFACE DESCRIPTOR (9 bytes) 
0x09, // bLength 
USB_INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType: 4 
0x02, // bInterfaceNumber
0x00, // bAlternateSetting
0x02, // bNumEndpoints
0x08, // bInterfaceClass: 8 = MSC Device
0x06, // bInterfaceSubClass:
0x50, // bInterfaceProtocol:
0x01, // iInterface:1
0x07, // bLength
USB_ENDPOINT_DESCRIPTOR_TYPE, // bDescriptorType
MSC_IN_EP, // bEndpointAddress; bit7=1 for IN, bits 3-0=1 for ep1
0x02, // *** bmAttributes, bulk
0x40, 0x00, // wMaxPacketSize, 64 bytes
0X00, // bInterval, ms
0x07, // bLength
USB_ENDPOINT_DESCRIPTOR_TYPE, // bDescriptorType
MSC_OUT_EP, // bEndpointAddress; bit7=1 for IN, bits 3-0=1 for ep1
0x02, // *** bmAttributes, bulk
0x40, 0x00, // wMaxPacketSize, 64 bytes
0x00 // bInterval, ms 
};

#msc #stm32f4 #composite #cdc
1 REPLY 1
ersan
Associate II
Posted on September 08, 2014 at 13:39

Hi,

I want to use the STM32 F4 Discovery as a composite device too.

Did you made some progress?

Is it possible to get the Project?

Best regards,

Emilio