Skip to main content

Programming Tool for WCH RISC-V Microcontrollers using WCH-Link

Description

With this open-source platform-independant command-line tool, WCH RISC-V microcontrollers can be programmed using a RISC-V compatible WCH-Link via their serial debug interface.

The tool currently supports the following microcontrollers:

  • CH32V002, CH32V003, CH32V004, CH32V005, CH32V006, CH32V007, CH32M007,
  • CH32V103, CH32V203, CH32V205, CH32V208, CH32V303, CH32V305, CH32V307, CH32V317,
  • CH32V406, CH32V407, CH32V467, CH32H415, CH32H416, CH32H417,
  • CH32X033, CH32X035, CH32X305, CH32X315,
  • CH32L103, CH32M103, CH32M030,
  • CH641, CH643, CH645,
  • CH565, CH569, CH571, CH573, CH581, CH582, CH583, CH584, CH585, CH591, CH592.

Read protection (-l/-u) is not available for CH643 and the CH5xx series. The CH32V205 requires WCH-Link firmware v3.6 or newer.

The tool currently supports the following programmers:

  • WCH-LinkB,
  • WCH-LinkE,
  • WCH-LinkW,
  • other compatible programmers.

Preparations

To use the WCH-Link on Linux, you need to grant access permissions beforehand by executing the following commands:

echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="1a86", ATTR{idProduct}=="8010", MODE="666"' | sudo tee /etc/udev/rules.d/99-WCH-LinkE.rules
echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="1a86", ATTR{idProduct}=="8012", MODE="666"' | sudo tee -a /etc/udev/rules.d/99-WCH-LinkE.rules
sudo udevadm control --reload-rules

On Windows, if you need to you can install the WinUSB driver over the WCH interface 1 using the Zadig tool. The libusb backend is installed automatically with the package (libusb-package).

Installation

Ensure that the prerequisites for installing Python packages are met. Then execute the following command in the command line:

pip install rvprog

Usage

To upload firmware, you should make the following connections to the WCH-Link (SWCLK is not present on CH32V00x and therefore does not need to be connected):

WCH-Link      RISC-V MCU
+------+      +--------+
| SWCLK| ---> |SWCLK   |
| SWDIO| <--> |SWDIO   |
|   GND| ---> |GND     |
|   3V3| ---> |VDD     |
+------+      +--------+

If the blue LED on the WCH-Link remains illuminated once it is connected to the USB port, it means that the device is currently in ARM mode and must be switched to RISC-V mode initially. There are a few ways to accomplish this:

  • You can utilize the rvprog tool with the -v option (see below).
  • Alternatively, you can select "WCH-LinkRV" in the software provided by WCH, such as MounRiver Studio or WCH-LinkUtility.
  • Another option is to hold down the ModeS button on the device while plugging it into the USB port.

More information can be found in the WCH-Link User Manual.

Usage: rvprog [-h] [-a] [-v] [-b] [-u] [-l] [-e] [-G] [-R] [-f FLASH] [--list]

Optional arguments:
  -h, --help                show help message and exit
  -a, --armmode             switch WCH-Link to ARM mode
  -v, --rvmode              switch WCH-Link to RISC-V mode
  -b, --unbrick             unbrick chip (power cycle erase)
  -u, --unlock              unlock chip (remove read protection)
  -l, --lock                lock chip (set read protection)
  -e, --erase               perform a whole chip erase
  -G, --pingpio             make PD7 a GPIO pin (CH32V00x only)
  -R, --pinreset            make PD7 a reset pin (CH32V00x only)
  -f FLASH, --flash FLASH   write BIN file to flash
  --list                    list supported chips

Example:
rvprog -f firmware.bin

Without action arguments, rvprog shows the programmer, the chip, its flash size and whether the chip is read protected.

Metadata

Release files for rvprog 1.13.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rvprog 1.13.0
File Size Uploaded Provenance Actions
rvprog-1.13.0.tar.gz 19.7 kB Without provenance Details for rvprog-1.13.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rvprog 1.13.0
File Interpreter ABI Platform Actions
rvprog-1.13.0-py3-none-any.whl Python 3 none any Details for rvprog-1.13.0-py3-none-any.whl

Total release size: 37.7 kB

Release files / rvprog-1.13.0.tar.gz

Download URL rvprog-1.13.0.tar.gz
Size 19.7 kB
Tags Source
SHA-256 checksum
How to use checksums
dc14bed474f5e5a354aa74d277ef61543efec087f81df6441915b2b890e6cac5
BLAKE2b-256 checksum
How to use checksums
7f02b145f10e7df734a0960e8251e0ca4196453405411287494bf18b3b3aadf2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / rvprog-1.13.0-py3-none-any.whl

Download URL rvprog-1.13.0-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
faf86d0e65a80d03718d065f50a711f702709c90ca88b6d0e71ac261dabf4ebb
BLAKE2b-256 checksum
How to use checksums
4a7a16f1c8b9e5156a30fafb09b62daf88642e721190b1a2fa27b3d4c9747e64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for rvprog 1.13.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page