espressif / esp-usb

Other
30 stars 16 forks source link

fix(host/cdc): Add case for CDC class in device descriptor (IEC-236) #89

Open zwizwa opened 5 days ago

zwizwa commented 5 days ago

Description

Added extra case in cdc_parse_is_cdc_compliant() to support CDC ACM device that has USB_CLASS_COMM set in the device descriptor.

Related

Testing

Tested on ESP32-S3 board connected to STM32F103 with CDC ACM descriptor. The STM32F103 is recognized in Linux as a ttyACMx device.


Checklist

Before submitting a Pull Request, please ensure the following:

zwizwa commented 5 days ago

The CDC ACM device's descriptors as printed by cdc_acm_host_desc_print()

*** Device descriptor ***
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0x2
bDeviceSubClass 0x0
bDeviceProtocol 0x0
bMaxPacketSize0 64
idVendor 0x483
idProduct 0x5740
bcdDevice 2.00
iManufacturer 1
iProduct 2
iSerialNumber 3
bNumConfigurations 1
*** Configuration descriptor ***
bLength 9
bDescriptorType 2
wTotalLength 67
bNumInterfaces 2
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
bMaxPower 100mA
    *** Interface descriptor ***
    bLength 9
    bDescriptorType 4
    bInterfaceNumber 0
    bAlternateSetting 0
    bNumEndpoints 1
    bInterfaceClass 0x2
    bInterfaceSubClass 0x2
    bInterfaceProtocol 0x1
    iInterface 0
    *** CDC Header Descriptor ***
    bcdCDC: 1.10
    *** CDC Call Descriptor ***
    bmCapabilities: 0x00
    bDataInterface: 1
    *** CDC ACM Descriptor ***
    bmCapabilities: 0x00
    *** CDC Union Descriptor ***
    bControlInterface: 0
    bSubordinateInterface[0]: 1
        *** Endpoint descriptor ***
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x83   EP 3 IN
        bmAttributes 0x3    INT
        wMaxPacketSize 16
        bInterval 255
    *** Interface descriptor ***
    bLength 9
    bDescriptorType 4
    bInterfaceNumber 1
    bAlternateSetting 0
    bNumEndpoints 2
    bInterfaceClass 0xa
    bInterfaceSubClass 0x0
    bInterfaceProtocol 0x0
    iInterface 0
        *** Endpoint descriptor ***
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x1    EP 1 OUT
        bmAttributes 0x2    BULK
        wMaxPacketSize 64
        bInterval 1
        *** Endpoint descriptor ***
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x82   EP 2 IN
        bmAttributes 0x2    BULK
        wMaxPacketSize 64
        bInterval 1
peter-marcisovsky commented 4 days ago

Hi @zwizwa thanks for the PR, we will take a look

tore-espressif commented 3 days ago

@zwizwa the changes LGTM! Could you please share full configuration and device descriptor in hex format? I'd like to add it to our tests

zwizwa commented 1 day ago

@zwizwa the changes LGTM! Could you please share full configuration and device descriptor in hex format? I'd like to add it to our tests

Sure. Is there a simple way to let the ACM firmware print the hex dumps?