blackpill-f4: Enable internal weak pull-up on nRST, simplify set_val #2068
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Detailed description
blackpill-f4
, which is, at least, inconsistent with other in-tree platforms.The original implementation was contributed like this in #1280 v1.8.0-702-g 02986d6 and such code snippet is correct for F1 GPIO, where resistors are part of input stage, but superflous for F4 GPIO, which retains PU/PD config across all digital modes (Input, Output, AF). I don't even see a reason to change modes or output-settings away from Output + Open-Drain + Pull-up + Lowest OSPEED.
gpio_clear
activates the low FET,gpio_set
deactivates it, soGPIO_ACTIVE_LOW
in Linux device-tree gpio bindings speak, or inverse polarity (!assert
). Seestlinkv3
, except I omit the busy-delay, more on that later.For platform_init, I guess neither TRST nor NRST were set up into output modes. For F4,
gpio_set()
during Digital Input mode does not enable internal weak pull-up, contrary to F1. Thegpio_clear()
during Output open-drain worked, but only when the wire was connected, and otherwise the level read back was whatever/floating. This interferes with BMD ADIv5 and Cortex-M layers logic. I can't tell for sure where exactly. Another adjacent problem is inconsistent nrst control implementation in platforms, I believe any delays should be hoisted up from platforms (volatile busy-delays) to callsites, but this is almost out of scope here.Tested on
blackpill-f411ce
with no shields/carriers in default pinout. Stabilizes the scans where previously bogus romtable entries were logged. Removes "SWD scan failed!" occasions when wiring and power are otherwise correct (and target's SWJ-DP is mapped and functional etc.)Your checklist for this pull request
Closing issues
Fixes #2062.