OpenOCD:无法在 WSL 中找到匹配的 CMSIS-DAP 设备

OpenOCD:无法在 WSL 中找到匹配的 CMSIS-DAP 设备

我正在尝试将 WSL 中的 GDB 连接到 Atmel SAMV71 Xplained Ultra 开发板。我在尝试让 OpenOCD 连接到开发板时遇到了问题。

我正在使用以下 OpenOCD 配置文件:

atmel_samv71_xplained_ultra_edbg.cfg

source [find interface/cmsis-dap.cfg]
source [find board/atmel_samv71_xplained_ultra.cfg]
source [find target/atsamv.cfg]

在 Windows 中使用 OpenOCD,我可以毫无问题地进行连接:

...
Debug: 62 214 target.c:1657 handle_target_init_command(): Initializing targets...
Debug: 63 216 semihosting_common.c:109 semihosting_common_init():
...
Debug: 70 333 cmsis_dap_usb_bulk.c:151 cmsis_dap_usb_open(): found product string of 0x03eb:0x2111 'EDBG CMSIS-DAP'
Debug: 71 337 cmsis_dap_usb_bulk.c:171 cmsis_dap_usb_open(): enumerating interfaces of 0x03eb:0x2111
Debug: 72 340 cmsis_dap_usb_bulk.c:218 cmsis_dap_usb_open(): found interface 0 string 'EDBG CMSIS-DAP'
Debug: 73 343 cmsis_dap_usb_bulk.c:238 cmsis_dap_usb_open(): skipping interface 0, endpoint[0] is not bulk out
Debug: 74 347 cmsis_dap_usb_bulk.c:231 cmsis_dap_usb_open(): skipping interface 1, has only 1 endpoints
Debug: 75 350 cmsis_dap_usb_bulk.c:238 cmsis_dap_usb_open(): skipping interface 2, endpoint[0] is not bulk out
Debug: 76 353 cmsis_dap_usb_bulk.c:238 cmsis_dap_usb_open(): skipping interface 3, endpoint[0] is not bulk out
...
Info : 84 483 cmsis_dap.c:1027 cmsis_dap_get_caps_info(): CMSIS-DAP: SWD supported
Info : 85 486 cmsis_dap.c:1004 cmsis_dap_get_version_info(): CMSIS-DAP: FW Version = 03.25.01B6
Info : 86 489 cmsis_dap.c:989 cmsis_dap_get_serial_info(): CMSIS-DAP: Serial# = ATML2407161800006103
Info : 87 492 cmsis_dap.c:1156 cmsis_dap_swd_open(): CMSIS-DAP: Interface Initialised (SWD)
Debug: 88 496 cmsis_dap.c:1238 cmsis_dap_init(): CMSIS-DAP: Packet Count = 4
Debug: 89 498 cmsis_dap.c:1241 cmsis_dap_init(): Allocating FIFO for 3 pending packets
Info : 90 501 cmsis_dap.c:1066 cmsis_dap_get_status(): SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1
Info : 91 506 cmsis_dap.c:1292 cmsis_dap_init(): CMSIS-DAP: Interface ready
...

我正在进行的项目需要许多 Linux 工具才能轻松构建,因此我尝试通过 WSL 进行连接。我已按照说明使用USBIPD

我正在使用 Windows 11,所以我认为不需要自定义内核:

$ uname -a
Linux DESKTOP-U0P8IUP 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

以下是udev我已经加载的规则(已用 检查和测试udevadm),并且我已确保我是 的成员plugdev

60-openocd.规则

ACTION!="add|change", GOTO="openocd_rules_end"
SUBSYSTEM=="gpio", MODE="0660", GROUP="plugdev", TAG+="uaccess"
SUBSYSTEM!="usb|tty|hidraw", GOTO="openocd_rules_end"
...
# Atmel SAMV71 Xplained Ultra
ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2111", MODE="660", GROUP="plugdev", TAG+="uaccess"
...
# CMSIS-DAP compatible adapters
ATTRS{product}=="*CMSIS-DAP*", MODE="660", GROUP="plugdev", TAG+="uaccess"
...

设备连接正常:

