Contents Menu Expand Light mode Dark mode Auto light/dark mode
RINS
RINS

Contents:

  • WCH-Link
    • Protocol
      • 0x02 - Flash
      • 0x06 - Flash protection
      • 0x08 - DMI
      • 0x0d - System
      • 0x0e - Debug
      • 0x55 - Error
  • RVSWD
  • SDI

Meta:

  • License
  • Contributors
Back to top

WCH-Link#

WCH-Link is USB debbuger tool by WCH for flashing and debugging WCH RISC-V and ARM microcontrollers.

The WCH-Link has two modes of operation, DAPLink and RV (i.e. RISC-V).

This documentation refers to the RV mode of operation only, changing the mode of operation is also out of scope.

This documentation was based on the 2.5 firmware version, differences are expected between versions.

Device Descriptors#

Table 1 - Device Descriptors#

Vendor ID

0x1a86

QinHeng Electronics

Product ID

0x8010

Manufacturer

wch.cn

Product

WCH-Link

Serial

0001A0000000

Same serial accross all devices

Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x1a86 QinHeng Electronics
  idProduct          0x8010
  bcdDevice            2.05
  iManufacturer           1 wch.cn
  iProduct                2 WCH-Link
  iSerial                 3 0001A0000000
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0078
    bNumInterfaces          3
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         1
      bFunctionClass        255 Vendor Specific Class
      bFunctionSubClass       0
      bFunctionProtocol       0
      iFunction               2
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           4
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    128
      bInterfaceProtocol     85
      iInterface              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
      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     0x81  EP 1 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     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         1
      bInterfaceCount         2
      bFunctionClass          2 Communications
      bFunctionSubClass       2 Abstract (modem)
      bFunctionProtocol       1 AT-commands (v.25ter)
      iFunction               4
    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 Call Management:
        bmCapabilities       0x00
        bDataInterface          1
      CDC ACM:
        bmCapabilities       0x02
          line coding and serial state
      CDC Union:
        bMasterInterface        1
        bSlaveInterface         2
      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               1
    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     0x83  EP 3 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     0x03  EP 3 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0

Endpoints#

The WCH-Link exposes 4 endpoints through a Vendor interface:

  • 0x82: EP 2 IN

  • 0x02: EP 2 OUT

  • 0x81: EP 1 IN

  • 0x01: EP 1 OUT

EP 2 IN/OUT is used for most of the communication, EP 1 IN/OUT is used for some flash related operations.

Protocol#

Table 2 - Command packet format#

Byte

0

1

2

3 .. End

Description

Header

Command Page

Command Size

Command

Header#

Fixed header byte: - 0x81 for host command packets - 0x82 for device response packets

Command Page#

Command page/group, used to identify how the command data will be interpreted.

Command Size#

Length in bytes of the remaining command data.

Command#

Command data, interpreted according to the command page.

Command Pages#

  • 0x02 Flash

  • 0x06 Flash protection

  • 0x08 DMI

  • 0x0d System

  • 0x0e Debug

  • 0x55 Error

Next
Protocol
Previous
Home
Copyright © 2023, RINS Contributors
Made with Sphinx and @pradyunsg's Furo
On this page
  • WCH-Link
    • Device Descriptors
      • Endpoints
    • Protocol
      • Header
      • Command Page
      • Command Size
      • Command
    • Command Pages