You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何调试双CDC接口USB设备的CDC ACM探测失败(错误-16)

双CDC接口USB复合设备探测失败问题

我正在开发一款带两个CDC接口的USB复合设备,基于芯片供应商的复合设备Demo修改:复制CDC描述符(已修改端点和接口编号),移除多余类描述符,添加对第二个CDC实例(使用独立端点)的支持。

目前只有第一个接口能被内核正常探测,第二个接口报错:

[186246.734619] usb 6-3.1.2.2: USB disconnect, device number 97
[186247.753706] usb 6-3.1.2.2: new high-speed USB device number 98 using xhci_hcd
[186247.885115] usb 6-3.1.2.2: New USB device found, idVendor=03eb, idProduct=2404, bcdDevice= 1.00
[186247.885119] usb 6-3.1.2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[186247.885121] usb 6-3.1.2.2: Product: myname
[186247.885122] usb 6-3.1.2.2: Manufacturer: mystuff
[186247.885123] usb 6-3.1.2.2: SerialNumber: 123456789ABCDEF
[186247.982684] cdc_acm 6-3.1.2.2:1.0: ttyACM0: USB ACM device
[186247.983128] cdc_acm: probe of 6-3.1.2.2:1.2 failed with error -16

我已经追踪固件中所有函数调用,两个CDC实例的执行逻辑完全一致(仅接口编号和端点不同)。内核会尝试为两个实例设置CDC线路编码,用Wireshark+usbmon抓包显示流量完全相同。第一个CDC工作正常,可在终端正常收发数据。

错误码-16对应EBUSY,我在内核源码的acm_suspend()函数里找到了该错误的触发点,请问该如何调试这个问题?

以下是lsusb识别到的描述符:

Bus 006 Device 098: ID 03eb:2404 Atmel Corp. The Micro
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2 
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x03eb Atmel Corp.
  idProduct          0x2404 The Micro
  bcdDevice            1.00
  iManufacturer           1 myname
  iProduct                2 mystuff
  iSerial                 3 123456789ABCDEF
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x008d
    bNumInterfaces          4
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         2
      bFunctionClass          2 Communications
      bFunctionSubClass       2 Abstract (modem)
      bFunctionProtocol       1 AT-commands (v.25ter)
      iFunction               0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         2 Communications
      bInterfaceSubClass      2 Abstract (modem)
      bInterfaceProtocol      1 AT-commands (v.25ter)
      iInterface              0 
      CDC Header:
        bcdCDC               10.01
      CDC Call Management:
        bmCapabilities       0x01
          call management
        bDataInterface          0
      CDC ACM:
        bmCapabilities       0x02
          line coding and serial state
      CDC Union:
        bMasterInterface        0
        bSlaveInterface         1 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              10
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass        10 CDC Data
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         2
      bInterfaceCount         2
      bFunctionClass          2 Communications
      bFunctionSubClass       2 Abstract (modem)
      bFunctionProtocol       1 AT-commands (v.25ter)
      iFunction               0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         2 Communications
      bInterfaceSubClass      2 Abstract (modem)
      bInterfaceProtocol      1 AT-commands (v.25ter)
      iInterface              0 
      CDC Header:
        bcdCDC               10.01
      CDC Call Management:
        bmCapabilities       0x01
          call management
        bDataInterface          0
      CDC ACM:
        bmCapabilities       0x02
          line coding and serial state
      CDC Union:
        bMasterInterface        2
        bSlaveInterface         1 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x86  EP 6 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              10
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass        10 CDC Data
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x05  EP 5 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2 
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  bNumConfigurations      1
Device Status:     0x0000
  (Bus Powered)

排查&调试方案

  • 修复描述符核心错误
    从lsusb输出可见,第二个CDC的Union描述符中bSlaveInterface设为1,这是第一个CDC的数据接口,正确值应为3(第二个CDC对应的数据接口);同时Call Management描述符的bDataInterface也设为0,需改为3。内核会因两个CDC实例错误共享同一个数据接口,判定资源占用冲突,触发EBUSY错误。

  • 内核端调试

    • 重新编译内核时开启CONFIG_USB_CDC_ACM_DEBUG宏,获取CDC ACM驱动的详细调试日志
    • 用dmesg -w实时跟踪内核日志,观察第二个CDC探测阶段的完整错误流程
    • 执行usb-devices命令,确认接口关联关系,排查是否存在其他资源冲突
  • 固件端验证
    重新核对固件中第二个CDC的所有描述符配置,确保接口编号、端点地址、关联类描述符的参数完全独立,无复制Demo时的残留错误。


内容的提问来源于stack exchange,提问作者filo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.31 01:42:23