Reverse engineeringguide
CH32V305 WCH-LinkE read-only debug triage
This is a separate CH32V305 RISC-V target. The WCH-LinkE probe (1a86:8010, RV mode, firmware v3.6(v42)) can see the chip’s 2-wire SDI at the electrical level - logic-analyzer activity confirms both SWCLK and SWDIO transition during attach - but wlink v0.1.3’s AttachChip command fails with protocol error 0x55 ([0x81, 0x55, 0x01, 0x01]). This error occurs before ChipID and RDPR status are available; it does not confirm that the chip’s option bytes lock the debug interface.
This page covers: the corrected WCH-LinkE JP1 pinout, the exact wire-level meaning of the 0x55 error and why it happens before any protection status query, the FX2 logic-analyzer capture workflow and the re-enumeration gotcha, an activity-not-decode caveat, and read-only next steps. No erase, unprotect, or debug-enable instructions are included.
For the related Nuvoton M483 lock model, see Nuvoton M483 flash locks and the glitch-oracle trap. For the SWD harness on that target, see Read-only SWD and voltage-glitch harness on a locked Nuvoton M483.
Constants
Section titled “Constants”| Component | Identifier / value |
|---|---|
| Target MCU | WCH CH32V305GBU6 (QFN28)1 |
| SDI data | PA13 / SWDIO, pin 19 |
| SDI clock | PA14 / SWCLK, pin 22 |
| Ground | VSS, pin 20 |
| Supply | VDD, pin 21 (3.3 V) |
| Debug probe | WCH-LinkE-R0-1v3, USB 1a86:8010 in RV mode, firmware v3.6(v42) |
wlink version | v0.1.3 (ch32-rs/wlink) |
| Target USB VID:PID | 3710:5406 (normal boot enumeration) |
| Logic analyzer | fx2lafw-compatible via sigrok-cli, usbipd-attached |
WCH-LinkE JP1 pinout (corrected)
Section titled “WCH-LinkE JP1 pinout (corrected)”The official WCH-LinkE-R0-1v3 schematic (page 1)2 confirms:
| JP1 pin | Signal |
|---|---|
| 1 | RX |
| 2 | SWCLK/TCK |
| 3 | TX |
| 4 | SWDIO/TMS |
| 5 | TDO |
| 6 | GND |
| 7 | TDI |
| 8 | 3V3 |
| 9 | RST |
| 10 | 5V |
A raw worker note that proposed a different order was wrong. Use the pinout above. For 2-wire SDI: JP1 pin 2 (SWCLK) to target PA14 (pin 22), JP1 pin 4 (SWDIO) to target PA13 (pin 19), JP1 pin 6 (GND) to target VSS (pin 20).
SDI vs SWD naming
Section titled “SDI vs SWD naming”WCH reuses the ARM pin names SWDIO/SWCLK, but the protocol is WCH-proprietary SDI (Serial Debug Interface). A standard ARM SWD debugger (CMSIS-DAP, J-Link in SWD mode) cannot talk to a CH32V305. The WCH-LinkE must be in RV mode (not ARM-DAP mode), and wlink implements the SDI protocol. The WCH-LinkRV bulk USB protocol uses OUT endpoint 0x01 and IN endpoint 0x81; normal responses begin with 0x82, error responses with 0x81.
What the 0x55 error means at the wire level
Section titled “What the 0x55 error means at the wire level”In wlink v0.1.3, a session starts by opening the USB bulk interface and sending:
GetProbeInfo([0x81, 0x0d, 0x01, 0x01]) - succeeds, probes the WCH-LinkE itself.- Up to 4 attempts (initial + 3 retries, 100 ms apart) of:
SetSpeed([0x81, 0x0c, 0x02, <riscvchip>, <speed>]) - succeeds.AttachChip([0x81, 0x0d, 0x01, 0x02]) - fails with0x55.
AttachChip instructs the WCH-LinkE MCU to initiate the 2-wire SDI handshake with the target RISC-V Debug Module and read its ChipID. When the probe cannot complete this handshake, it replies:
[0x81, 0x55, 0x01, 0x01]0x81: error response marker0x55: error reason “failed to connect with riscvchip”30x01: payload length 10x01: failure subcode
The attach error happens during Stage 1 (AttachChip). Stage 2 (CheckReadProtect, [0x81, 0x06, 0x01, 0x01]) runs only AFTER AttachChip succeeds and returns chip family + ChipID. Because 0x55 occurs in Stage 1, ChipID and RDPR status are unqueried. The error proves the SDI handshake did not complete. It does not confirm that option-byte locks are active.
Possible causes of 0x55
Section titled “Possible causes of 0x55”From the WCH official OpenOCD driver4 and ch32-rs/wlink issue reports5:
- Physical SDI connection or target power issue: open/swapped
SWDIO(PA13, pin 19) orSWCLK(PA14, pin 22), missing common GND, or unpowered target VDD. The live session eliminated these: all four wire runs were continuity-tested, and the target pad measured3.3 V. - Debug interface disabled or locked in option bytes / bootloader config (
RDPR != 0xA5): on CH32V30x, the option-byte registerRDPR_USERhas reset/unprotected value0x00FF5AA5(RDPR = 0xA5). A chip whose 2-wire SDI is closed at boot or by ISP config can refuseAttachChip. Debug-enable/configuration transitions may mass-erase code flash; do not attempt them without an independently protected backup. - Application firmware reconfiguring PA13/PA14 or entering a tight loop after boot: firmware can disable SDI on PA13/PA14 microseconds after reset release.
AttachChipdoes not assert the hardwarenRSTpin; if the firmware disables SDI immediately, a USB-paced attach cannot catch the boot window.
Logic-analyzer workflow and FX2 re-enumeration gotcha
Section titled “Logic-analyzer workflow and FX2 re-enumeration gotcha”The generic FX2 analyzer is attached through usbipd and driven by sigrok-cli. The capture workflow has a USB re-enumeration gotcha: when sigrok uploads firmware to the FX2, the USB device briefly disappears and re-appears. If the device is attached through usbipd when this happens, the attachment is dropped and must be re-attached. The workflow is now automated by tools/capture/fx2-capture.py and documented in the fx2-logic-analyzer skill.
With CH0/D0 on target SWCLK (PA14, pin 22) and CH1/D1 on target SWDIO (PA13, pin 19):
| Capture | CH0 transitions | CH1 transitions | Attach result |
|---|---|---|---|
| First | 0 | 12,118 | 0x55 |
| Tool self-test | 49,782 | 11,838 | 0x55 |
| Repeat | 163,482 | 12,248 | 0x55 |
In the repeat capture both channels began transitioning at the same sample. The initial flat SWCLK is therefore not reliable evidence of a missing clock. The reproducible result is probe activity on both SDI lines while target attach still fails.
Activity is not decode
Section titled “Activity is not decode”The logic-analyzer capture counts digital transitions. It does not decode the SDI protocol or verify that the target ever responds. The recorded activity is probe-driven (the WCH-LinkE sending the attach sequence). A silent target would still show probe-driven transitions on both lines. A full protocol decode or an NRST-controlled attach is required to separate the cases.
Read-only next steps
Section titled “Read-only next steps”- Protocol-decode the existing captures. Run a WCH SDI protocol decoder against the
sigrokcaptures to determine whether the target ever sends a response or remains silent throughout the handshake. A silent target points at debug disable or firmware pin reconfiguration; a partial response points at a timing or electrical issue. NRST-controlled attach. Target padP7has now been continuity-confirmed to CH32 pin 3NRST; JP1 pin 9 is the reset candidate. Verify that the selected driver actually asserts that pin before relying on the method - the recordedwlink statusoperation did not toggle it. A qualified held-reset attach prevents application firmware from reconfiguring PA13/PA14 during the attempt. Persistent0x55would still need the known-unprotected control before attribution.- ISP backup over USB/UART. The CH32V305 has a bootloader ISP that operates over USB or UART before the application firmware runs. Check whether a read-only ISP backup path exists via
wchispor a similar tool. Do not issue any write, erase, or config-change command without a verified backup. - Qualified
NRST-controlled attach with a known-unprotected CH32V305. The positive control: attach to a development board or unlocked sample with known-unprotected option bytes. Without it, a persistent0x55cannot be attributed to the target.
Related docs
Section titled “Related docs”- Nuvoton M483 flash locks and the glitch-oracle trap - the lock model, evidence timeline, and methodological lessons from a related investigation.
- Read-only SWD and voltage-glitch harness on a locked Nuvoton M483 - single-rail-owner SWD harness and safe-connect OpenOCD for a different target and debug transport.
- Agent-assisted reverse engineering - static decompilation and protocol capture as the step before hardware probing.
References
Section titled “References”-
WCH, “CH32V20x_30x Datasheet,” QFN28 pinout (PA13=pin 19, PA14=pin 22), distributor-hosted copy. https://www.lcsc.com/datasheet/C19100608.pdf ↩
-
WCH, “WCH-LinkE-R0-1v3 Schematic,” page 1 JP1 header pinout. https://file.wch.cn/download/file?id=421 ↩
-
ch32-rs/wlink contributors, “protocol.md” (v0.1.3), WCH-LinkRV bulk USB protocol. https://raw.githubusercontent.com/ch32-rs/wlink/v0.1.3/protocol.md ↩
-
WCH/treideme, “wlinke.c,” WCH Official OpenOCD driver. https://raw.githubusercontent.com/treideme/openocd-hacks/wch-riscv-2026/src/jtag/drivers/wlinke.c ↩
-
ch32-rs/wlink, Issue #94, “0x55 protocol error.” https://github.com/ch32-rs/wlink/issues/94 ↩