openwch / arduino_core_ch32

Core library for CH32duino
221 stars 38 forks source link

Upload Failing Windows 10 (WCH-LinkE) #87

Closed prairielandelec closed 2 weeks ago

prairielandelec commented 1 month ago

Just got a CH32C0003F4P6-Ro-1v1 and a WCH-LinkE-Ro-1v1 and am attempting to upload a test sketch.

First I installed the board packed per the instructions in this repo

I have connected SWDIO to PD1 on the dev board as well as 3v3 and GND and RX to PD5

When I look at Device manager there is a USB Serial Device and an unknown device WCH-Link

I select the USB Serial Device as the port in the Arduino IDE and the CH32V00x as the board and put in a simple blink test.

When I click "upload" I get the following:

Sketch uses 4796 bytes (29%) of program storage space. Maximum is 16384 bytes.
Global variables use 396 bytes (19%) of dynamic memory, leaving 1652 bytes for local variables. Maximum is 2048 bytes.
Open On-Chip Debugger 0.11.0+dev-02415-gfad123a16-dirty (2023-05-05-13:43)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'sdi'
Warn : Transport "sdi" was already selected
Ready for Remote Connections
Failed uploading: uploading error: exit status 0xc0000005

Is this just a faulty WCH-LinkE? Or am I missing some step of the initial configuration process? The bin builds just fine but after this error shows up nothing happens.

Thanks!

maxint-rd commented 1 month ago

I think you're missing some driver. In my Windows 11 system I see both a USB Serial COM port and under Interfaces a WCH-LinkRV device. The latter I believe handles the SWIO pin for programming and real-time debugging, while the COM port allows showing output from Serial.println() and input via Serial.read(). (For flashing the chip the debugging port is used).

prairielandelec commented 1 month ago

It would appear that is the case, I could not find any instructions in this repo and scant documentation in general. My understanding was that the WCH-LinkE utilized the OpenOCD drivers to some degree. I was looking through the Platoform IO Platform for this chip and saw the following section of their documentation: https://pio-ch32v.readthedocs.io/en/latest/installation.html#install-drivers-rules

I tried this driver on a spare laptop I had and it seemed to get things working. Biggest difference was seeing the WCH-Link interface appear in the "interfaces" section of device manager. I was able to program the following to the chip:


void setup() {
  pinMode(LED_PIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_PIN, HIGH);
  delay(100);
  digitalWrite(LED_PIN, LOW);
  delay(100);
}

The verification check seemed to pass just fine, however I do not see the output toggling on any of the pins. Is there any documentation on the pin naming? From what I can tell from other examples I have configured everything correctly.

Just trying to pinpoint if this is a problem with the flashing process, the code, or the chip on my dev board.

Thanks for the help!

maxint-rd commented 1 month ago

There are some cheat sheets that show the pinouts of the various chips. For the F4P6 I made a PDF out of the image I found somewhere: ch32v003f4p6_pinout.pdf

Usually I use pin names such as PC1, PA1, etc. Have fun!

TianpeiLee commented 2 weeks ago

When using wch-linke, it is important to ensure that the driver for wch-linke is installed correctly and that its firmware version is the latest. This can be done through the "WCH LinkUtility" tool to install the driver and update the firmware. https://www.wch.cn/downloads/WCH-LinkUtility_ZIP.html

In addition to using pinout diagrams similar to those provided by maxint-rd, there is also an imperfect way to query through the file "variantCH32V003F4.cpp" and the RM