If you decide to flash your firmware with the WCH flash/debug probe, you'll have to select that probe in Embeetle IDE and choose for OpenOCD as your flashtool:
You'll also need to install the WCH driver.
The probe can work in RISC-V-mode or ARM-mode. Make sure the probe is set to the appropriate mode (RISC-V).
Windows
The WCH-LinkE-r0-1v3 flash/debug probe is a WinUSB device. Just like other devices in this class, there is no need to install a driver. Plug it in a USB-port and open the Windows Device Manager. There are three ways the probe can be visible now:
-
Interface > WCH CMSIS-DAP
: the probe is in its default ARM-mode. -
Interface > WCH-LinkRV
: the probe is in RISC-V-mode. -
Other devices > WCH-Link
: Windows doesn't recognize the device right away.
We'll go over these cases one-by-one. Let's start with the first one:
Being shown as WCH CMSIS-DAP
means that the probe is in its default ARM-mode. In RISC-V-mode the Device Manager shows the probe as WCH-LinkRV
:
What should you do if Windows doesn't recognize the device right away? With a bit of bad luck, you see this in the Device Manager:
No panic! Just go to the following webpage (load time can be quite long): https://www.wch.cn/downloads/WCH-LinkUtility_ZIP.html
Then click the big blue download button:
Unzip the downloaded folder and navigate to the driver executable WCHLinkDrv_WHQL_S.exe
in the folder WCH-LinkUtility/Drv_Link/
:
Double click the executable to run it. Windows will ask permission - click YES
. That's all. There is no chain of popup windows to click through. It almost feels as if nothing happens, until you look in the Windows Device Manager:
Linux
Embeetle uses OpenOCD to interact with the WCH-LinkE probe. OpenOCD needs sudo rights to access USB drivers, unless you add the device to the plugdev group. First you need to add the current user:
Check the groups related to the current user:
If plugdev
would not be listed, add the current user to that group:
Figure out your device's Vendor ID and Product ID through the $ lsusb
command:
As you can see, the ID for my device consists of two 4-digit hex numbers: ID 1a86:8010
. The first one is the Vendor ID, the second one the Product ID. Do not confuse them!
In the console, navigate to /etc/udev/rules.d
and list the contents of the directory:
Now create a new file, for example with the gedit editor:
You can name this file whatever you want, so long as it ends in .rules
. Rules files by convention begin with a number. Linux parses rules files in lexical order, and the number makes it easy to see which files will be parsed first. Choosing a low number (like 10, as above) means that your file will be parsed before system rules files.
Now you need to add a line in the file that represents your device. If the file already existed (from a previous device you added this way), you can leave all the content as-is and just add a line at the bottom. The line you need to add is:
ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="8010", MODE="666", GROUP="plugdev"
Of course, fill in your own Vendor ID and Product ID! WCH distributes a few kinds of flash/debug probes. If you add the following three lines, you should be able to use all of them:
ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="8010", MODE="666", GROUP="plugdev" ATTRS{idVendor}=="4348", ATTRS{idProduct}=="55e0", MODE="666", GROUP="plugdev" ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="8012", MODE="666", GROUP="plugdev"
Save the file and close it. Now you need to tell Linux to reload the udev rules:
Any member of the plugdev group should now be able to run OpenOCD without using sudo.
Switching modes
The WCH-LinkE-r0-1v3 flash/debug probe can operate in two modes: ARM and RISC-V. It is very important that the mode corresponds to the processor architecture of your target microcontroller!
In ARM-mode, the probe lits a persistent blue LED light. In RISC-V mode, there is no blue light (except while you're flashing code or debugging, then you'll have one ore more blue blinks).
Hardware mode switch
Plug out the probe, make sure it's not connected to anything. Remove its plastic case (that can be a bit of a challenge). Then, press down the ModeS
button:
While keeping the button pressed, plug the probe into your computer, such that it can draw power. Then release the button. It should now have switched its mode.
Once the mode has switched from ARM to RISC-V (or vice versa), it will stay in its new mode until you switch it again. In other words: the mode is stored in non-volatile memory on the probe.
Software mode switch
To switch mode, download the WCH-LinkUtility tool software. This can only be done on Windows, for Linux refer to the hardware switch method above. Navigate to This webpage:
https://www.wch.cn/downloads/WCH-LinkUtility_ZIP.html
Click the big blue download button:
Unzip the downloaded folder and navigate inside. You should see the WCH-LinkUtility.exe
executable:
Launch the executable. The tool opens. At the bottom you should see the Active WCH-Link Mode
field. Click the Get
button next to it to see the current mode. By default, that would be WCH-LinkDAP-WINUSB
, which indicates ARM-mode.
To switch to RISC-V-mode, select WCH-LinkRV
in the dropdown menu. Then click Set
to apply the new mode. After doing so, you should see the result in the Windows Device Manager:
As you can see, the device now shows up in the Device Manager as WCH-LinkRV
. Once you switched the mode, it should remain like that forever - until you change it back.
Page last edited January 21, 2025
Text editor powered by tinymce.