Menu

#368 openocd don't proper fallback and not work on cmsis-dap-v1(hid) with `CMSIS DAP` in name of its usb serial

0.11.0
new
nobody
None
2022-10-29
2022-10-15
yyjdelete
No

Some cmsis-dap-v1 devices has an usb serial and CMSIS DAP in it's name.
Seems openocd choose to workaroud bug for KitProg3 by search CMSIS DAP in all usb devices, and not only WinUSB, but it also broken supported for all cmsis-dap-v1(hid) devices with an usb serial and CMSIS DAP in the name of serial(it will use cmsis-dap-v2 and failed)
https://github.com/openocd-org/openocd/blob/v0.12.0-rc1/src/jtag/drivers/cmsis_dap_usb_bulk.c#L249-L273
One workaround is make a copy of cmsis-dap.cfg, add cmsis_dap_backend hid to the new file and use the new one. But maybe it should works out of box by add an separately cmsis-dap-v1.cfg, do auto fallback to v1, use whitelist for special error devices, or use blacklist for usb serial with CMSIS DAP in name.

https://github.com/openocd-org/openocd/blob/v0.12.0-rc1/src/jtag/drivers/cmsis_dap_usb_bulk.c#L340-L342
Not sure, but should it also return FAIL here to make an fallback like all other place does?

Many error report can be found on the web.
https://www.google.com/search?q=Warn+%3A+Using+CMSIS-DAPv2+interface+1+with+wrong+class+10+subclass+0+or+protocol+0
https://github.com/search?q=cmsis_dap_backend+hid&type=issues

Discussion

  • Tomas Vanek

    Tomas Vanek - 2022-10-20

    Some cmsis-dap-v1 devices has an usb serial and CMSIS DAP in it's name.

    If CMSIS-DAP is included in the interface string of CDC ACM it is the peak of ignorance from the vendor - serial interface has nothing common with CMSIS-DAP protocol.

    CMSIS DAP in all usb devices, and not only WinUSB

    OpenOCD does not care about WinUSB descriptors as it runs on open systems too. Also CMSIS-DAP specs does not mention anything about WinUSB.

    The autodetection is based on the principle that it is better to find at least something as user can easily force fallback by adding

        -c 'cmsis_dap_backend hid'
    

    In the case the search for v2 interface fails the workaround is more complicated as you have to find the interface number and use

      -c 'cmsis_dap_usb interface x'
    

    do auto fallback to v1, use whitelist for special error devices, or use blacklist for usb serial with CMSIS DAP in name.

    If you want please submit such change to https://review.openocd.org

    The easy improvement could be limiting CMSIS-DAP bulk interface detection to uncommon classes only and filter out mainly CDC and MSC classes. Let's hope no vendor missconfigures bulk if as it were serial...

     
  • Tomas Vanek

    Tomas Vanek - 2022-10-20
     
  • Antonio Borneo

    Antonio Borneo - 2022-10-21

    I'm afraid that this issue could happen again in future with other adapters.
    If you have a linux machine, can you please plug the KitProg3 and post here the output of "lsusb -v -d 04b4:"?
    This could help keeping a log of problematic devices and take care of them if further fixes has to be applied.

    Maybe all such lsusb logs could be added as independent text files in OpenOCD code

     
  • yyjdelete

    yyjdelete - 2022-10-28

    Sorry for the delay, I lost the device for some time and finally found it.

    I tried https://review.openocd.org/c/openocd/+/7279 and it works for the device

    lsusb -v for the device(the one with CMSIS-DAP in name of CDC, and NOT KitProg3)

    Bus 001 Device 008: ID c251:f001 Keil Software, Inc. 
    Device Descriptor:
      bLength                18
      bDescriptorType         1
      bcdUSB               2.00
      bDeviceClass          239 Miscellaneous Device
      bDeviceSubClass         2 ?
      bDeviceProtocol         1 Interface Association
      bMaxPacketSize0        64
      idVendor           0xc251 Keil Software, Inc.
      idProduct          0xf001 
      bcdDevice            1.00
      iManufacturer           1 jixin.pro
      iProduct                2 CMSIS-DAP_LU
      iSerial                 3 LU_2022_8888
      bNumConfigurations      1
      Configuration Descriptor:
        bLength                 9
        bDescriptorType         2
        wTotalLength          107
        bNumInterfaces          3
        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               4 CMSIS-DAP CDC
        Interface Descriptor:
          bLength                 9
          bDescriptorType         4
          bInterfaceNumber        0
          bAlternateSetting       0
          bNumEndpoints           1
          bInterfaceClass         2 Communications
          bInterfaceSubClass      2 Abstract (modem)
          bInterfaceProtocol      0 None
          iInterface              4 CMSIS-DAP CDC
          CDC Header:
            bcdCDC               1.10
          CDC Call Management:
            bmCapabilities       0x01
              call management
            bDataInterface          1
          CDC ACM:
            bmCapabilities       0x02
              line coding and serial state
          CDC Union:
            bMasterInterface        0
            bSlaveInterface         1 
          Endpoint Descriptor:
            bLength                 7
            bDescriptorType         5
            bEndpointAddress     0x81  EP 1 IN
            bmAttributes            3
              Transfer Type            Interrupt
              Synch Type               None
              Usage Type               Data
            wMaxPacketSize     0x0040  1x 64 bytes
            bInterval               2
        Interface Descriptor:
          bLength                 9
          bDescriptorType         4
          bInterfaceNumber        1
          bAlternateSetting       0
          bNumEndpoints           2
          bInterfaceClass        10 CDC Data
          bInterfaceSubClass      0 Unused
          bInterfaceProtocol      0 
          iInterface              5 CMSIS-DAP DCI
          Endpoint Descriptor:
            bLength                 7
            bDescriptorType         5
            bEndpointAddress     0x02  EP 2 OUT
            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     0x82  EP 2 IN
            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        2
          bAlternateSetting       0
          bNumEndpoints           2
          bInterfaceClass         3 Human Interface Device
          bInterfaceSubClass      0 No Subclass
          bInterfaceProtocol      0 None
          iInterface              6 CMSIS-DAP_LU
            HID Device Descriptor:
              bLength                 9
              bDescriptorType        33
              bcdHID               1.00
              bCountryCode            0 Not supported
              bNumDescriptors         1
              bDescriptorType        34 Report
              wDescriptorLength      33
             Report Descriptors: 
               ** UNAVAILABLE **
          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               1
          Endpoint Descriptor:
            bLength                 7
            bDescriptorType         5
            bEndpointAddress     0x03  EP 3 OUT
            bmAttributes            3
              Transfer Type            Interrupt
              Synch Type               None
              Usage Type               Data
            wMaxPacketSize     0x0040  1x 64 bytes
            bInterval               1
    Device Status:     0x0000
      (Bus Powered)
    
     
  • Antonio Borneo

    Antonio Borneo - 2022-10-29

    Thanks for the log and for testing https://review.openocd.org/c/openocd/+/7279
    This adapter reuses Keil vendor ID...

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.