Commit Graph

206 Commits

Author SHA1 Message Date
Roman Leonov
ea3f801e14 Merge branch 'feature/usb_host_ext_port_isolate_hub_request' into 'master'
refactor(ext_port): Isolated the hub class specific request

Closes IDF-12511

See merge request espressif/esp-idf!37272
2025-04-24 02:25:32 +08:00
peter.marcisovsky
6dfb7269a1 feat(usb_host): Host tests for individual USB Host layers
- Public API CMock based Host tests
    - USB Host layer: driver install/uninstall unit test
    - USBH layer: driver install/uninstall unit test
    - Host tests are run in CI
2025-04-23 12:09:25 +02:00
Roman Leonov
941647597b refactor(ext_port): Changed the mechanism for hub class request
Merged all Hub Class specific request to one function.
Added a callback for the External Port Driver to break the dependency from ext_hub.h
2025-04-23 10:52:34 +02:00
peter.marcisovsky
92ece05ac5 fix(usb_host): Correctly initialize set pipe ep char 2025-04-22 16:41:11 +02:00
Tomas Rezucha
179a468adf Merge branch 'fix/usb_host_hcd_test_pipe_stall' into 'master'
feat(usb_host): Fix HCD test HCD control pipe STALL

See merge request espressif/esp-idf!38338
2025-04-15 20:43:15 +08:00
Roman Leonov
dbf9d78763 fix(hcd): Added delay to slow down scatter-gather dma for ls device via fs hubs
Closes https://github.com/espressif/esp-idf/issues/15683
2025-04-11 17:06:08 +08:00
peter.marcisovsky
fe9290bfe1 fix(usb_host): Fix HCD Test pipe stall with only one URB enqeued 2025-04-10 17:44:16 +02:00
Roman Leonov
4e673844bf Merge branch 'refactor/usb_host_test_ext_hub_prereq' into 'master'
refactor(test_apps): Moved usb phy and hcd  to common folder

See merge request espressif/esp-idf!37551
2025-03-27 18:22:25 +08:00
Roman Leonov
d0f27448ad refactor(usb_host): Made phy and hcd common
fix
2025-03-26 12:49:31 +01:00
igor.masar
5f6155638d fix(usb_host): Fix return code and description
Changed error code from ESP_ERR_INVALID_STATE to ESP_ERR_NOT_FOUND
when the client never opened the device.
Updated function documentation to correctly reflect return values.
2025-03-25 23:00:56 +01:00
Myk Melez
aa669fa25d fix(usb_host): Give semaphore on attempted close of non-opened device
If you call *usb_host_device_close()* for a device that isn't open, the function exits early,
without giving back the semaphore it took, which causes any other call that tries to take
that semaphore to hang indefinitely.

Strangely, there's redundant handling of this condition, with two checks in a row that both handle
the case where `_check_client_opened_device(client_obj, dev_addr)` returns `false`:

```c
    HOST_CHECK_FROM_CRIT(_check_client_opened_device(client_obj, dev_addr), ESP_ERR_NOT_FOUND);
    if (!_check_client_opened_device(client_obj, dev_addr)) {
        // Client never opened this device
        ret = ESP_ERR_INVALID_STATE;
        HOST_EXIT_CRITICAL();
        goto exit;
    }
…
exit:
    xSemaphoreGive(p_host_lib_obj->constant.mux_lock);
    return ret;
```

The first line is the one that exits early, as HOST_CHECK_FROM_CRIT returns its second parameter
if its first parameter is false, without giving back the semaphore (although it does exit
the critical section).

The subsequent block handles the exact same case, except that it ensures the semaphore is given
back before returning. Currently, this block is never reached.

Perhaps the first check was added, then someone noticed the issue and added the second check,
but they forgot to remove the first one.

In any case, this PR removes the first check, so the second check can properly handle this case
by giving back the semaphore before returning.

This bug appears to have been present in the initial commit of the USB Host library to the ESP-IDF
repo: accbaee57c

