-
-
Notifications
You must be signed in to change notification settings - Fork 781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: ARM JTAG regressions #1389
Conversation
Tested on BMP with v1.9.0, with SWD to a GD32 target. Fallback seems to work. With BMP updated to firmware built from this PR, scan succeeds, but attach fails, with errors similar to what I previously reported on Discord. |
Update: with
on the aux CDC channel around the time that BMDA is showing
Which reinforces my suspicion that BMP is attempting the recovery procedure, but is somehow becoming uncommunicative with BMDA during or after. That's about all I have time to debug at the moment. |
Thank you, that's incredibly helpful as we weren't certain if that wasn't still going to be a problem post-patch (it clearly is) so giving us something more to dig into to finish stabilising this branch before Esden reviews it with a view to merge |
0a994fd
to
0912afe
Compare
So, error recovery was still broken under JTAG, which is now fixed, but we haven't yet dived into error recovery under SWD. Unless we can figure out something simple today, we're inclined to punt fixing that into a new PR so Esden gets a chance to review what's here, test it and merge it. This PR is intentionally not touching SWD as such as it was JTAG that was quite so broken |
Thanks for looking into it! I probably won't have time to test your latest changes today, so I'm fine with leaving the SWD fixes for the high-level protocol for separate PR or issue. |
I just tried the latest changes, and there seems to be a regression that causes I haven't tracked down what causes it yet, but from preliminary tests, it looks like the recent "target resumption" change is not the cause. |
I went back to b865bd8 on both BMDA and BMP, which I had previously tested, and the regression on |
Any chance you could share a |
I'll try to get to that soon. Another regression is that it's no longer possible to use |
I'll upload logs from I do have some suspicions that the clock may be gated off too quickly after sending the detach commands, due to an unintended timing change happening as a side effect of these changes. (ADIv5.2 §B4.1.1 requires at least 8 clocks of idle if the clock is gated off after a command, to ensure that it's fully shifted in to the SW-DP.) |
Logs from various combinations of BMDA and BMP firmware. The "pull 1405" happened to be what I had flashed most recently. I can repeat it with main if you want, but I think the changes there aren't going to affect this behavior. I'm almost tempted to hook up a logic analyzer to see if there's something weird with the clock disable with the firmware built from this patch. It would have to be different between native and remote, despite a lot of shared code, though. I did try adding BMDA pull 1405, firmware pull 1405: no halt BMDA pull 1389, firmware pull 1405: no halt bmp-t-pull-1389-fw-pull-1405-no-halt.log BMDA pull 1389, firmware pull 1405, bmp-t-H-pull-1389-fw-pull-1405-no-halt.log BMDA pull 1389, firmware pull 1389: halt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See file comment for the possible cause of the regression with high-level SWD.
There's still a regression where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes to remote_respond
made a substantial change to the protocol with all-zeros responses returning K
instead of K0
. This causes some things to break, including blackmagic -t -H
. Unfortunately, BMDA wasn't adjusted to expect it. It's probably easiest to revert to the previous protocol.
7d7907e
to
ebbd87a
Compare
Thanks for the updates! I did some testing, and it does fix the regressions that I found with this PR. Unfortunately, the timeout during error recovery on SWD still happens. I think I failed to test my remote protocol fixes without the "add idle clocks after reads on SWD" changes, and those were preventing the error conditions that were triggering the timeouts. That was a pre-existing problem on main, though, so I'm happy to defer it for another PR or issue. |
Excellent, and yeah - think we'll deal with the SWD problem on a separate PR as mentioned before. Thank you for your excellent review! Much appreciated and helpful :) |
ebbd87a
to
ff0be34
Compare
Apparently we hadn't gone quite far enough fixing the order of operations in adiv5.c's adiv5_dp_init(), with the new order for reading the DPIDR and all that both slightly accelerating the process if high-level functions are in use, and dealing with sticky errors that bit earlier. |
8eaa61a
to
b8ddca4
Compare
…ts now they're not necessary
…oes not need formatting
…the new machinary
… the new machinary
…ough the remote protocol system
…as this call would fail to function properly and screw up probing for parts
…not trigger a write when there is no need for the ABORT DP register
…favour of the one baked into the firmware as the firmware one is more correct
…d as it was happening too late
4af0ca7
to
7d04143
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn, that is a lot of rework. I tested it to the best of my abilities. It does look good otherwise, and it definitely does fix the JTAG regression we had too. More use/testing needed to make sure, but that should happen in main. :)
Detailed description
This PR addresses several regressions in ARM JTAG handling detailed below and necessarily rewrites the ADIv5 high level remote protocol.
The regressions fixed are as follows:
As part of the remote protocol rewrite we have pre-emptively split the high-level component of the protocol into generic high-level commands and ADIv5-specific ones to make organisational space for the RISC-V specific ones when v2.0 happens. This happens to also make reading BMDA probe logs easier.
Your checklist for this pull request
make PROBE_HOST=native
)make PROBE_HOST=hosted
)Closing issues
Fixes #858