As I mentioned It took me quite a few days to get all of the information together to evaluate using the Moun River IDE to develop and upload code to WCH Risc-V MCUs such as the WCH32V003 and CH32V103. So I hope to present the challenges and solutions I found in one single place so that others may avoid the delay.
To start - there is no current support for these MCU in the Arduino IDE...
[ CORRECTION June 18 '23 ] - WCH just released a package for the Arduino IDE
which is what I am most familiar with. BUT it uses the Link boards to upload - there is no serial bootloader so I am getting nowhere fast.
WCH is the inventor of these modules (at least to us English speakers). They may be familiar as the company behind the CH340G USB-UART chip used on many early Arduinos. They have a high level of competence designing USB chips. Lately they have released a full line of RISC-V based MCUs, most of which feature a native USB interface. These chips caught my attention for their low-cost - less than a Canadian Quarter - in low quantities for the lower end chips. RISC-V is royalty-free as opposed to ARM, or AVR which is owned by MicroChip. The WCH line follows the STM line of ARM MCUs and in many cases there is a direct correspondence between the part numbers.
So, to begin I ordered a WCH32V003 and a WCH32V103 as well as the WCH-LinkE which is similar to a USBASP in the Arduino world and supposedly necessary to program at least the smaller of these 2 modules. It claims to be able to do emulation as well...
WCH recommends using the Moun River Eclipse based IDE for software development - it's free so while I was waiting for the hardware to arrive I downloaded and installed it... (Not to worry - (there is an "English" link in the upper right of the webpage). So far.. so smooth... ( see my "Instructions", you need to install the toolchain separately ).... but not easy to do a search for this company... Search engines assume that you mean Moon River (and they do not have https::).. Installation was quite straight forward on my Ubuntu 23.04 Linux system.
After that came the head scratching - Where to get examples, how to config the IDE for these particular boards etc.. The answer came from the WCH github. I received the "003" board first and found the Repository has a wealth of information. As in any first try on an MCU I wanted to make an LED Blink. In the GPIO sub directory, as for the other examples, you will find a ".wvprog" file that contains the necessary information to start complilng the Toggle GPIO example.
Actually it would be much better to clone the whole repository, using git clone https://github.com/openwch/ch32v003.git.. OR - even MUCHER better - the IDE supports importing projects directly from github,,,
I found compiling to be as expected... see my discussion on writing code for these MCUs...
BUT - I came to grief when it comes to uploading... I could not get the W-LinkE driver to work correctly. The W-Link supports 2 modes - Flash mode or Serial mode - which seems like a great idea... You could upload via the SWC ISP and then monitor output from the serial port from the W-Link...
When I first connected the W-Link to USB a red LED lit up. This indicated that it is in flash mode.. To switch to serial mode, power off.. hold down the ModeS button and power on. You should see a blue led lit, indicating serial mode. Te verify driver installation you could do a ls /dev/ttyA* and look for a ttyACMx file which is how direct USB serial ports appear in Linux. You can also do a lsusb to see if the W-Link has been recognized.
In my case the driver was loaded and the device recognized when in serial mode but nothing happened i flash mode. A /dev/ch3v?? device never showed. ( I actually put a condom on my mouse and gave my keyboard a shot and connect a HD with Windows 10...
Read more »
Thanks for taking the time to write it all down!