Programming Tool for WCH RISC-V Microcontrollers using WCH-LinkE
Project description
Programming Tool for WCH RISC-V Microcontrollers using WCH-LinkE
Description
With this open-source platform-independant command-line tool, WCH RISC-V microcontrollers can be programmed using the WCH-LinkE (pay attention to the "E" in the name) via their serial debug interface.
The tool currently supports the following microcontrollers:
- CH32V003, CH32V103, CH32V203, CH32V208, CH32V303, CH32V305, CH32V307,
- CH32X033, CH32X035,
- CH32L103,
- CH571, CH573, CH581, CH582, CH583, CH591, CH592.
Preparations
To use the WCH-LinkE 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-LinkE (SWCLK is not present on the CH32V003 and therefore does not need to be connected):
WCH-LinkE RISC-V MCU
+-------+ +--------+
| SWCLK| ---> |SWCLK |
| SWDIO| <--> |SWDIO |
| GND| ---> |GND |
| 3V3| ---> |VDD |
+-------+ +--------+
If the blue LED on the WCH-LinkE 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-LinkE to ARM mode
-v, --rvmode switch WCH-LinkE 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 nRST pin a GPIO pin (CH32V003 only)
-R, --pinreset make nRST pin a reset pin (CH32V003 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
Built Distribution
File details
Details for the file rvprog-1.7.1.tar.gz
.
File metadata
- Download URL: rvprog-1.7.1.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5667e1110dea4b5e8b4a4023309ce29ef8baf136548333a28b7a6fca386a2447 |
|
MD5 | 8e0a76c5d7689a293a96ea81d7766208 |
|
BLAKE2b-256 | 6ac188bd7fc92667788d1cdfd5cb2f6d9506fb4f61280639305022d28958ae25 |
File details
Details for the file rvprog-1.7.1-py3-none-any.whl
.
File metadata
- Download URL: rvprog-1.7.1-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 951b46115caeea2139a9852e845eb760b5435d4cfd83ff7cfe2eb7accbf6947d |
|
MD5 | f0c84a6eb561db5d4778c20aabab8477 |
|
BLAKE2b-256 | 64bb3375bcc13cd784ad34ab29e3b20e5ce8b57710dcd733e2731cf30e68aa33 |