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

Feature: tri-state SWDIO, SWCLK on unbuffered platforms#1945

Merged
dragonmux merged 2 commits into
blackmagic-debug:mainfrom
ALTracer:feature/tristate-tck
Oct 2, 2024
Merged

Feature: tri-state SWDIO, SWCLK on unbuffered platforms#1945
dragonmux merged 2 commits into
blackmagic-debug:mainfrom
ALTracer:feature/tristate-tck

Conversation

@ALTracer
Copy link
Copy Markdown
Contributor

@ALTracer ALTracer commented Oct 1, 2024

Detailed description

  • This feature is a principle from native Feature: high-z TCK/SWCLK when idle #1192 applied to other platforms.
  • The existing problem is unbuffered BMP-compatibles hogging SWDIO/SWCLK lines in push-pull output modes, rendering other debuggers unusable when connected in parallel for extended diagnostics (this includes onboard debuggers).
  • This PR solves that by switching GPIOs from push-pull output into input mode on the same function call that native uses.

Tested on stlink/v3e of Nucleo-144 to give up the lines and allow using another external debugger. If SWDIO_MODE_DRIVE/SWDIO_MODE_FLOAT of swdptap.c and TMS_SET_MODE of jtagtap.c macros worked correctly, then I'd only need to touch the TCK gpio, but it was not enough. It may have to do with the sequence of swd writes (BMP is expected to write the next command and can't know it should idle).

The bonus change increases the slowest 2MHz slew rate on f723 to at least 25 MHz, because I've seen it bitbang faster than 10 MHz, and the waveform is degraded. Also CFLAGS="-Og" slow the swdptap.c routines down compared to "-Os" of other platforms, I'd like to update that as well (considering most stlinkv3's are in RDP2 anyways).

The same patch should be adapted and applied to blackpills and swlink, likely others (f072, f3, f4discovery, etc.)
I can't assume what pull-ups or pull-downs will be present on target's SWJ-DP (SW-DP), e.g. STM32 uses a TCK pull-down but RP2040 uses pull-ups on both TCK and TMS. So I just float the (normally driven) pins.

Your checklist for this pull request

Closing issues

Fixes #1868 point 3.

Copy link
Copy Markdown
Member

@dragonmux dragonmux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionally LGTM, there's just one item to do with a comment which once sorted we can then merge this.

Comment thread src/platforms/stlinkv3/platform.c Outdated
@dragonmux dragonmux added this to the v2.0 release milestone Oct 2, 2024
@dragonmux dragonmux added Enhancement General project improvement Foreign Host Board Non Native hardware to runing Black Magic firmware on labels Oct 2, 2024
@ALTracer ALTracer force-pushed the feature/tristate-tck branch from c07eeff to 27cbec7 Compare October 2, 2024 17:45
Copy link
Copy Markdown
Member

@dragonmux dragonmux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, merging. Thank you for the contribution!

@dragonmux dragonmux merged commit 27cbec7 into blackmagic-debug:main Oct 2, 2024
@ALTracer ALTracer deleted the feature/tristate-tck branch March 30, 2025 19:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Enhancement General project improvement Foreign Host Board Non Native hardware to runing Black Magic firmware on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Platform behaviour unification (wrt VTref, GPIOs, DFU)

2 participants