Of course, if you never try to close a non-opened device, then you won't encounter it!
Unfortunately, I have some code that tried to do that, which is how I found the issue.
2025-03-24 21:58:34 +01:00
Roman Leonov
168aa0d25f feat(hcd): Added verification of intr pipe allocation with any bInterval 2025-03-21 20:25:38 +08:00
igor.udot
daf2d31008 test: format all test scripts 2025-03-05 12:08:48 +08:00
Tomas Rezucha
51fd02dd83 Merge branch 'fix/usb_phy_set_speed' into 'master'
fix(usb/phy): Fixed crash on external PHY init with speed != UNDEFINED

See merge request espressif/esp-idf!37218
2025-02-26 19:50:23 +08:00
Roman Leonov
858947e461 feat(ext_hub): Added support for low-speed devices, connected via hubs 2025-02-24 19:39:53 +08:00
Tomas Rezucha
ca24a117c7 fix(usb/phy): Fixed crash on external PHY init with speed != UNDEFINED
Also deprecated usb_phy_otg_dev_set_speed()
and usb_phy_action() which are no longer used in esp-idf
2025-02-21 14:11:51 +01:00
Roman Leonov
46952c601d feat(usb_host): Added uid presence check in USBH device object list 2025-02-19 10:23:44 +01:00
Roman Leonov
7c118fd072 feat(enum): Added test application to test enum driver with mocked device 2025-02-13 11:58:57 +01:00
Roman Leonov
9c8517045c fix(usb_phy): Removed pull resistors override configuration for Internal FSLS PHY 2025-02-05 12:28:38 +01:00
Roman Leonov
2255cdc462 fix(usb_host): Fixed unchecked return value in enum driver (coverity) 2025-01-28 14:11:55 +01:00
Tomas Rezucha
ce59bd4017 fix(usb): Fixed missing GPIO drive capability on ESP32-P4
All USB PHYs that share their IOs with GPIOs must set
the GPIO's drive capability to maximum.
2025-01-24 14:02:52 +01:00
Tomas Rezucha
65c2cc095d refactor(usb/phy): Merge P4 and S2/S3 PHYs into one module
P4 had separate PHY implementation for initial bring-up,
now we can merge it with the original PHY driver.
2025-01-15 11:18:10 +01:00
Peter Marcisovsky
c4a4de0bb1 Merge branch 'feat/usb_host_external_power_switch_ci' into 'master'
Feat/usb host external power switch for esp32s2(s3) CI target runners

Closes IEC-238

See merge request espressif/esp-idf!35247
2025-01-09 01:16:20 +08:00
peter.marcisovsky
5918368831 feat(usb_host): Enable DRVVBUS to control VBUS during test run
- DRVVBUS control GPIO selectable in menuconfig
    - enabled for esp32s2 and esp32s3
2025-01-07 17:41:33 +01:00
Tomas Rezucha
c97b2e6cc8 refactor(usb/phy): Start using values from usb_dwc_info in PHY driver
Add tests for PHY sanity checks
2025-01-07 10:00:48 +01:00
Tomas Rezucha
a66cecd250 refactor(usb/phy): Do not use deprecated variables in usb_phy 2025-01-07 09:10:23 +01:00
Tomas Rezucha
3132ffbcd7 feat(hal/usb): Explicitly enable clock and reset USB WRAP on init 2025-01-07 09:10:23 +01:00
peter.marcisovsky
3cef3baeba feat(usb_host): Mock USB device open/close
- CMock callbacks for USB device opening and closing
2024-12-16 16:55:37 +01:00
Daniel Mangum
7962d54c4c fix(usb_host): return ESP_ERR_NO_MEM on failed alloc in client register
Fixes issue where ESP_ERR_NO_MEM was being silently discarded after
cleaning up after a failed malloc in usb_host_client_register.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
2024-11-10 19:55:18 -05:00
Tomas Rezucha
1805efb0b2 Merge branch 'feat/dynamic_usb_hal' into 'master'
feat(hal/usb): Make USB-DWC HAL&LL configuration independent

