STM32F4 USB Composite CDC + MSC

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
};

STM32F4 HAL Composite USB Device Example

Hi,

The STM32Cube FW package includes examples based on elementary USB classes (MSC, HID, CDC,...). 
Multi-interface applications (composite) are not yet developed. We’ll notify our development team about this subject.

Regards,
Heisenberg.

Thank you.

Could you please tell me if it is currently possible to achieve a composite USB device using the current version of STM32CubeF4 HAL library (so it is just lacking an example demonstration) or the libraries should be changed first (hopefully in the near future) to do that?

And, thank you for the STM32Cube initiative, it's still not as mature as the StdPeriph libraries, but I'm sure it will be, soon enough.

Hi,

It is possible to achieve your own composite USB Device, by combining the desired classes' drivers into one class, under your own folder within: Middlewares\ST\STM32_USB Device Library\Class

Regards,
Heisenberg.

STM32F4 HAL Composite USB Device Example : CDC + MSC的更多相关文章

  1. What is a Windows USB device path and how is it formatted?

    http://community.silabs.com/t5/Interface-Knowledge-Base/Windows-USB-Device-Path/ta-p/114059 Windows ...

  2. Power OFF and ON USB device in linux (ubuntu)

    Power OFF and ON USB device in linux (ubuntu) http://loginroot.com/power-off-and-on-usb-device-in-li ...

  3. Install Slax on USB device (Slax U 盘安装)

    Slax is a modern, portable, small and fast Linux operating system with a modular approach and outsta ...

  4. USB Device Finder

    http://www.velleman.eu/images/tmp/usbfind.c #ifdef __cplusplus extern "C" { #endif #includ ...

  5. Assigning Host USB device to a Guest VM

    Example Assigning Host USB device to a Guest VM This example is based on qemu-kvm (0.15.0) as instal ...

  6. usb host和usb device

    S3C2440的数据手册将USB功能分为两章--usb host和usb device.具体什么意思呢? usb host: 微处理器作为usb主设备,可以挂接U盘之类的从属设备. usb devic ...

  7. "The connection for the USB device '###' was unsuccessful. The device is currently in use"

    一.问题描述 1.情景描述 笔者的物理主机系统是“windows7 64位”,想使用“摄像头录像大师”.这个软件在录制视频的过程中,需要调用windows自带的"windows media ...

  8. USB device & USB controller & USB passthrough

    目录 USB device USB controller Linux 相关命令 Python 相关库 Libvirt USB passthrough 参考资料 近期往 openstack 里倒腾 US ...

  9. usb device address error 110

    ubuntu失灵了,怎么都起不来,报一堆错误usb device descriptor read/64, error 110......重启,换kvm的接口,usb键盘鼠标...终于在试了下面这个方法 ...

随机推荐

  1. <td>内容超出自动换行

    td 内容自动换行 table表格td设置宽度后文字太多自动换行 设置table 的 style="table-layout:fixed;" 然后设置td的 style=" ...

  2. 解决Tomcat6解压版在64位windows系统上无法启动服务的问题

    解决Tomcat6解压版在64位windows系统上无法启动服务的问题         由于客户环境为64位windows系统,开发环境一直用32位.tomcat使用6.0.20非安装版.部署时发现在 ...

  3. keepalived vrrp_script脚本不执行解决办法

    首先打开日志观察: tail -f /var/log/messages 然后新开一个客户端重启keepalived , systemctl restart keepalived.service 看日志 ...

  4. win10下安装MinGW-w64 - for 32 and 64 bit Windows

    对于不经常使用c语言的同学来说,只需要安装MinGW-w64 - for 32 and 64 bit Windows,就可以使用GCC在命令行对c源码进行编译. 首先打开命令行检查自己是否已经安装了g ...

  5. .Net Core连接RabbitMQ集群

    var connectionFactory = new ConnectionFactory() { //HostName = "192.168.205.128", 集群不在此处声明 ...

  6. 【ARTS】01_01_左耳听风-20181112~1116

    每周至少做一个 leetcode 的算法题.阅读并点评至少一篇英文技术文章.学习至少一个技术技巧.分享一篇有观点和思考的技术文章.(也就是 Algorithm.Review.Tip.Share 简称A ...

  7. 编程入门python之定义函数【转】

    编程入门python之定义函数 零基础学编程by学哥 2017-02-06 10:51 今天讲python函数. 输入参数求三角形或圆形或长方形的面积 先输入1个参数:形状类型 1=三角形 2=圆形 ...

  8. 大数据系列之数据仓库Hive命令使用及JDBC连接

    Hive系列博文,持续更新~~~ 大数据系列之数据仓库Hive原理 大数据系列之数据仓库Hive安装 大数据系列之数据仓库Hive中分区Partition如何使用 大数据系列之数据仓库Hive命令使用 ...

  9. ERP渠道管理添加验证和查询(二十二)

    添加联系人的后台代码: protected void btnSubmit_Click(object sender, EventArgs e) { BioErpCrmManageChannel chan ...

  10. ***linux下安装xampp,XAMPP目录结构(阿里云安装xampp)

    XAMPP目录结构 重要的文件和目录 文件/目录                              用途 /opt/lampp/bin/ XAMPP 命令库.例如 /opt/lampp/bin ...