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

Some misc fixes #2607

Merged
merged 4 commits into from
Apr 25, 2024
Merged

Some misc fixes #2607

merged 4 commits into from
Apr 25, 2024

Conversation

HiFiPhile
Copy link
Collaborator

Describe the PR
Some fixes I did when implementing dwc2 DMA support, better to do a separate PR.

@@ -202,10 +202,10 @@ static void edpt_activate(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoin
(xfer->max_size << DOEPCTL_MPSIZ_Pos);

if (dir == TUSB_DIR_OUT) {
dwc2->epout[epnum].doepctl |= dxepctl;
dwc2->epout[epnum].doepctl = dxepctl;
Copy link
Collaborator Author

@HiFiPhile HiFiPhile Apr 23, 2024

Choose a reason for hiding this comment

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

dxepctl is not cleared on bus reset, besides no need to do masked write.

@@ -280,10 +280,17 @@ static void bus_reset(uint8_t rhport) {
dwc2->epout[n].doepctl |= DOEPCTL_SNAK;
}

// 2. Disable all IN endpoints
for (uint8_t n = 0; n < ep_count; n++) {
Copy link
Collaborator Author

@HiFiPhile HiFiPhile Apr 23, 2024

Choose a reason for hiding this comment

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

If there are pending IN transfer on bus reset, eg. in cdc echo test do only write without read:
Since EPENA is not cleared on reset, once the EP is opened it will enter DIEPINT_TXFE interrupt and try to write packet and cause access violation.

@@ -700,11 +707,15 @@ void dcd_edpt_close_all(uint8_t rhport) {

for (uint8_t n = 1; n < ep_count; n++) {
// disable OUT endpoint
dwc2->epout[n].doepctl = 0;
if (dwc2->epout[n].doepctl & DOEPCTL_EPENA) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Write dxepctl to 0 won't clear EPENA.

Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

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

perfect, thank you for the fix

@hathach hathach merged commit fc91e15 into hathach:master Apr 25, 2024
69 checks passed
@HiFiPhile HiFiPhile deleted the dwc2_fix branch April 26, 2024 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants