Skip to content

Commit

Permalink
Merge branch 'refactor/usb_host_hcd_dwc_enum_messages' into 'master'
Browse files Browse the repository at this point in the history
refactor(usb_host):  HCD DWC and Enum additional error messages

See merge request espressif/esp-idf!34236
  • Loading branch information
roma-jam committed Oct 25, 2024
2 parents 57553ec + c19e2b7 commit 501e4e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
20 changes: 13 additions & 7 deletions components/usb/enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,9 +765,15 @@ static esp_err_t control_response_handling(enum_stage_t stage)
usb_transfer_t *ctrl_xfer = &p_enum_driver->constant.urb->transfer;

if (ctrl_xfer->status != USB_TRANSFER_STATUS_COMPLETED) {
ESP_LOGE(ENUM_TAG, "Bad transfer status %d: %s",
ctrl_xfer->status,
enum_stage_strings[stage]);
if (ctrl_xfer->status == USB_TRANSFER_STATUS_STALL &&
stage >= ENUM_STAGE_CHECK_SHORT_LANGID_TABLE &&
stage <= ENUM_STAGE_CHECK_FULL_SER_STR_DESC) {
// String Descriptor request could be STALLed, if the device doesn't have them
} else {
ESP_LOGE(ENUM_TAG, "Bad transfer status %d: %s",
ctrl_xfer->status,
enum_stage_strings[stage]);
}
return ret;
}

Expand Down Expand Up @@ -1015,10 +1021,6 @@ static bool set_next_stage(bool last_stage_pass)
next_stage = last_stage + 1;
}
} else {
ESP_LOGE(ENUM_TAG, "[%d:%d] %s FAILED",
p_enum_driver->single_thread.parent_dev_addr,
p_enum_driver->single_thread.parent_port_num,
enum_stage_strings[last_stage]);
// These stages cannot fail
assert(last_stage != ENUM_STAGE_SET_ADDR_RECOVERY &&
last_stage != ENUM_STAGE_SELECT_CONFIG &&
Expand Down Expand Up @@ -1055,6 +1057,10 @@ static bool set_next_stage(bool last_stage_pass)
break;
default:
// Stage is not allowed to failed. Cancel enumeration.
ESP_LOGE(ENUM_TAG, "[%d:%d] %s FAILED",
p_enum_driver->single_thread.parent_dev_addr,
p_enum_driver->single_thread.parent_port_num,
enum_stage_strings[last_stage]);
next_stage = ENUM_STAGE_CANCEL;
break;
}
Expand Down
2 changes: 2 additions & 0 deletions components/usb/hcd_dwc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1814,6 +1814,8 @@ esp_err_t hcd_pipe_alloc(hcd_port_handle_t port_hdl, const hcd_pipe_config_t *pi
bool chan_allocated = usb_dwc_hal_chan_alloc(port->hal, pipe->chan_obj, (void *) pipe);
if (!chan_allocated) {
HCD_EXIT_CRITICAL();
// The only reason why alloc channel could return false is no more free channels
ESP_LOGE(HCD_DWC_TAG, "No more HCD channels available");
ret = ESP_ERR_NOT_SUPPORTED;
goto err;
}
Expand Down

0 comments on commit 501e4e6

Please sign in to comment.