Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

Inconsistent clock signal during SWDIO turnaround #1706

@stansotn

Description

@stansotn

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.

Screenshot 2023-12-27 at 6 08 05 PM

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions