RISC-V MCU - USB and debugger - Page 1
Forum section: electronics / general

author: nForce
author_rank: Frequent Contributor
timestamp: September 13, 2023, 06:22:37 pm
content: Hello,can I ask why does these boards have USB-C port? I thought it is for programming (flashing the program) and debugging. Do I need a debugger likethis one, to program these two boards?Thanks again.

author: ataradov
author_rank: Super Contributor
timestamp: September 13, 2023, 07:03:05 pm
content: CH32V307 has a bootloader in the ROM. This bootloader is called when you hold the BOOT0 button while resetting the device. It can use USB and UART for programming. But there is no way to debug though this interface.The second board to too low resolution to tell what it is, but it would be something similar, just check the datasheet and a reference manual for the MCU.Having a debugger on hand is always a good idea, even if you use it once to verify that it can identify the chip. It is not like they are excessively expensive.

author: nForce
author_rank: Frequent Contributor
timestamp: December 28, 2023, 08:44:46 pm
content: Hello,I am back and I ordered the debugger WCH-Link which I received, but with the examples from the official Github repository I cannot flash the board. I get this message:Code:Not supported by WCH-Link CH32V203(DAP-HID). Please refer to "WCH-LinkUserManual.pdf" for more help.I do not have the CH32V203, but CH32V307. That black board which I showed above (image). Do you maybe know what is the case? I am using W10 and the device manager shows the WCH-Link.Does anyone have a hint?Thank you.

author: tellurium
author_rank: Frequent Contributor
timestamp: December 28, 2023, 08:58:10 pm
content: I have the same CH32V307 board.I reflash it by pressing "boot0" then "reset" buttons, which puts the board into the bootloader mode.Then I use wchisp utility to load a new firmware: "whisp flash firmware.elf"wchisp is here -https://github.com/ch32-rs/wchisp, you can get binaries from the nightly builds.In order to see the logs, I connect an external usb-serial converter to the PA9 pin, which is USART1 TX.I use USB hub with Ethernet jack, which I plug to my Mac's USB-C socket, and enable "internet sharing".This way, I get a simple development setup with minimum gear.Photo attached.The other possibility is to get an external wchlink, and connect it to the 4-pin connector at the side of the board, some soldering would be required. It'll give live debugging support. I did not do it yet cause still waiting for the wchlink to arrive.Also, I mostly use printf-style debugging, so don't really fancy live debuggers.

author: SiliconWizard
author_rank: Super Contributor
timestamp: December 28, 2023, 10:19:05 pm
content: I've also used the wchisp Rust-based tool for the CH32V307 initially, and it works, although on one of my dev boards, it didn't - and the official WCH tool on Windows didn't either with this particular board - I suspect the bootloader of the particular CH32V307 on this board was not the same version as with the others, and this version was faulty. So, beware of the integrated bootloader.I've since bought a couple WCH-Link boards, not the original from WCH, but one from MuseLab: WCH-LinkE, which has a USB-C connector and is much more practical to use IMO. Otherwise the firmware is the same, and it works with wlink, also a Rust-based CLI tool (which works even on the "faulty" bootloader chip I mentioned above, so it's definitely a bootloader issue.)https://github.com/ch32-rs/wlinkSince the bootloader on these MCUs is programmed in Flash rather than ROM, it's likely that different versions are in circulation depending on the batch of the chip.

author: jnk0le
author_rank: Regular Contributor
timestamp: December 29, 2023, 12:29:33 am
content: Quote from: nForce on December 28, 2023, 08:44:46 pmv203 is the chip used in some of the wchlinks. What software are you trying to use?Try to connect in wchlink-utility first.Quote from: nForce on December 28, 2023, 08:44:46 pmdriver not installed, run wchlink utility which should install it automatically (should show as "WCH-LinkRV")

author: nForce
author_rank: Frequent Contributor
timestamp: January 02, 2024, 07:20:24 pm
content: So, I downloaded the wchisp and wlink. (I can use one of them, if I understand correctly they are both programs for flashing CH32 chips?)Where can I get the specific firmware for the board, used within the command:Code:firmware.elf?@jnk0leI launched the wchlink-utility and it installed the driver, but in the Device Manager it still shows WCH-Link. I am using the Mounriver IDE.Thanks.

author: tellurium
author_rank: Frequent Contributor
timestamp: January 03, 2024, 01:31:53 am
content: Quote from: nForce on January 02, 2024, 07:20:24 pmThe firmware you should build yourself - using whatever tools you like.For example, Mounriver IDE.The result of the build process should be an .elf file, and that is what you should flash.There is a dedicated topic for the modbus + web UI firmware,https://www.eevblog.com/forum/microcontrollers/ch32v307-modbus-web-ui-firmware/You could get a pre-built firmware from there, or build the firmware yourself.

author: nForce
author_rank: Frequent Contributor
timestamp: January 03, 2024, 03:23:49 pm
content: Hey, thanks@tellurium.As I understand you, I should build for example blinky led example in MounRiver IDE. And then I can use wchisp to flash the memory via USB connector with blinky_led.elf?Because as the user@SiliconWizardpointed out there is a problem with bootloader, I would like to ask, where can I get a new bootloader for the chip? Probably flashing with the bootloader is the same with these command-line programs?Thanks to both of you

author: jnk0le
author_rank: Regular Contributor
timestamp: January 04, 2024, 12:18:40 am
content: Quote from: nForce on January 02, 2024, 07:20:24 pmprobably this wchlink works different than wchlinkE.Can you connect to the chip and do like chip erase? (may need switching to risc-v mode somewhere in those utilities)Quote from: nForcenormally all those eclipse based IDEs can program the executable by openocd debug session

author: nForce
author_rank: Frequent Contributor
timestamp: January 04, 2024, 06:38:34 pm
content: Probably yes, it is a difference with this wchlink.I build the blinky-led example in the MounRiver IDE and tried to flash with wchisp tool, I get this:Code:Error: No WCH ISP USB device found(4348:55e0 device not found at index #0)As you proposed, I also tried with the WCHLink utility (erase, connect), I got this:Code:Failed to connect with WCH-Link!Please affirm link is at RISC-V mode!

author: bingo600
author_rank: Super Contributor
timestamp: January 04, 2024, 09:30:10 pm
content: I had one of the "Buttonless" cheap wch-link that came wirh my 307' board , and it was in "arm (DAP) mode"I used WCH-LinkUtility on Win10 to switch it to RiscV mode.QuoteConverthttps://www.eevblog.com/forum/microcontrollers/ch32v307-risc-v-minicore-with-ethernet/msg5195130/#msg5195130https://www.eevblog.com/forum/microcontrollers/ch32v307-risc-v-minicore-with-ethernet/msg5195859/#msg5195859https://www.eevblog.com/forum/microcontrollers/reflashing-a-bricked-wch-linke/msg5256081/#msg5256081Otherhttps://www.eevblog.com/forum/microcontrollers/ch32v307-risc-v-minicore-with-ethernet/msg5171010/#msg5171010https://www.eevblog.com/forum/microcontrollers/ch32v307-risc-v-minicore-with-ethernet/msg5171547/#msg5171547https://www.eevblog.com/forum/microcontrollers/ch32v307-risc-v-minicore-with-ethernet/msg5173056/#msg5173056