probe-rs icon indicating copy to clipboard operation
probe-rs copied to clipboard

Fast fix for WCH-Link

Open burrbull opened this issue 3 years ago • 9 comments

Uses CMSIS-DAP v1

See #995

burrbull avatar Feb 09 '22 10:02 burrbull

My preference would be to check the interface strings instead, which I think on this device do still contain "CMSIS-DAP" against the HID interface? It sounds like you can use hidapi's DeviceInfo::path() to discover it.

But, that's more work, and this presumably (is it tested?) would get WCH-Links working right away.

If you have a WCH-Link could you post the lsusb -vv for it?

adamgreig avatar Feb 09 '22 11:02 adamgreig

If you have a WCH-Link could you post the lsusb -vv for it?

Nothing new

 16:19 ❯ lsusb -vv -d 1a86:8011

Bus 001 Device 004: ID 1a86:8011 QinHeng Electronics 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2 
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0         8
  idVendor           0x1a86 QinHeng Electronics
  idProduct          0x8011 
  bcdDevice            1.05
  iManufacturer           1 wch.cn
  iProduct                2 WCH-Link
  iSerial                 3 0001A0000001
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x006b
    bNumInterfaces          3
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              500mA
    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 WCH CMSIS-DAP
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         2 Communications
      bInterfaceSubClass      2 Abstract (modem)
      bInterfaceProtocol      0 
      iInterface              4 WCH CMSIS-DAP
      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     0x84  EP 4 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 
      bInterfaceProtocol      0 
      iInterface              5 (error)
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 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     0x83  EP 3 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 
      bInterfaceProtocol      0 
      iInterface              6 (error)
        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     0x81  EP 1 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     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
can't get debug descriptor: Resource temporarily unavailable
cannot read device status, Resource temporarily unavailable (11)

burrbull avatar Feb 09 '22 13:02 burrbull

Hey, do you intend to fix this? Or what is the progress on this? :)

Yatekii avatar Feb 25 '22 01:02 Yatekii

Hey, do you intend to fix this? Or what is the progress on this? :)

Are you asking me? I'm just use this workaround which works good enough for me and waiting for reaction from probe developer.

burrbull avatar Feb 25 '22 09:02 burrbull

I think there might be a misunderstanding :)

Adam and I are probe-rs developers/maintainers :)

Adam wrote this:

My preference would be to check the interface strings instead, which I think on this device do still contain "CMSIS-DAP" against the HID interface? It sounds like you can use hidapi's DeviceInfo::path() to discover it.

And I agree with that. It's how they did it in PyOCD (see https://github.com/probe-rs/probe-rs/issues/995). So I wanted to know if you plan to implement it the same way :) Should be a very simple fix; but I cannot test it since I do not have a WCH-Link.

Yatekii avatar Feb 25 '22 09:02 Yatekii

I can test. if it helps. it is meant to be tested on MacOS, right?

elfmimi avatar Feb 25 '22 11:02 elfmimi

The OS does not matter. But before you can test the correct fix needs to be implemented :) Thanks a lot for offering; I'll come back to you when the fix is in!

Yatekii avatar Feb 25 '22 11:02 Yatekii

I think there might be a misunderstanding :)

Yes, looks like you did not understand that I was saying about reaction from wchlink probe developers: https://github.com/guoccaiLi/wchlink/issues/1. Not from you :)

burrbull avatar Feb 25 '22 12:02 burrbull

Ohhh I am so very sorry!

Thanks for clarifying :))

Yatekii avatar Feb 25 '22 13:02 Yatekii

@adamgreig Rebased Now there is only 1 place requires fix

Rules, I use:

❯ cat /etc/udev/rules.d/99-wchlink.rules 
# WCH Link (CMSIS-DAP compatible adapter)
ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="8011", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1", ENV{ID_MM_PORT_IGNORE}="1"

burrbull avatar Feb 23 '23 07:02 burrbull

On my wch-link, I have a different USB descriptor, that has an interface association with a function "CMSIS-DAP" but sadly no CMSIS-DAP in any interface strings, which means I need a change on line 66 to check for "WCH-Link" in the product ID or it doesn't get detected. Do you know if it's possible to update the firmware? Mine is the WCH-Link-R1-1v1 board, which their table confusingly says does winusb but not hid cmsis (which I think is the wrong way around...?).

Once it's working we should add the rule to https://github.com/probe-rs/webpage/blob/master/static/files/69-probe-rs.rules too.

adamgreig avatar Feb 23 '23 22:02 adamgreig

Do you know if it's possible to update the firmware?

I've tried to ask, but no reply. https://github.com/guoccaiLi/wchlink/issues/1

burrbull avatar Feb 24 '23 01:02 burrbull

was this closed on putpsoe?

Yatekii avatar Feb 27 '23 09:02 Yatekii

was this closed on putpsoe?

no. I don't know what I has done. I'll try to restore it in several hours.

burrbull avatar Feb 27 '23 10:02 burrbull

Oh maybe a mis-push :)

Yatekii avatar Feb 27 '23 14:02 Yatekii