Skip to content

Commit d7222cc

Browse files
committed
Merge branch 'feature/usb_host_ext_hub_error_handle' into 'master'
feat(ext_hub): Added device error handling Closes IDF-10057 Closes #15437 See merge request espressif/esp-idf!33956
2 parents 61f992a + e815f68 commit d7222cc

File tree

7 files changed

+192
-165
lines changed

7 files changed

+192
-165
lines changed

Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,5 @@ mainmenu "Espressif IoT Development Framework Configuration"
702702
- CONFIG_BOOTLOADER_CACHE_32BIT_ADDR_QUAD_FLASH
703703
- CONFIG_ESP_WIFI_EAP_TLS1_3
704704
- CONFIG_ESP_WIFI_ENABLE_ROAMING_APP
705-
- CONFIG_USB_HOST_EXT_PORT_SUPPORT_LS
706705
- CONFIG_USB_HOST_EXT_PORT_RESET_ATTEMPTS
707706
- CONFIG_LIBC_PICOLIBC

components/usb/Kconfig

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,6 @@ menu "USB-OTG"
115115
menu "Downstream Port configuration"
116116
depends on USB_HOST_HUBS_SUPPORTED
117117

118-
config USB_HOST_EXT_PORT_SUPPORT_LS
119-
depends on IDF_EXPERIMENTAL_FEATURES
120-
bool "Support LS"
121-
default n
122-
help
123-
Enables support of Low-speed devices, connected through the external Hub.
124-
125118
config USB_HOST_EXT_PORT_RESET_ATTEMPTS
126119
depends on IDF_EXPERIMENTAL_FEATURES
127120
# Invisible config option

components/usb/ext_hub.c

Lines changed: 177 additions & 136 deletions
Large diffs are not rendered by default.

components/usb/hub.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -351,16 +351,6 @@ static void ext_port_event_callback(ext_port_event_data_t *event_data, void *arg
351351
}
352352
}
353353

