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

Command Reference

CMD is byte 1 of a request frame (see Frame Format). All payload integers are big-endian. Source links point at src/commands/mod.rs unless noted otherwise; 0x0d subcommands live in src/commands/control.rs and are expanded in Control Subcommands.

Command ID summary

CMDNamePayloadResponseStatus
0x01SetWriteMemoryRegion8 bytes: address, length()implemented
0x02Program1 byte: subcommandu8implemented
0x03SetReadMemoryRegion8 bytes: address, length()implemented
0x06ConfigChip1–8 bytes: protection/configu8partially implemented
0x08DmiOp6 bytes6 bytesimplemented
0x0bReset1 byte()implemented
0x0cSetSpeed2 bytes: riscvchip, speedboolimplemented
0x0dControlsubcommand + argsvariesimplemented — see Control Subcommands
0x0eDisableDebug1 byte 0x01()implemented
0x0fGet device mode1 byteunknownunverified
0x11GetChipInfo (ESIG)1 byte: 0x09 / 0x0620 raw bytesimplemented
0xfeDisable encryption1 byteunknownunverified
0xffMode switch1 byte 0x41—implemented (RV → DAP)

The old protocol.md listed 0x0c as ??? and 0x0f as “begin verify”. Both are wrong: 0x0c is SetSpeed (corrected in CHANGELOG for v0.0.6), and 0x0f only appears in a GetDeviceMode capture.


0x01 — SetWriteMemoryRegion

Sets the target address and byte count for the following write operation.

OffsetTypeField
0u32_bestart_addr (typically 0x08000000 code flash or 0x00000000 SRAM)
4u32_belen (firmware length in bytes)

Request: 81 01 08 <addr:4> <len:4>. Response: ().

Source: SetWriteMemoryRegion. Used at the start of ProbeSession::write_flash.

0x02 — Program

One-byte subcommand selector. Response is a single status byte; wlink checks the returned value for the 0x07 step during flashing.

SubRust variantMeaning
0x01EraseFlashErase code flash
0x02WriteFlashBegin fast-program (bulk data follows on the data endpoint)
0x04WriteFlashAndVerifyWrite flash with verification
0x05WriteFlashOPBegin writing the per-family flash algorithm blob
0x06PreparePrepare before setting the RAM address (not used by current flows)
0x07Unknown07AfterFlashOPWrittenCommit step after the flash blob was written; response must be 0x07
0x08EndEnd program
0x0bUnknown0BAfterFlashOPWrittenAlternative commit step for riscvchip == 1
0x0cReadMemoryStart a memory read on the data endpoint

Older notes listed 0x03 “execute ram”, 0x05 “begin bulk transfer”, 0x07 “verify”, 0x09 “bulk transfer ends”, 0x0a “verify” and 0x0b “= verify for riscvchip 1”. Those labels are unverified; see Unverified Commands.

0x03 — SetReadMemoryRegion

Identical layout to 0x01: start_addr and len, both u32_be. Response (). Followed by 0x02 / 0x0c (ReadMemory) and a bulk read on endpoint 0x82.

Source: SetReadMemoryRegion, ProbeSession::read_memory.

0x06 — ConfigChip

Flash read/write protection and option-byte configuration. Response is a status u8 for the query variants.

PAYLOAD[0]Rust variantPayloadMeaning / response
0x01CheckReadProtect1 byte0x01 protected, 0x02 unprotected
0x02Unprotect1 byteRemove read protection (mass-erases option bytes)
0x03Protect1 byteSet read protection
0x04CheckReadProtectEx1 byte0x11 write-protected, 0x00 unprotected
0x02 + argUnprotectEx(b)8 bytes: 02 b ff ff ff ff ff ffExtended unprotect; b is 0xff or 0xbf
0x03 + argProtectEx(b)8 bytes: 03 b ff ff ff ff ff ffExtended protect
—Config { data, wrp }8 bytesUnimplemented in wlink (todo!()); capture: 81 06 08 02 3f 00 00 ff ff ff ff

Flags (ConfigChip associated constants): FLAG_READ_PROTECTED = 0x01, FLAG_READ_UNPROTECTED = 0x02, FLAG_WRITE_PROTECTED = 0x11, FLAG_WRITE_UNPROTECTED = 0x00.

Changing protection requires a fresh 0x0d / 0x02 attach afterwards. wlink skips Unprotect when flash is already unprotected, because the probe firmware mass-erases the option-byte page (USER/Data/WRPR).

0x08 — DmiOp

Six-byte payload, six-byte response. See DMI and the Debug Module for register addresses and status handling.

OffsetSizeRequest fieldResponse field
01addr (DMI register)addr
1–44data (u32_be)data (u32_be)
51op: 0 NOP, 1 READ, 2 WRITEop: 0x00 success, 0x02 failed, 0x03 busy

Example — read DMSTATUS (0x11): 81 08 06 11 00 00 00 00 01.

0x0b — Reset

PAYLOAD[0]Rust variantMeaning
0x01Reset::SoftQuit reset / reset and run (most common); wlink waits ~300 ms afterwards
0x02Reset::ChipChip reset (memory is not reset)
0x03Reset::NormalNormal reset

Response: (). Source: Reset, ProbeSession::soft_reset.

0x0c — SetSpeed

OffsetFieldValues
0riscvchipChip family code, see Constants
1speed0x01 High (6000 kHz, default), 0x02 Medium (4000 kHz), 0x03 Low (400 kHz)

Response payload 0x01 means success (Response for bool). wlink sends this before attaching and again after auto-detection. Source: SetSpeed, Speed.

0x0d — Control

The multi-purpose control command. Its first payload byte selects a subcommand; the remainder depends on it. See Control Subcommands for the complete table.

Quick reference: 0x01 probe info, 0x02 attach chip, 0x04/0x05 ROM/RAM split, 0x08 erase by RST pin, 0x09–0x0c power output, 0x0e RST pin, 0x0f erase by power-off, 0xee SDI print, 0xff detach.

0x0e — DisableDebug

Payload 0x01, response (). Only used for specific riscvchip families (older notes mention families 2 and 3). Frame: 81 0e 01 01.

Source: DisableDebug.

0x11 — GetChipInfo / ESignature

PAYLOAD[0]Rust variantNotes
0x09GetChipInfo::V1Used with firmware older than v2.9
0x06GetChipInfo::V2Introduced in firmware v2.9

This command does not use the standard response frame — see Chip Info and ESIG for the raw 20-byte layout. Source: GetChipInfo, ESignature.

0xff — Mode switch

RawCommand<0xff> with payload 0x41 (81 ff 01 41) switches an RV-mode probe into DAP mode. The reverse direction writes 81 ff 01 52 raw to endpoint 0x02 while the probe is in DAP mode. See USB Transport.