nrf5x: Fix race condition during startup#1221
Merged
hathach merged 1 commit intohathach:masterfrom Dec 8, 2021
Merged
Conversation
hathach
reviewed
Dec 8, 2021
Owner
hathach
left a comment
There was a problem hiding this comment.
great work, thank you for the fix. Though maybe we should use tud_inited() . nrf dcd use usbd_defer_func() API to schedule/defer function call anyway 😄
When NRF5x device is reset by software (after DFU for example), power event is ready from the beginning. When power interrupt is triggered before tud_init() finished USBD_IRQn is enabled before it would be enabled in tud_init(). This in turn may result in BUS RESET event being sent from USB interrupt to USB task when queue is not initialized yet. This scenario often happens in Mynewt build where queue creation takes more time. To prevent this scenario USBD_IRQn is not enabled in power event interrupt handler before dcd_init() was called.
a21efa9 to
21db235
Compare
hathach
approved these changes
Dec 8, 2021
Owner
hathach
left a comment
There was a problem hiding this comment.
look great, thank you for the fix
Owner
|
PS: github ci seesm to have network issue, need to re-run the build. will merge when it complete. |
7FM
pushed a commit
to 7FM/tinyusb
that referenced
this pull request
Aug 23, 2025
This will enable builds to use pre-compiled copies of pioasm and elf2uf2, instead of requiring a native compiler.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
When NRF5x device is reset by software (after DFU for example),
power event is ready from the beginning.
When power interrupt is triggered before tud_init() finished
USBD_IRQn is enabled before it would be enabled in tud_init().
This in turn may result in BUS RESET event being sent from
USB interrupt to USB task when queue is not initialized yet.
This scenario often happens in Mynewt build where queue creation
takes more time.
To prevent this scenario USBD_IRQn is not enabled in power event
interrupt handler before dcd_init() was called.
Additional context
Fixes #1154
This solution is simple enough but I'm opened to other solutions.