-
Notifications
You must be signed in to change notification settings - Fork 846
Inconsistent clock signal during SWDIO turnaround #1706
Description
Summary
Serial wire debug (SWD/SWJ) clock signal generation is inconsistent during the turnaround cycle. The clock low time is to short during the turnaround cycle, which depending on the setup may result in the target's debug module missing the clock cycle entirely.
Version and platform information
Commit SHA ef32a54 the most recent tag is v1.10.1
gcc-arm-none-eabi-10.3-2021.07 toolchain.
STM32F411 "black pill" board, but I am guessing the issue is hardware agnostic.
10KOhm resistor pull up on the SWDIO line.
Steps to reproduce
The issue can be observed in all SWD transactions. Running monitor swd_scan with a valid debug target connected is enough to observe the issue on the oscilloscope trace. The issue becomes more apparent at higher frequencies since the troubled clock pulse becomes short enough to be missed by the target.
What is the current bug behavior?
Low side of the clock (SWCLK) signal does not adhere to the protocol timing during the turnaround cycle on the SWDIO pin. This causes a missing clock cycle at higher frequencies (see screenshot below).
What is the expected correct behavior?
The clock signal remains consistent throughout the entire serial wire debug transaction. By consistent I mean the clock pulse width (high and low) should be greater or equal 1/(2*f), were f is the configured SWD frequency.
Relevant logs, screenshots, or inputs
Following is a scope trace showing the missing clock low period during the first turnaround (BMP probe assuming receiver role). Clock frequency is measured at 36.4kHz. monitor frequency command says 79207Hz.
All consecutive SWD transactions contain the same issue during the turnaround cycle when the probe is assuming receiver role.
Possible causes or fixes
The low clock delay is only applied when BMP is turning around to be transmitter. The low clock delay is missing when BMP is becoming receiver.
https://github.com/blackmagic-debug/blackmagic/blob/main/src/platforms/common/swdptap.c#L72