$ lsusb -v
...
Bus 001 Device 003: ID 03eb:2111 Atmel Corp. Xplained Pro board debugger and programmer
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          0x2111 Xplained Pro board debugger and programmer
  bcdDevice            1.01
  iManufacturer           1 Atmel Corp.
  iProduct                2 EDBG CMSIS-DAP
  iSerial                 3 ATML2407161800006103
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0082
    bNumInterfaces          4
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              4 EDBG CMSIS-DAP
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      35
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               1
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         1
      bInterfaceCount         2
      bFunctionClass          2 Communications
      bFunctionSubClass       2 Abstract (modem)
      bFunctionProtocol       1 AT-commands (v.25ter)
      iFunction               6 EDBG Virtual COM Port
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         2 Communications
      bInterfaceSubClass      2 Abstract (modem)
      bInterfaceProtocol      1 AT-commands (v.25ter)
      iInterface              0 
      CDC Header:
        bcdCDC               1.10
      CDC ACM:
        bmCapabilities       0x06
          sends break
          line coding and serial state
      CDC Union:
        bMasterInterface        1
        bSlaveInterface         2 
      CDC Call Management:
        bmCapabilities       0x03
          call management
          use DataInterface
        bDataInterface          2
      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               8
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass        10 CDC Data
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x05  EP 5 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol    255 Vendor Specific Protocol
      iInterface              5 EDBG Data Gateway
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x87  EP 7 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval             255
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x06  EP 6 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval             255
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)
...

但尝试连接 OpenOCD 会导致以下结果:

...
Debug: 71 5 target.c:1639 handle_target_init_command(): Initializing targets...
Debug: 72 5 semihosting_common.c:99 semihosting_common_init():  
...
Debug: 74 11 cmsis_dap_usb_bulk.c:156 cmsis_dap_usb_open(): found product string of 0x03eb:0x2111 'EDBG CMSIS-DAP'
Debug: 75 11 cmsis_dap_usb_bulk.c:176 cmsis_dap_usb_open(): enumerating interfaces of 0x03eb:0x2111
Debug: 76 12 cmsis_dap_usb_bulk.c:223 cmsis_dap_usb_open(): found interface 0 string 'EDBG CMSIS-DAP'
Debug: 77 12 cmsis_dap_usb_bulk.c:243 cmsis_dap_usb_open(): skipping interface 0, endpoint[0] is not bulk out
Debug: 78 12 cmsis_dap_usb_bulk.c:236 cmsis_dap_usb_open(): skipping interface 1, has only 1 endpoints
Debug: 79 12 cmsis_dap_usb_bulk.c:243 cmsis_dap_usb_open(): skipping interface 2, endpoint[0] is not bulk out
Debug: 80 13 cmsis_dap_usb_bulk.c:243 cmsis_dap_usb_open(): skipping interface 3, endpoint[0] is not bulk out
...
Error: 82 13 cmsis_dap.c:259 cmsis_dap_open(): unable to find a matching CMSIS-DAP device
Debug: 83 13 command.c:628 run_command(): Command 'init' failed with error code -4
...

找到后这个帖子,我检查了一下,发现在中遇到了同样的错误dmesg

$ dmesg| grep -i hid                                                                                                                                                    ⏎
[    0.348324] usbcore: registered new interface driver usbhid
[    0.348507] usbhid: USB HID core driver
[   48.383257] hid-generic 0003:03EB:2111.0001: device has no listeners, quitting

我编译了一个自定义内核并CONFIG_USB_HIDDEV启动它并确保它正在运行:

$ dmesg| grep -i hid
[    0.000000] Linux version 5.15.133.1-microsoft-standard-WSL2-with-HIDDEV+ (kyle@DESKTOP-U0P8IUP) (gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #1 SMP Tue Dec 5 13:09:53 EST 2023
[    0.369619] usb usb1: Manufacturer: Linux 5.15.133.1-microsoft-standard-WSL2-with-HIDDEV+ vhci_hcd
[    0.372640] usb usb2: Manufacturer: Linux 5.15.133.1-microsoft-standard-WSL2-with-HIDDEV+ vhci_hcd
[    0.376862] usbcore: registered new interface driver usbhid
[    0.377012] usbhid: USB HID core driver
[   92.238687] hid-generic 0003:03EB:2111.0001: hiddev96: USB HID v1.11 Device [Atmel Corp. EDBG CMSIS-DAP] on usb-vhci_hcd.0-1/input0

但我从 OpenOCD 收到了同样的错误。

我还遗漏了什么?WSL 内核中还有许多其他与 USB HID 设备相关的配置选项。还有其他需要的吗?还有其他udev需要的规则吗?还有其他人使用 WSL 成功连接到此主板吗?

相关内容