Using CH32Vxxx Risc-V and Moun River

Notes on using the MOUN River IDE to program WCH32V Risc-V modules on Linux by an Arduino Hack.

Public Chat
Similar projects worth following
I like to design my own Arduino type modules, so far with AVR Espressif MCUs, but when I discovered the price/performance of the WCH family of RISC-V MCUs I couldn't resist trying them out. Here are some notes on getting a development eco-system up and going in the hope of saving someone else the days of searching I had to do.

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  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 »

  • 1 × CH32V003 Dev Boarding WCH32V003F4P6 Risc-V MCU with W-LinkE connector.
  • 1 × WLinkE programmer board used to upload binaries.

  • 1
    Install Moun River on Windows 10​

    Download the Windows Installer and follow instructions..  I know almost nothing about Windows so no help here other than to say I did successfully install the IDE on Windows 10.

      NOTE: does NOT use https://

    I actually had to download the ZIP in Linux - Windows wanted 1 1/2 hours to do the download - Moun River is obviously not a powerhouse on the web.

  • 2
    Install Moun River on Linux

    Download Moun River for Linux and extract it.  Read the README - you will need to run a script before installing.

    The actual IDE is an appImage -- see my Instruction on creating a launcher Icon for the gnome desktop.

  • 3
    Creating a launcher Icon for Moun River.

    There are 2 types of launcher that can be created for the gnome desktop.

    Local Installation: if you want to install the IDE for a certain user only.

    1. Copy all of the Moun River extracted files to: ......  TBD

    SystemWide Installation: to allow any user to execute Moun River.

    1. Create directory: sudo mkdir /opt/mounriver
    2. Copy all of the Moun River extracted files to: /opt/mounriver

View all 3 instructions

Enjoy this project?



svofski wrote 03/27/2024 at 21:04 point

Thanks for taking the time to write it all down!

  Are you sure? yes | no wrote 05/19/2023 at 12:21 point

MounRiver is based on Eclipse and I am not convinced that it offers any value added.  After downloading and installing it you till have to install the toolchain separately.  One could probably accomplish this just using a generic installation of Eclipse.  Perhaps the fact that it can interpret the ".wvproj" files is of value - dunno..  You can import repositories directly from github..

  Are you sure? yes | no wrote 05/19/2023 at 12:15 point

MounRiver IDE

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates