Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

wlink Documentation

This site is the documentation for wlink, the command-line flash and debug tool for WCH-Link probes and WCH RISC-V MCUs.

Its main part is a protocol reference for the WCH-LinkRV USB protocol — the private protocol spoken between the host and the WCH-Link probe. The old protocol.md at the repository root was written in 2023 and had stopped tracking the implementation; this reference is rebuilt from the source code so that the byte-level description and src/commands/ cannot silently diverge.

This is a reverse-engineered description, not an official WCH specification. WCH does not publish a protocol specification for the WCH-Link. Everything here comes from reading wlink’s implementation, from USB captures, and from other open-source implementations listed in External References. Entries marked unverified are observations only.

Where to start

If you want to…Read
Understand the wire formatUSB Transport, then Frame Format
Implement a commandCommand Reference and Control Subcommands
Understand how a flash operation is sequencedOperation Flows
Work with the RISC-V debug moduleDMI and the Debug Module
Look up an ID, flag or constantConstants and Chip Families
Find unimplemented or uncertain commandsUnverified Commands and Captures
Wire up a specific MCUThe Chip Notes section in the sidebar

Source of truth

Protocol knowledge is derived from these files in the repository. When the documentation and the code disagree, the code wins — please open a PR that corrects the documentation.

FileWhat it defines
src/commands/mod.rsFrame construction and parsing, command IDs, payload layouts
src/commands/control.rsThe complete 0x0d control subcommand set, firmware version encoding
src/probe.rsUSB IDs, endpoints, raw send/receive, mode switching
src/operations.rsCommand sequences for attach, erase, program, read, reset
src/chips.rsChip family IDs and the ChipID-to-part-name database
src/flash_op.rsPer-family flash algorithm blobs sent over the data endpoint
src/dmi.rs, src/regs.rsDMI operations and RISC-V debug register addresses

Building this site locally

The site is built with mdBook:

cargo install mdbook --locked
mdbook build          # output in book/
mdbook serve          # live preview at http://localhost:3000

The rendered site is published from the gh-pages branch; see .github/workflows/docs.yml. The intended public URL is https://ch32-rs.github.io/wlink/.