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: improved target power backfeed safety #1434

Merged
merged 2 commits into from
Jul 31, 2023

Conversation

dragonmux
Copy link
Member

Detailed description

During a conversation on Discord with @compuphase it came up that the native hardware with current firmware allows you to some quite nasty things with the target power pin once feeding power from BMP has been enabled.

Saying "don't backfeed tpwr" is fine and all, but given the STM32F103 and related devices have an internal 1.2V bandgap reference, we set about figuring out how hard it might be to use the systick timer to sample that bandgap every few miliseconds and if we detect too much of a voltage rise or fall, switch tpwr feeding off.

This PR is the culmination of that work and should provide robust handling of tpwr backfeeding causing VCC to be driven up above 3.6V or down below 3.0V.

Your checklist for this pull request

  • I've read the Code of Conduct
  • I've read the guidelines for contributing to this repository
  • It builds for hardware native (make PROBE_HOST=native)
  • It builds as BMDA (make PROBE_HOST=hosted)
  • I've tested it to the best of my ability
  • My commit messages provide a useful short description of what the commits do

Closing issues

@dragonmux dragonmux added Enhancement General project improvement BMP Firmware Black Magic Probe Firmware (not PC hosted software) labels Apr 4, 2023
@dragonmux dragonmux added this to the v1.10 milestone Apr 4, 2023
@dragonmux dragonmux requested a review from esden April 4, 2023 10:25
@dragonmux dragonmux force-pushed the feature/improved-tpwr-backfeed-safety branch from 8ee0427 to 321ee44 Compare April 17, 2023 03:14
@dragonmux dragonmux force-pushed the feature/improved-tpwr-backfeed-safety branch from 321ee44 to 9370161 Compare April 24, 2023 13:16
@dragonmux dragonmux force-pushed the feature/improved-tpwr-backfeed-safety branch 2 times, most recently from f072273 to 82cf483 Compare June 6, 2023 05:23
@dragonmux dragonmux force-pushed the feature/improved-tpwr-backfeed-safety branch 2 times, most recently from 665e45e to 50d35e8 Compare June 22, 2023 05:12
@dragonmux dragonmux force-pushed the feature/improved-tpwr-backfeed-safety branch 2 times, most recently from a23d058 to a15f478 Compare July 4, 2023 16:24
@desertsagebrush
Copy link
Contributor

desertsagebrush commented Jul 7, 2023

I was able to test this a bit with a programmable power supply; the general test procedure for testing overvoltage protection was:

  • enable target power
  • match power supply voltage to that (current limit 100mA) and enable
  • slowly increase the voltage (10 mV steps) until twpr disables^1.
  • repeat several times

Cut-off over-voltage results, given as voltage (current drawn before cutoff):

BMP (native) v2.3b BMP (native) v2.1e
3.81 V (80 mA) 3.70 V (30 mA)
3.80 V (80 mA) 3.72 V (40 mA)
3.79 V (80 mA) 3.70 V (30 mA)
3.81 V (80 mA) 3.70 V (40 mA)
3.79 V (80 mA) 3.70 V (40 mA)
-------------------- --------------------
avg 3.8 V 3.70 V

Best guess for the difference is that there are slight differences in the bandgap generation between the GD23F103 and the STM32F103 implementations. (Or resistor differences, etc)

Will get to the under-voltage side a little bit later/in a few days

^1: This can also be seen as the point when the device stops sinking current from the power supply.

Power Supplies tested: Siglent SPD3303X-E, BK Precision 9206 (will test early next week)

@dragonmux
Copy link
Member Author

3.7-3.8V feels a bit high, but that's great that the feature works! that makes it seem like it's worth us adjusting the thresholds a little to get that 10-20mV down and closer to 3.3V for safety - but not bad.

Thank you for the help testing this. We look forward to seeing the under-voltage results

@dragonmux dragonmux force-pushed the feature/improved-tpwr-backfeed-safety branch 2 times, most recently from 9fe8dbd to 5537c0f Compare July 26, 2023 02:19
@desertsagebrush
Copy link
Contributor

Apologies for not responding sooner, but work came up with a vengeance and I've been dealing with that.

That being said, I did play with it a bit with both the Siglent SPD3303X-E and BK Precision 9206, and over-voltage stays the same. I still haven't been able to test the under-voltage side because lowering the output from the power supply doesn't pull the probe output voltage down (which makes sense; the power supply is designed to source current, not sink it), and I do not have a programmable load floating around.

@desertsagebrush
Copy link
Contributor

(I tested stuff again a few days ago before your newer commits, just FYI)

@dragonmux
Copy link
Member Author

Thank you for your help with this - the "new" commits have only been us rebasing the branch forward to keep it in sync with main.

Interesting behaviour on trying to undervolt the target power pin - guessing then that the regulator puts out progressively more current till reaching the current limit. If @esden is contented with this, we'll try and figure out a value that is closer to 3.6V for the upper cut-off and convert this PR to ready for review so we can get it included in v1.10

@dragonmux dragonmux force-pushed the feature/improved-tpwr-backfeed-safety branch from 5537c0f to 3fb9319 Compare July 28, 2023 06:48
…erence to check and see if VCC is being dragged too low/high by backfeeding through tpwr when enabled
@dragonmux dragonmux force-pushed the feature/improved-tpwr-backfeed-safety branch from 3fb9319 to 2ef3646 Compare July 28, 2023 20:20
@dragonmux
Copy link
Member Author

We've added a voltage threshold adjustment for the upper bound, which should improve the safety factor from it kicking in at 3.7-3.8V to it kicking in between 3.6-3.7V. We'll mark this ready for merge in the mean time as it's shown to work at least for the over-voltage side of things, and that's a great improvement over not having this at all.

@dragonmux dragonmux marked this pull request as ready for review July 28, 2023 20:22
Copy link
Member

@esden esden left a comment

Choose a reason for hiding this comment

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

LGTM, I think the best thing to do is to merge this so that it gets more use and testing before the next release.

@esden esden merged commit 24295b7 into main Jul 31, 2023
6 checks passed
@dragonmux dragonmux deleted the feature/improved-tpwr-backfeed-safety branch August 1, 2023 02:48
@dragonmux
Copy link
Member Author

Agreed, sounds good :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BMP Firmware Black Magic Probe Firmware (not PC hosted software) Enhancement General project improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants