From 9d1c8f4f1815ce1d4bcea32ab7ef2cb830e90a08 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 3 Apr 2023 21:03:07 +0800 Subject: [PATCH] Fix usb enumeration stage error for some device --- components/usb/hub.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/usb/hub.c b/components/usb/hub.c index da53cae2b6..4606e44863 100644 --- a/components/usb/hub.c +++ b/components/usb/hub.c @@ -164,6 +164,7 @@ typedef struct { uint8_t iProduct; /**< Index of the Product string descriptor */ uint8_t iSerialNumber; /**< Index of the Serial Number string descriptor */ uint8_t str_desc_bLength; /**< Saved bLength from getting a short string descriptor */ + uint8_t bConfigurationValue; /**< Device's current configuration number */ } enum_ctrl_t; typedef struct { @@ -365,7 +366,7 @@ static bool enum_stage_transfer(enum_ctrl_t *enum_ctrl) break; } case ENUM_STAGE_SET_CONFIG: { - USB_SETUP_PACKET_INIT_SET_CONFIG((usb_setup_packet_t *)transfer->data_buffer, ENUM_CONFIG_INDEX + 1); + USB_SETUP_PACKET_INIT_SET_CONFIG((usb_setup_packet_t *)transfer->data_buffer, enum_ctrl->bConfigurationValue); transfer->num_bytes = sizeof(usb_setup_packet_t); //No data stage enum_ctrl->expect_num_bytes = 0; //OUT transfer. No need to check number of bytes returned break; @@ -516,6 +517,7 @@ static bool enum_stage_transfer_check(enum_ctrl_t *enum_ctrl) case ENUM_STAGE_CHECK_FULL_CONFIG_DESC: { //Fill configuration descriptor into the device object const usb_config_desc_t *config_desc = (usb_config_desc_t *)(transfer->data_buffer + sizeof(usb_setup_packet_t)); + enum_ctrl->bConfigurationValue = config_desc->bConfigurationValue; ESP_ERROR_CHECK(usbh_hub_enum_fill_config_desc(enum_ctrl->dev_hdl, config_desc)); ret = true; break;