Detailed description
- This is a refactoring of core bitbanging routines.
- The existing problem was IMO suboptimal efficiency of swdptap, jtagtap functions.
- This PR solves this problem by extracting and improving the busy-looping delay; dropping double STM32F4 GPIO_BSRR writes; and rebalancing some of the no_delay routines to adjust for changes.
Tested on blackpill-f411ce platform connected to a stm32f103cb DUT. Firmware does not crash on exceptions from spurious ACKs. The 24MHz fx2la does not let me verify setup-and-hold timing compliancy, but the target silicon replies okay. I could retest with other targets accessible to me, possibly with low HCLKs. I was focusing ot stm32f4 platforms, but lm4f launchpad-icdi may be affected, too.
LINERESET waveform improved from 2.988 MHz to ~8.000 MHz, that is swd_seq_out_no_delay().
BMDA -r -f 8M was 22.5 and 41 KiB/s in JTAG and SWD mode, becomes 28 and 44 KiB/s respectively (but that bottleneck is different).
The PR aims to:
- increase raw SWD performance of capable platforms (stm32f4), and by extension JTAG performance;
- improve granularity of selecting max frequency (thanks to a quicker busy-delay loop); and fix said frequency calculations;
- rebalance edge-case timings where needed;
- optionally reduce AP WAIT polling spam (this makes logs and wire capture snapshots cleaner, but may hurt performance).
Important mentions:
GPIO_BSRR hack was introduced in github.com/blackmagic-debug/blackmagic@f1ea5ed8f9 ; the reasoning behind it is not clear to me, but we can either set some default divider to target lower (2 MHz) frequency, and BMDA already asks for some 3 or 4 MHz. I wired everything on a breadboard with flying wires and a couple ground connections (no ribbon cables).
swdptap.c has optimize(3) since https://github.com/blackmagic-debug/blackmagic/pull/669/commits/4698a26bab59236efc0217068b49ae734853fd86 (but not jtagtap.c). -O3 increases flash footprint and may alter the timings.
Your checklist for this pull request
- I've read the Code of Conduct
- I've read the guidelines for contributing to this repository
- It builds for hardware native (
make PROBE_HOST=native) - It builds as BMDA (
make PROBE_HOST=hosted) - I've tested it to the best of my ability
- My commit messages provide a useful short description of what the commits do
Closing issues
No known issues w.r.t. SWJ speed.