7
31
Fork
You've already forked blackmagic
23

Fix: add a minimum reset pulse duration #2251

Merged
dragonmux merged 3 commits from ALTracer/blackmagic:fix/target-reset-pulse into main 2026年05月14日 00:14:03 +02:00
Contributor
Copy link

Detailed description

  • No new features.
  • The existing problem is the reset pulse of too short duration on some in-tree BMP platforms. #1868 point 2.
  • This PR solves it by adding a minimal (1ms) delay at cortexm_reset() callsite (and cortexar).

This was previously tested to fix stlink and blackpill-f411ce so that they are able to cortexm_reset by wire the AT32F403A target connected via JTAG transport. See #2248 (actually problem present since before PR2072).
This seems to be the easier of the two mitigation variants for it (the other is invoking dp->ensure_idle() somehow mid-write to AIRCR via ADIv5 MEM-AP so that READ DP CTRL/STAT doesn't face broken transport).
Can't say how much native and bmp-v3 were affected, as they incorporate small busy-loops in platform_nrst_set_val(); this will increase the reset pulse (active low) duration, which is not necessarily a bad thing. Later the busy-loops can be removed from platforms where present.
BMDA was not affected as USB FS and synchronous nature of BMP remote protocol resulted in sufficient delay.
riscv_reset() has some riscv_dm_poll_state() call between nrst_set_val edges, which is basically a riscv_dm_read(), which might be long enough -- keeping as-is.

Your checklist for this pull request

Closing issues

Fixes #1868 point 2.

## Detailed description * No new features. * The existing problem is the reset pulse of too short duration on some in-tree BMP platforms. #1868 point 2. * This PR solves it by adding a minimal (1ms) delay at `cortexm_reset()` callsite (and cortexar). This was previously tested to fix `stlink` and `blackpill-f411ce` so that they are able to cortexm_reset by wire the AT32F403A target connected via JTAG transport. See #2248 (actually problem present since before PR2072). This seems to be the easier of the two mitigation variants for it (the other is invoking `dp->ensure_idle()` somehow mid-write to AIRCR via ADIv5 MEM-AP so that READ DP CTRL/STAT doesn't face broken transport). Can't say how much `native` and `bmp-v3` were affected, as they incorporate small busy-loops in `platform_nrst_set_val()`; this will increase the reset pulse (active low) duration, which is not necessarily a bad thing. Later the busy-loops can be removed from platforms where present. BMDA was not affected as USB FS and synchronous nature of BMP remote protocol resulted in sufficient delay. `riscv_reset()` has some `riscv_dm_poll_state()` call between nrst_set_val edges, which is basically a `riscv_dm_read()`, which might be long enough -- keeping as-is. ## Your checklist for this pull request * [x] I've read the [Code of Conduct](https://codeberg.org/blackmagic-debug/blackmagic/src/CODE_OF_CONDUCT.md) * [x] I've read the [guidelines for contributing](https://codeberg.org/blackmagic-debug/blackmagic/src/CONTRIBUTING.md) to this repository * [x] It builds for hardware native (see [Building the firmware](https://codeberg.org/blackmagic-debug/blackmagic?tab=readme-ov-file#building-the-firmware)) * [x] It builds as BMDA (see [Building the BMDA](https://codeberg.org/blackmagic-debug/blackmagic?tab=readme-ov-file#building-black-magic-debug-app)) * [x] I've tested it to the best of my ability * [x] My commit messages provide a useful short description of what the commits do ## Closing issues Fixes #1868 point 2.
cortexm, cortexar: Add a minimum reset pulse duration
Some checks failed
ci/woodpecker/pr/build-firmware/5 Pipeline failed
ci/woodpecker/pr/build-firmware/1 Pipeline failed
ci/woodpecker/pr/build-firmware/3 Pipeline failed
ci/woodpecker/pr/build-firmware/2 Pipeline failed
ci/woodpecker/pr/build-firmware/6 Pipeline failed
ci/woodpecker/pr/build-firmware/7 Pipeline failed
ci/woodpecker/pr/build-firmware/8 Pipeline failed
ci/woodpecker/pr/build-firmware/9 Pipeline failed
ci/woodpecker/pr/build-firmware/11 Pipeline failed
ci/woodpecker/pr/build-firmware/10 Pipeline failed
ci/woodpecker/pr/build-firmware/13 Pipeline failed
ci/woodpecker/pr/build-firmware/12 Pipeline failed
ci/woodpecker/pr/build-firmware/14 Pipeline failed
ci/woodpecker/pr/build-firmware/16 Pipeline failed
ci/woodpecker/pr/build-firmware/15 Pipeline failed
ci/woodpecker/pr/build-firmware/18 Pipeline failed
ci/woodpecker/pr/build-firmware/17 Pipeline failed
ci/woodpecker/pr/build-firmware/19 Pipeline failed
ci/woodpecker/pr/build-firmware/20 Pipeline failed
ci/woodpecker/pr/build-linux/1 Pipeline failed
ci/woodpecker/pr/build-windows Pipeline failed
ci/woodpecker/pr/build-linux/2 Pipeline failed
ci/woodpecker/pr/lint Pipeline failed
ci/woodpecker/pr/build-firmware/4 Pipeline was successful
19e3e69800
dragonmux requested changes 2026年05月12日 03:57:27 +02:00
Dismissed
dragonmux left a comment
Copy link

Change looks good but we'd really like you to pull the delay loops out of the bmp-v2 and bmp-v3 platforms to match. That way we get much more consistent behaviour between all the platforms and save on some code size.

Change looks good but we'd really like you to pull the delay loops out of the bmp-v2 and bmp-v3 platforms to match. That way we get much more consistent behaviour between all the platforms and save on some code size.
platforms: Delete the "for-volatile-counter" delay from nrst_set_val()
Some checks failed
ci/woodpecker/pr/build-firmware/16 Pipeline was successful
ci/woodpecker/pr/build-firmware/14 Pipeline was successful
ci/woodpecker/pr/build-firmware/19 Pipeline was successful
ci/woodpecker/pr/build-linux/1 Pipeline was successful
ci/woodpecker/pr/build-linux/2 Pipeline was successful
ci/woodpecker/pr/build-windows Pipeline was successful
ci/woodpecker/pr/lint Pipeline was successful
ci/woodpecker/push/build-firmware/1 Pipeline was successful
ci/woodpecker/push/build-firmware/4 Pipeline was successful
ci/woodpecker/push/build-firmware/6 Pipeline was successful
ci/woodpecker/push/build-firmware/2 Pipeline was successful
ci/woodpecker/push/build-firmware/3 Pipeline was successful
ci/woodpecker/push/build-firmware/5 Pipeline was successful
ci/woodpecker/push/build-firmware/7 Pipeline was successful
ci/woodpecker/push/build-firmware/8 Pipeline failed
ci/woodpecker/push/build-firmware/13 Pipeline failed
ci/woodpecker/push/build-firmware/14 Pipeline was successful
ci/woodpecker/push/build-firmware/9 Pipeline was successful
ci/woodpecker/push/build-firmware/15 Pipeline was successful
ci/woodpecker/push/build-firmware/11 Pipeline was successful
ci/woodpecker/push/build-firmware/12 Pipeline was successful
ci/woodpecker/push/build-firmware/10 Pipeline was successful
ci/woodpecker/push/build-linux/1 Pipeline was successful
ci/woodpecker/push/build-firmware/18 Pipeline failed
ci/woodpecker/push/build-firmware/17 Pipeline was successful
ci/woodpecker/push/build-linux/2 Pipeline was successful
ci/woodpecker/push/build-firmware/16 Pipeline was successful
ci/woodpecker/push/build-firmware/20 Pipeline was successful
ci/woodpecker/push/build-firmware/19 Pipeline was successful
ci/woodpecker/push/build-windows Pipeline was successful
64958ec29d
* Any delays necessary will exist at callsites
* Most platforms do not have this delay
* Duration of 10000 iterations depends on Hclk and architecture (stlinkv3 CM7 may complete faster)
dragonmux left a comment
Copy link

This LGTM, merging once CI completes. Thank you for the contribution!

This LGTM, merging once CI completes. Thank you for the contribution!
Sign in to join this conversation.
No reviewers
Labels
Clear labels
BMD App
Black Magic Debug App (aka. PC hosted) (not firmware)
BMP Firmware
Black Magic Probe Firmware (not PC hosted software)
Bug
Confirmed bug
Build system
Build system
Can't reproduce
Maintainers can't reproduce this problem
CI
Continuous Integration System
Contribution wanted
User contributions welcome
Documentation
Project documentation
Draft
Work in progress draft
Duplicate
This issue or pull request already exists
Enhancement
General project improvement
Feedback wanted
Requires additional submitter feedback
Foreign Host Board
Non Native hardware to runing Black Magic firmware on
GDB
Issue/PR related to GDB
Good first issue
Good for newcommers
HwIssue Mitigation
Solving or mitigating a Hardware issue in Software
Information Needed
Maintainers need more information
NativeHardware
Official Black Magic Debug Hardware
New Host Board
New hardware to run Black Magic firmware on
New Target
New debug target
Off Topic
Something that does not involve the project in any way
Potential Bug
A potential, unconfirmed or very special circumstance bug
Regression
Bug caused by a regression
User Interest Needed
More user interest required before consideration
User Testing Needed
Looking for user testing reports
Won't fix
Outside of the project scope or works as intended
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
blackmagic-debug/blackmagic!2251
Reference in a new issue
blackmagic-debug/blackmagic
No description provided.
Delete branch "ALTracer/blackmagic:fix/target-reset-pulse"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?