STM32/STM8技术论坛
直播中

Lewoyen

6年用户 4经验值
擅长:嵌入式技术 接口/总线/驱动
私信 关注
[问答]

求教整过USB多功能接口设备的帮忙看看啊

这是整合的一个多功能接口设备的描述符,实现CDC+Mass Storage两个设备功能,描述符如下:
unsigned char device_framework_high_speed[] = {
    /* Device descriptor */
    0x12,
    0x01,
    0x00, 0x02,
    0xEF,
    0x02,
    0x01,
    0x40,
    0x84, 0x84,
    0x00, 0x01,
    0x00, 0x01,
    0x01,
    0x02,
    0x03,
    0x01,                        //bNumConfigurations:configuration 1

    /* Device qualifier descriptor */
    0x0a, 0x06, 0x00, 0x02, 0x02, 0x00, 0x00, 0x40,
    0x01, 0x00,

    /* Configuration 1 descriptor */
    0x09,
    0x02,
    0x59, 0x00,                //wTotallength=97
    0x03,                        //bNumInterfaces
    0x01,                        //bConfigurationValue:Enable configuration 1
    0x00,
    0x80,
    0x32,

    /* Interface association descriptor of CDC. */
    0x08,
    0x0b,
    0x00,                        //bFirstInterface
    0x02,                        //bInterfaceCount
    0x02,                        //bFunctionClass:2--CDC
    0x02,
    0x00,
    0x00,

/**********************************The Descriptor of CDC *************************************/
    /* Communication Class Interface Descriptor Requirement */
    0x09,
    0x04,
    0x00,                        //bInterfaceNumber
    0x00,
    0x01,                        //bNumEndpoints:one Endpoint(0x84)
    0x02,                        //bInterfaceClass:2--CDC
    0x02,
    0x01,
    0x00,

    /* Header Functional Descriptor */
    0x05,
    0x24,
    0x00,
    0x10, 0x01,                //bcdCDC

    /* ACM Functional Descriptor */
    0x04,
    0x24,
    0x02,
    0x0f,

    /* Union Functional Descriptor */
    0x05,
    0x24,
    0x06,
    0x00,                        //bMasterInterface
    0x01,                        //bSlaveInterface0:Data Class Interface

    /* Call Management Functional Descriptor */
    0x05,
    0x24,
    0x01,
    0x03,
    0x01,

    /* Endpoint 1 descriptor */
    0x07,
    0x05,
    0x81,                        //bEndpointAddress:IN, EndpointID=1
    0x03,                        //bmAttributes:Interrupt
    0x08, 0x00,                //wMaxPacketSize
    0x0b,                        //bInterval

    /* Data Class Interface Descriptor Requirement */
    0x09,
    0x04,
    0x01,                        //bInterfaceNumber
    0x00,
    0x02,                        //bNumEndpoints:two endpoints for IN_endpoints and OUT_endpoints
    0x0A,                        //bInterfaceClass:0A--CDC
    0x00,
    0x00,
    0x00,

    /* First alternate setting Endpoint 2 descriptor */
    0x07,
    0x05,
    0x02,                        //bEndpointAddress:OUT, EndpointID=2
    0x02,                        //bmAttributes:Bulk
    0x00, 0x02,                //wMaxPacketSize:0200h=512--high_speed
    0x00,

    /* Endpoint 3 descriptor */
    0x07,
    0x05,
    0x83,                        //bEndpointAddress:IN, EndpointID=3
    0x02,                        //bmAttributes:Bulk
    0x00, 0x02,                //wMaxPacketSize:0200h=512--high_speed
    0x00,

    /************************************************************************************************************/
    #if 0
        /* Interface association descriptor of Mass Storage. */
        0x08,
        0x0b,
        0x01,                        //bFirstInterface
        0x01,                        //bInterfaceCount
        0x08,                        //bFunctionClass:08--MASS STORAGE Class
        0x06,
        0x00,
        0x00,
    #endif
    /*******************************The descriptor of Mass Storage  ************************************/

        /* Mass Storage Class Interface Descriptor Requirement */
        0x09,
        0x04,
        0x02,                        //bInterfaceNumber
        0x00,                   //bAlternateSetting
        0x02,                   //bNumEndpoints:two endpoints for IN and OUT
        0x08,                   //bInterfaceClass:08--MASS STORAGE Class
        0x06,                   //bInterfaceSubClass:SCSI transparent
        0x50,
        0x00,

        /* Mass Storage Class Endpoint 4 Descriptor Requirement */
        0x07,
        0x05,
        0x84,                        //bEndpointAddress:IN, EndpointID=4
        0x02,                   //bmAttributes:Bulk
        0x00, 0x02,                //wMaxPacketSize:0200h=512--high_speed
        0x00,

        /* Mass Storage Class Endpoint 5 Descriptor Requirement */
        0x07,
        0x05,
        0x05,                        //bEndpointAddress:OUT, EndpointID=5
        0x02,                        //bmAttributes:Bulk
        0x00, 0x02,                //wMaxPacketSize:0200h=512--high_speed
        0x00,
/*********************************************************************************************/
};
将该描述符在目标平台运行并接入Linux主机,用“dmesg”查看打印信息如下:
[ 1925.208169] u*** 2-4: new high-speed USB device number 5 using ehci-pci
[ 1925.341185] u*** 2-4: config 1 has an invalid descriptor of length 7, skipping remainder of the config
[ 1925.341203] u*** 2-4: config 1 interface 2 altsetting 0 has 0 endpoint descriptors, different from the interface descriptor's value: 2
[ 1925.342182] u*** 2-4: New USB device found, idVendor=8484, idProduct=0100
[ 1925.342190] u*** 2-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1925.342197] u*** 2-4: Product: EL Composite device
[ 1925.342203] u*** 2-4: Manufacturer: Expres Logic
[ 1925.342209] u*** 2-4: SerialNumber: 0001
[ 1925.380015] cdc_acm 2-4:1.0: ttyACM0: USB ACM device
[ 1925.380545] u***core: registered new interface driver cdc_acm
[ 1925.380548] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
[ 1925.392882] u***-storage 2-4:1.2: USB Mass Storage device detected
[ 1925.394796] u***-storage: probe of 2-4:1.2 failed with error -5
[ 1925.394834] u***core: registered new interface driver u***-storage
[ 1925.437745] u***core: registered new interface driver uas
第二条和第三条报错怎么改也都有......还有Mass Storage能被检测到,但失败了,根据“probe of 2-4:1.2 failed with error -5”报错信息也没查到,是因为缺少处理Mass Storage接口的命令吗?因为这个是自己添加的,CDC是原先USB协议栈里自带定义好的.......
大伙帮忙看看,拜谢了!

已退回3积分

更多回帖

发帖
×
20
完善资料,
赚取积分