Skip to content

Conversation

@mean00
Copy link

@mean00 mean00 commented Dec 21, 2025

Hi, finally had a bit of time:
This is a request for comment regarding the native support of the two wire protocol / rvswdp as used on WCH chips
(at least CH32V1xx/CH32V2xx/CH32V3XX). As far as i could tell it's not present in the current bmp codebase.
I've been using another flavor of that implementaion for a couple of years and afaik without major issues.

It is piggybacking a bit on the SWD implementation by reusing the SWDIO and SWCLK pins.
To avoid duplication a swdptap_common.h file contain the small common part .

I'm fairly sure the integration with the build system and meson setup is not complete.
I've also created a new target for testing cross/swlink-riscv.ini

In short, it implements the rvswd_scan command in native mode, on top of the work done by @perigoso for the wch-link.

Known Limitation/ things that will be reverted when everything else is okay :
1- the CH32 chips will work up to ~ 1.6Mbit/s only.
2- the errors are not necessarily managed correctly, but it seems "good enough"
4- I added temporarily a nop in the loop clock_on/clock_off macro for debug purpose . Those macros are there for readibility sake, i know they are not necessarily loved.
5- i had to change a bit the swlink platform temporarily to suit my test env, please ignore these changes
6- the implementation is very straightforward and use partially reverse engineered information , probably incomplete

Tested with a CH32V307, output is :

rvswdp_scan

Explain the details for making this change.

  • Is a new feature implemented? Yes
  • What existing problem(s) does the pull request solve? Native support of WCH protocol for CH32V1/2/3xx
  • How does the pull request solve these problems? Implement protocol

Your checklist for this pull request

Closing issues

@mean00 mean00 force-pushed the wch_two_wire_protocol branch from 4d803d0 to 235fcaf Compare December 21, 2025 14:44
@dragonmux dragonmux added this to the v2.1 release milestone Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants