Install arduino_core_ch32 (1.0.3) on Arduino IDE 2+ to develop CH32V003 RISC-V MCU in Arduino Framework

With openwch/arduino_core_ch32, now we can develop  CH32 RISC-V MCU in Arduino IDE 2.0+/Windows 11. This video show steps to install arduino_core_ch32 in Arduino IDE 2 (fail to install version 1.0.4, then success in version 1.0.3). Then program Muse Lab nanoCH32V003 (32-bit RISC-V development board), and upload using Muse Lab WCH-LinkE (WCH-Link Emulation Debugger Module).


Install arduino_core_ch32 in Arduino IDE 2

Add the following link in the "Additional Boards Managers URLs" field:
https://github.com/openwch/board_manager_files/raw/main/package_ch32v_index.json

Then search and install CH32 MCU EVT Boards by WCH.
Currently, 1.0.4 is the most updated version, but fail:

Downloading packages
WCH:riscv-none-embed-gcc@8.2.0
WCH:openocd@1.0.0
WCH:beforeinstall@1.0.0
WCH:ch32v@1.0.4
Installing WCH:riscv-none-embed-gcc@8.2.0
Configuring tool.
WCH:riscv-none-embed-gcc@8.2.0 installed
Installing WCH:openocd@1.0.0
Configuring tool.
WCH:openocd@1.0.0 installed
Installing WCH:beforeinstall@1.0.0
Failed to install platform: 'WCH:ch32v:1.0.4'.
Error: 13 INTERNAL: Cannot install tool WCH:beforeinstall@1.0.0: extracting archive: Create link C:\Users\laukc\AppData\Local\Arduino15\tmp\package-3215482598\wch_beforeinstall_linux-1.0.0\libhidapi-hidraw.so: symlink libhidapi-hidraw.so.0.0.0 C:\Users\laukc\AppData\Local\Arduino15\tmp\package-3215482598\wch_beforeinstall_linux-1.0.0\libhidapi-hidraw.so: A required privilege is not held by the client.
Then I re-install version 1.0.3, and success.

Notice that WCH-LinkE can work in two mode:
WCH-LinkRV (BLUE LED OFF): online debugging and downloading of WCH RISC-V MCU
WCH-DAPLink (BLUE LED ON): online debugging and downloading of ARM MCU with SWD/JTAG interface

To program nanoCH32V003, WCH-LinkE have to set in WCH-LinkRV mode, refer to the end of the video.

Connection:

    Connection between WCH-LinkE and nanoCH32V003:

			  nanoCH32V003
			  +-----------+
			  |G	     G|
			  |5V	    C4|
			  |C5	    C3|
			  |C6	    C2|
			  |C7	    C1|
			  |D2	    C0|
			  |D3	    D0|
			  |D4	   3V3|
			  |D5 G D 3 A2|
			  |D6 N I V A1|
			  |D7 D O 3 D1|
			  +-----------+
			      | | |
			      | | |    
		WCH-LinkE     | | |
		  +-+         | | |
	       RST| |5V       | | |
	       3V3| |3V3------|-|-+
	       GND| |SWDIO----|-+
	      U_TX| |GND------+
	      U_RX| |SWCLK
		  +-+


Code:

nanoCH32V003_Blink.ino, exercise to blink the nanoCH32V003 onboard LED.
/*
  Blink exercise:
  run on nanoCH32V003 (https://github.com/wuxx/nanoCH32V003)
  in Arduino Framework using Core library for CH32duino
  openwch/arduino_core_ch32 (https://github.com/openwch/arduino_core_ch32)
  to blink onboard LED.

On nanoCH32V003:

Onboard LED is connected to PD6
ref: Github wuxx/nanoCH32V003/hardware/nanoCH32V003.pdf
https://github.com/wuxx/nanoCH32V003/blob/master/hardware/nanoCH32V003.pdf

*/
#define LED PD6

// the setup function runs once when you press reset or power the board
void setup() {
  delay(500);

  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(300);                      // wait for a second
  digitalWrite(LED, LOW);   // turn the LED off by making the voltage LOW
  delay(500);                      // wait for a second
}






Comments

Popular posts from this blog

480x320 TFT/ILI9488 SPI wih EP32C3 (arduino-esp32) using Arduino_GFX Library

my dev.tools - FNIRSI 2C23T 3-in-1 Dual Channel Oscilloscope/Multimeter/Signal Generator