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

New feature: Serial watch #36

Closed andelf closed 9 months ago

andelf commented 9 months ago

This is designed to print serial logs.

Usage:

wlink -v flash --enable-sdi-print --watch-serial xxx.bin
> wlink flash --enable-sdi-print --watch-serial target/riscv32ec-unknown-none-elf/release/examples/sdi-debug
16:04:37 [INFO] WCH-Link v2.11 (WCH-LinkE-CH32V305)
16:04:37 [INFO] Attached chip: CH32V003 [CH32V003F4P6] (ChipID: 0x00300500)
16:04:37 [INFO] Chip UID: cd-ab-80-17-48-bc-95-7f
16:04:37 [INFO] Flash protected: false
16:04:37 [INFO] Read target/riscv32ec-unknown-none-elf/release/examples/debug as ELF format
16:04:37 [INFO] Firmware size: 4037, start_address: 0x00000000, end_address: 0x00000fc5
16:04:37 [INFO] Flashing 4037 bytes to 0x08000000
16:04:37 [INFO] WCH-Link v2.11 (WCH-LinkE-CH32V305)
16:04:37 [INFO] Attached chip: CH32V003 [CH32V003F4P6] (ChipID: 0x00300500)
16:04:37 [INFO] Flash already unprotected
16:04:37 [INFO] Flash protected: false
16:04:38 [INFO] Flash done
16:04:38 [INFO] Now reset...
16:04:38 [INFO] Now connect to the WCH-Link serial port to read SDI print
gle
Hello world from ch32v003 SDI print!
led toggle
led toggle
led toggle
^C
>

Note that "gle" is from previous content(before reset).

andelf commented 9 months ago

@UCSIG I've tested on macOS. Could you help to check if this works on Linux or Windows?

UCSIG commented 8 months ago

That's a super useful feature, thanks!

@UCSIG I've tested on macOS. Could you help to check if this works on Linux or Windows?

Yes, it works perfectly. I've tested it on Windows 23H2 as well as under Ubuntu 22.04 in wsl. I think it would also be beneficial to add the --watch-serial option to the sdi-print command when enable is specified as the subcommand.
Currently, when the wch-link debugger accidently disconnects or the user switches to a different usb port, the flash command has to be invoked again and a new flash process has to be started just to get the serial terminal active again.

andelf commented 8 months ago

I think it would also be beneficial to add the --watch-serial option to the sdi-print command when enable is specified as the subcommand.

Indeed.

thirstyone commented 8 months ago

stupid question about speed settings? (probably irrelevant) + feature request: make it warn users, that SDI print doesn't work with their WCH-Link v2.9 (and probably suggest to upgrade the probe firmware :-)