sipeed / RV-Debugger-BL702

RV-Debugger-BL702 Project, an opensource debugger implement
159 stars 57 forks source link

No Setup/Hold time on TDI / TMS #11

Open GideonZ opened 2 years ago

GideonZ commented 2 years ago

With my purchased Sipeed RV Debugger Plus, which seems to use this firmware, I am not getting any successful JTAG connection using OpenOCD.

One issue is that the setup and hold times on TDI and TMS are near zero. This is wrong!

TDI and TCK toggle AT THE SAME TIME. Even more so, TDI / TMS also change on the falling edge of TCK. I did not expect this, and it is highly suspicious.

Please fix, as this adapter is totally unusable with a timing like this.

robertlipe commented 2 years ago

** This is a fly-by comment. I don't technically contain any relevant experience with this project, except as a user. (They work OK on the devices I've used...) I was looking at the source and something caught my eye that may be relevant.

In the main source directory of this app, there are two versions of the source code for the main application. I think they share a common ancestor, but it's not clear which is the newest or what the hardware actually shipped with. Just reading the code and the git history, the trunk contains a newer version (10 months vs. 11) of that main app that works hard to avoid code that was there that added delays in transitions like this.

Try replacing jtag_process.c with jtag_process.c.gowin. There are a lot of changes, but all that DELAY stuff that is missing might actually be helpful to this case. It's uncomfortable to busy-wait in an interrupt handler, but that interrupt handler should be most of what that device is doing. It'd cause USB and serial overruns, but it shouldn't be DOING either of those while JTAGGing, right?

Maybe you graft those definitions and uses into the trunk and create a PR.

At the very least, these DELAY_HIGH and DELAY_LOW call sites mark the places in the code create edges in those signals when starting and ending transitions, so it may be helpful to add yet more delays.

Sidebar: you may find #3 handy.

Good luck.