Skip to content
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

Feature: SWD delay/frequency calibration #1955

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ALTracer
Copy link
Contributor

Detailed description

  • This is a new feature unused during actual debug.
  • The existing problem is most in-tree probe platforms misrepresent the SWCLK setting returned by platform_max_frequency_get() -- could run much slower or much faster.
  • This PR solves it for SWD but not JTAG by implementing an example remote monitor command (platform-specific) to emit example waveforms (in a blocking fashion, like always) and measure the CPU cycles it took (via DWT or TIM2 32-bit).

Tested on blackpill-f411ce, stlink/swlink (GD32F1, GD32F3) and f072 (32F072B-Disco) to enhance precision after correcting timing_stm32.c, both no_delay special case and clk_delay constants. Checks out with fx2la to <5%. I also tried emitting more than one SWD LINEREST (four) and I try to compensate for the static overhead of function calls, by subtracting eyeballed cycles taken. STM32F4 has 1-KiB ART cache, STM32F1 doesn't, GD32F1 runs from 0WS flash. STM32F0 also tested. Test a couple times to negate cold flash cache and IRQ uncertainty. JTAG could be implemented as a seprate command. Note that I did not use native linear regression calibration workflow, as the normal swdptap behaviour can be approximated as a linear law with no_delay point special-cased.

Your checklist for this pull request

Closing issues

ALTracer and others added 4 commits October 12, 2024 17:19
* Current _clk_delay strategy is better approximated by a proportional law,
  but _no_delay does not fit into that nicely.
* Also update delay macros with values obtained from calibration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant