ch32-rs / wlink

An open source WCH-Link library/command line tool written in Rust.
Apache License 2.0
155 stars 25 forks source link

Feature: SDI printf support #34

Closed UCSIG closed 9 months ago

UCSIG commented 9 months ago

This adds the command sdi-printf to enable the SDI virtual serial port function introduced in the WCH-LinkUtility v1.80. It is supported by WCH-LinkE and was added to WCH-LinkUtility in v1.80. With this feature, the WCH-LinkE dongle can be used to read data from the debug interface of the mcu and redirect it to the serial port of the WCH-LinkE. Now, printf can be used without the UART peripheral of the mcu, only by using the mcu's internal debug module and the WCH-LinkE dongle. To use this feature, use an adapted _write function in the mcu's code, as in this example. Then, enable sdi printf functionality with this option and open the serial port of the WCH-LinkE.

andelf commented 9 months ago

Thanks! That's an interesting feature I've missed.

I've checked the SDI_printf of ch32v003, which is a straightforward printing implementation utilizing data0 and data1 to pass raw bytes to WCH-Link. I believe the shell printing functionality can also be incorporated into wlink. This can be achieved by introducing subcommands such as wlink sdi-printf watch or simply wlink flash/reset/resume --watch.

Currently, I am away on a business trip, so I won't be able to look into this immediately. If you prefer to implement the watch feature, I'm glad to help. Or I'll pick up the watch feature when I back home.

Thanks again for bringing this up, and I'll make sure to address it as soon as I am available.

UCSIG commented 9 months ago

Indeed, that would be very cool if the shell/serial port printing could also be implemented into wlink.
However, currently I don't have enough time to do that... If you could implement the watch feature, that would be amazing!

andelf commented 9 months ago

Got a weekend. I'll start work on this.

andelf commented 9 months ago

I've polished the implementation.

andelf commented 9 months ago

Thanks for the help. merged.