fix enum walkaround forever check for SE0 when pull up is disabled #700
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.
Describe the PR
This issue is discovered while troubleshooting adafruit/circuitpython#4066 (comment)
Part of enumeration walkaround is waiting for bus reset to complete i.e line state != SE0.
https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/pico_fix/rp2040_usb_device_enumeration/rp2040_usb_device_enumeration.c#L61
However, when pull-up is disabled e.g application call
tud_disconnect()
to soft disconnect from Host (while still physically plugged in). SE0 will be permanent present causing the walkround forever checking for the state unitltud_connect()
(pullup is enabled) or cpu reset. Worse ifPICO_TIME_DEFAULT_ALARM_POOL_DISABLED = 1
, the walkaround will blockingly wait --> sort of hanged there.To reproduce, add this to any of the example, press the button, rp2040 will disconnect but forever hanged if PICO_TIME_DEFAULT_ALARM_POOL_DISABLED=1
Solution
Only run enumeration walkaround if pull-up is enabled.
Additional Context
I add a bit of TODO for VBus detect and Suspend & Resume later on. Note to myself: the pico schematic use GPIO24 which is is actually VBUS over current detection (FUN9), will need a jump wire to test later on.