-
-
Notifications
You must be signed in to change notification settings - Fork 781
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
native/platform: fix DFU detach #1707
Conversation
DFU detach wasn't lowering the USB pullup. This meant that BMP was rebooting into DFU bootloader mode, but the host wasn't re-enumerating it, because it hadn't detected a detach. In `platform_request_boot`, The `gpio_set_mode` config was for analog instead of floating input. PA8 isn't defined as an analog pin on this chip, so it's arguably undefined behavior. Also confirmed that using `scb_reset_system` instead of `scb_reset_core` to do the DFU reboot would correctly detach and enter the bootloader, if the boot button was held down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, and as we've talked about this at length on Discord to determine what was wrong and why, we're happy to merge this as-is. Thank you for the contribution!
For completeness, the DFU product string is |
For the record, BMP native D+ voltages measured with a DMM: Belkin USB 3.0 SuperSpeed hub with USB A device ports:
Directly connected to a USB C port on a M2 MacBook Air:
Note that 0.9V is within the forbidden zone for full-speed USB D+/D- voltages. (V_IL (max) is 0.8V for low/full speed, and V_IH (min) is 2.0V.) This strongly implies that the analog GPIO configuration is invalid for this pin, at least on this particular rev of GD32F103 silicon, and that the D+ pulldown on both the hub and the Mac's host port are reasonably within spec. In analog mode, the voltage did take a while to settle down to around 0.9V, which implies a somewhat moderate impedance or capacitance involved. The difference between the hub and directly-connected behaviors that I observed pre-patch are almost certainly due to allowed differences in threshold for detecting the disconnect voltage. A hub is required to detect SE0 when D+ and D- are both below V_IL (max), but is allowed to detect SE0 when they're both below V_IH (min). I might eventually put the analog scope on it, but this is strong enough evidence that the previous code was wrong, and plausibly causing DFU bootloader entry failures that might be inconsistent or difficult to reproduce. I applied a patch to instrument |
Agreed on your analysis there - thank you very much for getting that extra data on the issue, that's extremely useful. Think we'll be backporting this to v1.9 and v1.10 at the very least. |
DFU detach wasn't lowering the USB pullup. This meant that BMP was rebooting into DFU bootloader mode, but the host wasn't re-enumerating it, because it hadn't detected a detach.
In
platform_request_boot
, Thegpio_set_mode
config was for analog instead of floating input. PA8 isn't defined as an analog pin on this chip, so it's arguably undefined behavior.Also confirmed that using
scb_reset_system
instead ofscb_reset_core
to do the DFU reboot would correctly detach and enter the bootloader, if the boot button was held down.Detailed description
Your checklist for this pull request
make PROBE_HOST=native
)make PROBE_HOST=hosted
)Closing issues