summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2025-11-03 22:00:05 +0800
committersakumisu <[email protected]>2025-11-03 22:01:12 +0800
commitd482b7c7388d126a1571820a55925d320cfbafd0 (patch)
treea43e68b861582a231dceab3408330631239f204b
parent1d3b7fb203433d3891b3c902162cbe4a9387224f (diff)
update(core/usbh_core): add retry for control transfer, some devices are flakey
Signed-off-by: sakumisu <[email protected]>
-rw-r--r--core/usbh_core.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/core/usbh_core.c b/core/usbh_core.c
index 8860716a..bc4b4dca 100644
--- a/core/usbh_core.c
+++ b/core/usbh_core.c
@@ -729,6 +729,7 @@ int usbh_deinitialize(uint8_t busid)
int usbh_control_transfer(struct usbh_hubport *hport, struct usb_setup_packet *setup, uint8_t *buffer)
{
struct usbh_urb *urb;
+ volatile uint8_t retry = 3;
int ret;
if (!hport || !setup) {
@@ -741,12 +742,21 @@ int usbh_control_transfer(struct usbh_hubport *hport, struct usb_setup_packet *s
usbh_print_setup(setup);
+resubmit:
usbh_control_urb_fill(urb, hport, setup, buffer, setup->wLength, CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT, NULL, NULL);
ret = usbh_submit_urb(urb);
if (ret == 0) {
ret = urb->actual_length;
}
+ if (ret < 0 && (ret != -USB_ERR_TIMEOUT)) {
+ retry--;
+ if (retry > 0) {
+ USB_LOG_WRN("Control transfer failed, errorcode %d, retrying...\r\n", ret);
+ goto resubmit;
+ }
+ }
+
usb_osal_mutex_give(hport->mutex);
return ret;
}