Author Topic: RISC-V MCU - USB and debugger  (Read 3980 times)

0 Members and 1 Guest are viewing this topic.

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
RISC-V MCU - USB and debugger
« on: September 13, 2023, 06:22:37 pm »
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 like this one, to program these two boards?




Thanks again.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11780
  • Country: us
    • Personal site
Re: RISC-V MCU - USB and debugger
« Reply #1 on: September 13, 2023, 07:03:05 pm »
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.
Alex
 
The following users thanked this post: nForce

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
Re: RISC-V MCU - USB and debugger
« Reply #2 on: December 28, 2023, 08:44:46 pm »
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: [Select]
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.
 

Offline tellurium

  • Frequent Contributor
  • **
  • Posts: 274
  • Country: ua
Re: RISC-V MCU - USB and debugger
« Reply #3 on: December 28, 2023, 08:58:10 pm »
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.
« Last Edit: December 28, 2023, 09:00:42 pm by tellurium »
Open source embedded network library https://github.com/cesanta/mongoose
TCP/IP stack + TLS1.3 + HTTP/WebSocket/MQTT in a single file
 
The following users thanked this post: nForce

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15439
  • Country: fr
Re: RISC-V MCU - USB and debugger
« Reply #4 on: December 28, 2023, 10:19:05 pm »
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/wlink

Since 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.
« Last Edit: December 28, 2023, 10:20:43 pm by SiliconWizard »
 
The following users thanked this post: nForce

Offline jnk0le

  • Regular Contributor
  • *
  • Posts: 79
  • Country: pl
Re: RISC-V MCU - USB and debugger
« Reply #5 on: December 29, 2023, 12:29:33 am »
Code: [Select]
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?
v203 is the chip used in some of the wchlinks. What software are you trying to use?

Try to connect in wchlink-utility first.

I am using W10 and the device manager shows the WCH-Link.
driver not installed, run wchlink utility which should install it automatically (should show as "WCH-LinkRV")
 
The following users thanked this post: nForce

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
Re: RISC-V MCU - USB and debugger
« Reply #6 on: January 02, 2024, 07:20:24 pm »
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: [Select]
firmware.elf ?

@jnk0le
I 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.

 

Offline tellurium

  • Frequent Contributor
  • **
  • Posts: 274
  • Country: ua
Re: RISC-V MCU - USB and debugger
« Reply #7 on: January 03, 2024, 01:31:53 am »
Where can I get the specific firmware for the board, used within the command:
Code: [Select]
firmware.elf ?

The 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.
Open source embedded network library https://github.com/cesanta/mongoose
TCP/IP stack + TLS1.3 + HTTP/WebSocket/MQTT in a single file
 
The following users thanked this post: nForce

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
Re: RISC-V MCU - USB and debugger
« Reply #8 on: January 03, 2024, 03:23:49 pm »
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 @SiliconWizard pointed 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  :)
 

Offline jnk0le

  • Regular Contributor
  • *
  • Posts: 79
  • Country: pl
Re: RISC-V MCU - USB and debugger
« Reply #9 on: January 04, 2024, 12:18:40 am »
I 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.
probably 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: nForce
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?

normally all those eclipse based IDEs can program the executable by openocd debug session
 
The following users thanked this post: nForce

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
Re: RISC-V MCU - USB and debugger
« Reply #10 on: January 04, 2024, 06:38:34 pm »
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: [Select]
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: [Select]
Failed to connect with WCH-Link!Please affirm link is at RISC-V mode!
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 2034
  • Country: dk
« Last Edit: January 05, 2024, 06:11:01 am by bingo600 »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf