Skip to main content

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

Project description

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,
  • CH32V103, CH32V203, CH32V208, CH32V303, CH32V305, CH32V307,
  • CH32X033, CH32X035,
  • CH32L103,
  • CH571, CH573, CH581, CH582, CH583, CH591, CH592.

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.

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]

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

Example:
rvprog -f firmware.bin

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rvprog-1.10.0.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rvprog-1.10.0-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file rvprog-1.10.0.tar.gz.

File metadata

  • Download URL: rvprog-1.10.0.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for rvprog-1.10.0.tar.gz
Algorithm Hash digest
SHA256 936348bcc34d6d8d680d2eafae22d963c379854bcd5e83c17041cff33fa482cc
MD5 a8f5359f2f662d5429f6cb83819aabbb
BLAKE2b-256 0fc89ed6a359451b8df0d21cbfba68244d387ddf60f38f70f2cf594c41b0f8dc

See more details on using hashes here.

File details

Details for the file rvprog-1.10.0-py3-none-any.whl.

File metadata

  • Download URL: rvprog-1.10.0-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for rvprog-1.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 561d356bfdf50f9c84c73c3e5ca8646c746d0dbf5e90382a0b2990ead072b44b
MD5 9fb6873299f0689fc579cd96f1bf104a
BLAKE2b-256 f21fb165671c8cd56322ef8f2014c5fade9820f60836fe7c42df10b57faba3fe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page