-
Notifications
You must be signed in to change notification settings - Fork 2.1k
driver/usbdev_synopsys_dwc2: use correct number of EPs #19380
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
driver/usbdev_synopsys_dwc2: use correct number of EPs #19380
Conversation
This commit fixes the problem that the driver uses the wrong number of EPs when using the USB OTG HS core. The reason is that the constant `DWC2_USB_OTG_FS_NUM_EP` is used in several places even though there is a function `_max_endpoints` which takes into account the configuration used. For most MCUs this is not a problem, because they have only a USB OTG FS core anyway. But for MCUs like the STM32, which has both a USB OTG FS core and a USB OTG HS core, it matters.
bors merge |
Build succeeded: |
Thanks for reviewing. |
This is really really strange. This very small change leads for the |
If I change it back here
DWC2_USB_OTG_FS_NUM_EP while finding an unused EP in _usbdev_new_ep , it works.
Even more strange, if I leave the code as is, i.e. using diff --git a/drivers/usbdev_synopsys_dwc2/usbdev_synopsys_dwc2.c b/drivers/usbdev_synopsys_dwc2/usbdev_synopsys_dwc2.c
index 5ea29f682c..27804d220c 100644
--- a/drivers/usbdev_synopsys_dwc2/usbdev_synopsys_dwc2.c
+++ b/drivers/usbdev_synopsys_dwc2/usbdev_synopsys_dwc2.c
@@ -539,6 +539,7 @@ static usbdev_ep_t *_usbdev_new_ep(usbdev_t *dev, usb_ep_type_t type,
ep->num = idx;
}
}
+ if (ep == NULL) { printf ("NULL"); }
}
if (ep && ep->type == USB_EP_TYPE_NONE) { it works although the So there seems to be something that is soooo time critical that it works with very small code changes, but doesn't work without those small code changes. |
Contribution description
This PR fixes the problem that the driver uses the wrong number of EPs when using the USB OTG HS core.
The constant
DWC2_USB_OTG_FS_NUM_EP
was used in several places independent on whether the USB OTG FS core or the USB OTG HS core is used even though there is a function_max_endpoints
which takes into account the configuration used. For most MCUs this was not a problem, because they have only a USB OTG FS core anyway. But for MCUs like the STM32, which have both a USB OTG FS core and a USB OTG HS core, it matters.Testing procedure
Use either
or
Without this PR it just stucks due to an
assert
here:RIOT/sys/usb/usbus/cdc/ecm/cdc_ecm.c
Lines 217 to 221 in 19da279
With the PR it works as expected.
Issues/PRs references