Community-PIO-CH32V / platform-ch32v

PlatformIO platform for CH32V RISC-V chips (CH32V003, CH32V103, CH32V20x, CH32V30x, CH32X035) and CH56x, CH57x, CH58x, CH59x
Apache License 2.0
203 stars 34 forks source link

SDI printf #62

Closed ldab closed 2 months ago

ldab commented 2 months ago

I'm not too familiar with how things are set up here, but I have a CH32V003 printing over SDI (one wire) but for that to happen first the "enable SDI Printf" needs to be sent on the WCH-LinkUtility, I can do so on Windows, but on linux the tool is not available:

image

It seems tho that a CLI is available here: https://github.com/ch32-rs/wlink#feature-support which seems to support the feature, so theoretically we sent wlink flash --enable-sdi-print do you see how this could be integrated on the flasher?

Basically the issues is more like a dumb question to "where/which flasher is used?"

ldab commented 2 months ago

So, theoretically I add a new uploader here? https://github.com/Community-PIO-CH32V/platform-ch32v/blob/6dce5eb1338cc96587d70c0bc814b8357378bd5a/platform.json#L142

maxgerhardt commented 2 months ago

theoretically I add a new uploader here?

Yes. But that also has to be matched by providing the download URL for PlatformIO compatible packages for that tool (tar.gz packages that have package.json + the platform-specific wlink executable). wlink is not yet added, but can easily be added.

To answer the question:

"where/which flasher is used?"

Depending on which upload_protocol = ... is selected from the available ones

https://github.com/Community-PIO-CH32V/platform-ch32v/blob/6dce5eb1338cc96587d70c0bc814b8357378bd5a/boards/ch32v307_evt.json#L44-L48

we either use

  1. The WCH fork of OpenOCD.
  2. CNLohr's minichlink executable (here)
  3. Or wchisp (only thing that can do USB ISP bootloader uploads now)

The builder.py code decides how to invoke these uploads then. The platform.py usually holds the download links for the custom packages.

Let me just add wlink tool support and a platform target for "View SDI Printfs via wlink".,

maxgerhardt commented 2 months ago

Ahh, I have to correct myself. We don't even need to enable uploading with that tool, just one-time invoking wlink with that --enable-sdi-print is going to make the serial port of the WCH-Link spit out the decoded SDI prints automatically, as normal?

ldab commented 2 months ago

Ahh, I have to correct myself. We don't even need to enable uploading with that tool, just one-time invoking it wlink with that --enable-sdi-print is going to make the serial port of the WCH-Link spit out the decoded SDI prints automatically, as normal?

Agreed, after enabling, WCH-Link will spit the printfs.

I will add an example after that.

maxgerhardt commented 2 months ago

I've made addition https://github.com/Community-PIO-CH32V/platform-ch32v/commit/a73ed6d664f4cefff840a7f79228122fd82c874f.

grafik

You'll need to do a full platform update and window reload of VSCode. Easiest is to delete C:\Users\<user>\.platformio\platforms\ch32v* and restart VSCode.

ldab commented 2 months ago

that is super cool, it works no problem:

Enabling SDI Printf
14:01:18 [INFO] Connected to WCH-Link v2.10(v30) (WCH-LinkE-CH32V305)
14:01:19 [INFO] Attached chip: CH32V003 [CH32V003F4P6] (ChipID: 0x00300500)
14:01:19 [INFO] Enabling SDI print
14:01:19 [INFO] Now you can connect to the WCH-Link serial port

image

I think the next step would be to add an option to the monitor itself, something like monitor_sdi = true to the ini file, what do you think?

maxgerhardt commented 2 months ago

Would be nice, but I'm not sure at the moment if the PlatformIO core allows a "pre" hook for the monitor task or a prediction thereof, where we could execute a quick wlink sdi-print enable if that project option is set..