354-
#if (!CONFIG_USB_HOST_EXT_PORT_SUPPORT_LS)
355-
if (port_speed == USB_SPEED_LOW) {
356-
ESP_LOGE(HUB_DRIVER_TAG, "Connected %s-speed device, not supported",
357-
(char *[]) {
358-
"Low", "Full", "High"
359-
}[port_speed]);
360-
goto new_ds_dev_err;
361-
}
362-
#endif // CONFIG_USB_HOST_EXT_PORT_SUPPORT_LS
363-
364354
if (dev_tree_node_new(event_data->connected.parent_dev_hdl, event_data->connected.parent_port_num, port_speed) != ESP_OK) {
365355
ESP_LOGE(HUB_DRIVER_TAG, "Failed to add new downstream device");
366356
goto new_ds_dev_err;

components/usb/private_include/ext_hub.h

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -127,7 +127,7 @@ esp_err_t ext_hub_get_handle(usb_device_handle_t dev_hdl, ext_hub_handle_t *ext_
127127
*
128128
* @return
129129
* - ESP_OK: New device added successfully
130-
* - ESP_ERR_INVALID_STATE: External Hub driver is not installed, or not in correct state to add a new device
130+
* - ESP_ERR_NOT_ALLOWED: External Hub driver is not installed
131131
*/
132132
esp_err_t ext_hub_new_dev(uint8_t dev_addr);
133133

@@ -141,7 +141,7 @@ esp_err_t ext_hub_new_dev(uint8_t dev_addr);
141141
*
142142
* @return
143143
* - ESP_OK: Device freed successfully
144-
* - ESP_ERR_INVALID_STATE: External Hub driver is not installed
144+
* - ESP_ERR_NOT_ALLOWED: External Hub driver is not installed
145145
* - ESP_ERR_INVALID_ARG: Invalid argument
146146
* - ESP_ERR_NOT_FOUND: Device address not found
147147
*/
@@ -182,7 +182,7 @@ esp_err_t ext_hub_status_handle_complete(ext_hub_handle_t ext_hub_hdl);
182182
*
183183
* @return
184184
* - ESP_OK: All events handled
185-
* - ESP_ERR_INVALID_STATE: External Hub driver is not installed
185+
* - ESP_ERR_NOT_ALLOWED: External Hub driver is not installed
186186
*/
187187
esp_err_t ext_hub_process(void);
188188

@@ -199,10 +199,11 @@ esp_err_t ext_hub_process(void);
199199
*
200200
* @return
201201
* - ESP_OK: The port can be recycled
202-
* - ESP_ERR_INVALID_STATE: External Hub driver is not installed
202+
* - ESP_ERR_NOT_ALLOWED: External Hub driver is not installed
203203
* - ESP_ERR_INVALID_ARG: Invalid argument
204204
* - ESP_ERR_INVALID_SIZE: External Hub port number out of the hub's range
205205
* - ESP_ERR_NOT_SUPPORTED: External Port Driver has not been installed
206+
* - ESP_ERR_INVALID_STATE: External Hub wasn't configured or suspended
206207
*/
207208
esp_err_t ext_hub_port_recycle(ext_hub_handle_t ext_hub_hdl, uint8_t port_num);
208209

@@ -214,7 +215,7 @@ esp_err_t ext_hub_port_recycle(ext_hub_handle_t ext_hub_hdl, uint8_t port_num);
214215
*
215216
* @return
216217
* - ESP_OK: The port can be reset
217-
* - ESP_ERR_INVALID_STATE: External Hub driver is not installed
218+
* - ESP_ERR_NOT_ALLOWED: External Hub driver is not installed
218219
* - ESP_ERR_INVALID_ARG: Invalid argument
219220
* - ESP_ERR_INVALID_SIZE: External Hub port number out of the hub's range
220221
* - ESP_ERR_NOT_SUPPORTED: External Port Driver has not been installed
@@ -229,7 +230,7 @@ esp_err_t ext_hub_port_reset(ext_hub_handle_t ext_hub_hdl, uint8_t port_num);
229230
*
230231
* @return
231232
* - ESP_OK: Device on the External hub's port has been enumerated
232-
* - ESP_ERR_INVALID_STATE: External Hub driver is not installed
233+
* - ESP_ERR_NOT_ALLOWED: External Hub driver is not installed
233234
* - ESP_ERR_INVALID_ARG: Invalid argument
234235
* - ESP_ERR_INVALID_SIZE: External Hub port number out of the hub's range
235236
* - ESP_ERR_NOT_SUPPORTED: External Port Driver has not been installed
@@ -244,10 +245,11 @@ esp_err_t ext_hub_port_active(ext_hub_handle_t ext_hub_hdl, uint8_t port_num);
244245
*
245246
* @return
246247
* - ESP_OK: Device on the External hub's port can be disabled
247-
* - ESP_ERR_INVALID_STATE: External Hub driver is not installed
248+
* - ESP_ERR_NOT_ALLOWED: External Hub driver is not installed
248249
* - ESP_ERR_INVALID_ARG: Invalid argument
249250
* - ESP_ERR_INVALID_SIZE: External Hub port number out of the hub's range
250251
* - ESP_ERR_NOT_SUPPORTED: External Port Driver has not been installed
252+
* - ESP_ERR_INVALID_STATE: External Hub wasn't configured or suspended
251253
*/
252254
esp_err_t ext_hub_port_disable(ext_hub_handle_t ext_hub_hdl, uint8_t port_num);
253255

@@ -260,10 +262,11 @@ esp_err_t ext_hub_port_disable(ext_hub_handle_t ext_hub_hdl, uint8_t port_num);
260262
*
261263
* @return
262264
* - ESP_OK: The device's speed obtained successfully
263-
* - ESP_ERR_INVALID_STATE: External Hub driver is not installed
265+
* - ESP_ERR_NOT_ALLOWED: External Hub driver is not installed
264266
* - ESP_ERR_INVALID_ARG: Invalid argument
265267
* - ESP_ERR_INVALID_SIZE: External Hub port number out of the hub's range
266268
* - ESP_ERR_NOT_SUPPORTED: External Port Driver has not been installed
269+
* - ESP_ERR_INVALID_STATE: External Hub wasn't configured or suspended
267270
*/
268271
esp_err_t ext_hub_port_get_speed(ext_hub_handle_t ext_hub_hdl, uint8_t port_num, usb_speed_t *speed);
269272

@@ -281,6 +284,7 @@ esp_err_t ext_hub_port_get_speed(ext_hub_handle_t ext_hub_hdl, uint8_t port_num,
281284
* - ESP_ERR_NOT_ALLOWED: External Hub driver is not installed
282285
* - ESP_ERR_INVALID_ARG: Invalid argument
283286
* - ESP_ERR_INVALID_SIZE: External Hub port number out of the hub's range
287+
* - ESP_ERR_INVALID_STATE: External Hub is not configured or suspended
284288
*/
285289
esp_err_t ext_hub_set_port_feature(ext_hub_handle_t ext_hub_hdl, uint8_t port_num, uint8_t feature);
286290

@@ -296,6 +300,7 @@ esp_err_t ext_hub_set_port_feature(ext_hub_handle_t ext_hub_hdl, uint8_t port_nu
296300
* - ESP_ERR_NOT_ALLOWED: External Hub driver is not installed
297301
* - ESP_ERR_INVALID_ARG: Invalid argument
298302
* - ESP_ERR_INVALID_SIZE: External Hub port number out of the hub's range
303+
* - ESP_ERR_INVALID_STATE: External Hub is not configured or suspended
299304
*/
300305
esp_err_t ext_hub_clear_port_feature(ext_hub_handle_t ext_hub_hdl, uint8_t port_num, uint8_t feature);
301306

@@ -313,6 +318,7 @@ esp_err_t ext_hub_clear_port_feature(ext_hub_handle_t ext_hub_hdl, uint8_t port_
313318
* - ESP_ERR_NOT_ALLOWED: External Hub driver is not installed
314319
* - ESP_ERR_INVALID_ARG: Invalid argument
315320
* - ESP_ERR_INVALID_SIZE: External Hub port number out of the hub's range
321+
* - ESP_ERR_INVALID_STATE: External Hub is not configured or suspended
316322
*/
317323
esp_err_t ext_hub_get_port_status(ext_hub_handle_t ext_hub_hdl, uint8_t port_num);
318324

docs/en/api-reference/peripherals/usb_host.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ Currently, the Host Library and the underlying Host Stack has the following limi
4545
- Only supports using one configuration. Changing to other configurations after enumeration is not supported yet.
4646
- Transfer timeouts are not supported yet.
4747
:esp32p4: - {IDF_TARGET_NAME} contains two USB-OTG peripherals USB 2.0 OTG High-Speed and USB 2.0 OTG Full-Speed. Only the High-Speed instance is supported now.
48-
- The External Hub Driver: Supports only devices with the same speed as upstream port speed (e.g., Low-speed device won't work through Full-speed external Hub).
4948
- The External Hub Driver: Remote Wakeup feature is not supported (External Hubs are active, even if there are no devices inserted).
5049
- The External Hub Driver: Doesn't handle error cases (overcurrent handling, errors during initialization etc. are not implemented yet).
5150
- The External Hub Driver: No Interface selection. The Driver uses the first available Interface with Hub Class code (09h).

docs/zh_CN/api-reference/peripherals/usb_host.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ USB 主机库(以下简称主机库)是 USB 主机栈的最底层,提供
4545
- 仅支持使用发现的首个配置,尚不支持变更为其他配置。
4646
- 尚不支持传输超时。
4747
:esp32p4: - {IDF_TARGET_NAME} 包含两个 USB-OTG 外设:USB 2.0 OTG 高速和 USB 2.0 OTG 全速。目前仅支持高速实例。
48-
- 外部 Hub 驱动:仅支持与上游端口速率相同的设备。(例如,低速设备无法通过全速外部 Hub 工作。)
4948
- 外部 Hub 驱动:不支持远程唤醒功能(即使没有设备插入,外部 Hub 也处于工作状态)。
5049
- 外部 Hub 驱动:不处理错误用例(尚未实现过流处理、初始化错误等功能)。
5150
- 外部 Hub 驱动:不支持接口选择。驱动程序使用具有 Hub 类代码 (09h) 的第一个可用接口。

0 commit comments

Comments
 (0)