Skip to content

Commit 501e4e6

Browse files
committed
Merge branch 'refactor/usb_host_hcd_dwc_enum_messages' into 'master'
refactor(usb_host): HCD DWC and Enum additional error messages See merge request espressif/esp-idf!34236
2 parents 57553ec + c19e2b7 commit 501e4e6

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

components/usb/enum.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -765,9 +765,15 @@ static esp_err_t control_response_handling(enum_stage_t stage)
765765
usb_transfer_t *ctrl_xfer = &p_enum_driver->constant.urb->transfer;
766766

767767
if (ctrl_xfer->status != USB_TRANSFER_STATUS_COMPLETED) {
768-
ESP_LOGE(ENUM_TAG, "Bad transfer status %d: %s",
769-
ctrl_xfer->status,
770-
enum_stage_strings[stage]);
768+
if (ctrl_xfer->status == USB_TRANSFER_STATUS_STALL &&
769+
stage >= ENUM_STAGE_CHECK_SHORT_LANGID_TABLE &&
770+
stage <= ENUM_STAGE_CHECK_FULL_SER_STR_DESC) {
771+
// String Descriptor request could be STALLed, if the device doesn't have them
772+
} else {
773+
ESP_LOGE(ENUM_TAG, "Bad transfer status %d: %s",
774+
ctrl_xfer->status,
775+
enum_stage_strings[stage]);
776+
}
771777
return ret;
772778
}
773779

@@ -1015,10 +1021,6 @@ static bool set_next_stage(bool last_stage_pass)
10151021
next_stage = last_stage + 1;
10161022
}
10171023
} else {
1018-
ESP_LOGE(ENUM_TAG, "[%d:%d] %s FAILED",
1019-
p_enum_driver->single_thread.parent_dev_addr,
1020-
p_enum_driver->single_thread.parent_port_num,
1021-
enum_stage_strings[last_stage]);
10221024
// These stages cannot fail
10231025
assert(last_stage != ENUM_STAGE_SET_ADDR_RECOVERY &&
10241026
last_stage != ENUM_STAGE_SELECT_CONFIG &&
@@ -1055,6 +1057,10 @@ static bool set_next_stage(bool last_stage_pass)
10551057
break;
10561058
default:
10571059
// Stage is not allowed to failed. Cancel enumeration.
1060+
ESP_LOGE(ENUM_TAG, "[%d:%d] %s FAILED",
1061+
p_enum_driver->single_thread.parent_dev_addr,
1062+
p_enum_driver->single_thread.parent_port_num,
1063+
enum_stage_strings[last_stage]);
10581064
next_stage = ENUM_STAGE_CANCEL;
10591065
break;
10601066
}

components/usb/hcd_dwc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,6 +1814,8 @@ esp_err_t hcd_pipe_alloc(hcd_port_handle_t port_hdl, const hcd_pipe_config_t *pi
18141814
bool chan_allocated = usb_dwc_hal_chan_alloc(port->hal, pipe->chan_obj, (void *) pipe);
18151815
if (!chan_allocated) {
18161816
HCD_EXIT_CRITICAL();
1817+
// The only reason why alloc channel could return false is no more free channels
1818+
ESP_LOGE(HCD_DWC_TAG, "No more HCD channels available");
18171819
ret = ESP_ERR_NOT_SUPPORTED;
18181820
goto err;
18191821
}

0 commit comments

Comments
 (0)