Closes IDF-11437

See merge request espressif/esp-idf!34045
2024-10-30 18:32:32 +08:00
Roman Leonov
501e4e6c81 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
2024-10-25 16:09:25 +08:00
Tomas Rezucha
d837cae2b0 feat(hal/usb): Make USB-DWC HAL&LL configuration independent
Previously, we included symbols from soc/usb_dwc_cfg.h and configured
the HAL and LL according to it. Now we get the configuration in runtime
from USB-DWC registers.

Added missing definition for USB FS peripheral on ESP32-P4.
2024-10-24 16:54:20 +02:00
Roman Leonov
c19e2b7f8d refactor(usb_host): Removed error in enum when stalled, added hcd_dwc no more free channels 2024-10-24 16:40:55 +08:00
Tomas Rezucha
c1f5d3067f feat(hal/usb): Add USB UTMI PHY HAL
* Add a bare-bones HAL API for the USB UTMI PHY
* Split USB-DWC LL per target
2024-10-24 15:18:30 +08:00
Tomas Rezucha
b02ad37a55 feat(soc/usb): Add USB related changes to soc_caps and usb_dwc_periph
This commit changes the following:

- Add types and data structures indicating the available USB controllers
for each target.
2024-10-24 15:18:30 +08:00
Roman Leonov
4677ccee86 fix(ext_port): ESP_LOGW() -> ESP_LOGD() changed back 2024-10-17 19:44:00 +08:00
Roman Leonov
76293e3356 fix(ext_port): Moved reset recovery delay in correct place, removed delay while polling port which in reset state 2024-10-17 19:44:00 +08:00
Roman Leonov
30f199562b fix(ext_port): Added port recovery delay 2024-10-17 19:44:00 +08:00
Roman Leonov
f333131063 feat(hub): Added notification when hubs support disabled 2024-10-14 12:37:34 +02:00
Peter Marcisovsky
d19666d8e5 refactor(usb_host): Update the USB component to new critical section API 2024-10-08 17:43:55 +02:00
Roman Leonov
3d07895c8f refactor(usb_host_examples): Enabled Hub support by default 2024-10-07 10:13:10 +02:00
Roman Leonov
70f222e5d2 feat(ext_port): Added External Port driver
Closes https://github.com/espressif/esp-idf/issues/12554
2024-09-26 12:38:24 +02:00
Peter Marcisovsky
d071bb4c56 feat(usb_host): Create USB Host mock for CMock host tests 2024-09-18 15:04:03 +02:00
Roman Leonov
fac1966c9b Merge branch 'refactor/usb_host_ext_hub_cleanup' into 'master'
refactor(hub): Cleaned up dev_tree_node debug output, moved node freeing

See merge request espressif/esp-idf!33380
2024-09-12 16:01:36 +08:00
Wu Zheng Hui
6abe40e590 Merge branch 'feature/optimize_esp32p4_active_power_eco1' into 'master'
feat(system): Optimize esp32p4 active state  power consumption

Closes PM-103 and IDF-7688

See merge request espressif/esp-idf!32950
2024-09-11 23:15:29 +08:00
wuzhenghui
05e74480f5 feat(esp_system): gate some clock by default to optmize esp32p4 active power 2024-09-11 10:53:00 +08:00
Peter Marcisovsky
3362e18432 fix(usb_host): Update log level and error poropagation 2024-09-08 18:43:42 +02:00
Roman Leonov
a9d960a81f refactor(hub): Cleaned up dev_tree_node debug output, moved node freeing 2024-09-06 22:44:37 +02:00
Tomas Rezucha
19bf686d5e feat(usb/host): Enable USB Host tests on P4 2024-09-05 19:41:07 +02:00
Tomas Rezucha
3857f779cc fix(usb/host): Correctly handle unpowered port in HUB 2024-09-05 19:40:52 +02:00