Commit Graph

46 Commits

Author SHA1 Message Date
Roman Leonov
19ce9ed634 refactor(test_usb_host_async): Added host_lib_task finish notification 2025-05-20 11:34:53 +02:00
Tomas Rezucha
b961f42e8b feat(usb/host): Add option to choose peripheral for USB host library
Starting with ESP32-P4 we can have targets that have more than 1 USB-OTG peripheral.
This commit adds an option to choose which peripherals will be used by USB Host lib.

Internally, we will still have only 1 Root HUB but with multiple Root ports.
2025-05-14 10:34:11 +02:00
Igor Masar
c06fa310cf Merge branch 'feat/usb-explicit-fifo-config' into 'master'
feat(usb/hal): Add HAL API to configure custom FIFO layout

Closes IDF-9042

See merge request espressif/esp-idf!38404
2025-05-13 22:28:41 +08:00
peter.marcisovsky
cd5b3877bf feat(usb_host): Move DMA capable memory to external ram on P4
- DWC-OTG internal DMA can access psram on esp32p4
    - Move DMA memory buffs to psram, to save internal ram
    - HCD tests and MSC example runs in CI with psram enabled
2025-05-13 15:37:30 +08:00
igor.masar
cb4d90186f feat(usb/hal): Add support for explicit FIFO configuration
Introduce a new HAL API `usb_dwc_hal_set_fifo_config()` that allows advanced users
to manually configure RX, Non-Periodic TX, and Periodic TX FIFO sizes. This offers
fine-grained control beyond the previous bias-based sizing approach.

The HAL function no longer returns `esp_err_t`, and internal validations are enforced
via `HAL_ASSERT()`. Responsibility for input validation has been moved to the HCD layer.

FIFO configuration must be applied before any USB pipes are created or activated.
This feature is intended for use during `usb_host_install()`.

If no custom FIFO configuration is provided (i.e., all values are zero),
the driver falls back to a bias-based default layout based on Kconfig settings
(`CONFIG_USB_HOST_HW_BUFFER_BIAS_*`). Bias resolution is done inside `hcd_port_init()`.

The `port_obj_t` structure has been extended with a `fifo_config` field, which stores
the configuration to allow re-application after a USB port reset.

Obsolete FIFO bias enums (`usb_hal_fifo_bias_t`, `hcd_port_fifo_bias_t`) and related
APIs (`hcd_port_set_fifo_bias()`) have been removed in favor of the new structure-based mechanism.

The HCD initialization and port reset flow has been updated to use the explicit
FIFO configuration.

USB Host maintainer documentation (`maintainers.md`) has been updated accordingly.
Test cases were updated to remove the usage of removed bias API and now rely on default
or custom FIFO configuration.
2025-05-09 15:03:52 +02:00
Roman Leonov
aaebc37467 Merge branch 'refactor/usb_host_ext_port_change_deps_to_ext_hub' into 'master'
refactor(ext_port): Remove dependency from the External Hub driver

Closes IDF-12562

See merge request espressif/esp-idf!37518
2025-05-02 16:30:20 +08:00
Tomas Rezucha
4b15ef706b Merge branch 'fix/usb_comprehensive_heap' into 'master'
fix(usb/host): Do not call heap_caps_get_allocated_size() in USB host driver

Closes IDFGH-15138

See merge request espressif/esp-idf!38715
2025-04-30 14:22:08 +08:00
Roman Leonov
178ac8ee0f refactor(ext_port): Removed ext_hub dependency: update test_app 2025-04-29 17:55:25 +02:00
Roman Leonov
8a6271bc32 feat(test_ext_port): Added test cases for the external port driver testing 2025-04-29 16:39:15 +08:00
Tomas Rezucha
6badd2cf25 fix(usb/host): Do not call heap_caps_get_allocated_size() in USB host driver
It causes heap corruption if heap poisoning is enabled on ESP32-P4.
It returns incorrect size on ESP32-S3.

Closes https://github.com/espressif/esp-idf/issues/15815
2025-04-29 14:50:11 +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
d0f27448ad refactor(usb_host): Made phy and hcd common
fix
2025-03-26 12:49:31 +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
Roman Leonov
7c118fd072 feat(enum): Added test application to test enum driver with mocked device 2025-02-13 11:58:57 +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
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
3d07895c8f refactor(usb_host_examples): Enabled Hub support by default 2024-10-07 10:13:10 +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
Darian Leung
cac0ef9d11 refactor(usb): Remove use of usb_phy_action() from unit tests
Currently, USB Host unit tests that require a software triggered disconnection/
reconnection rely on the 'usb_phy_action()' function.

This commit replaces those calls with 'hcd_port_command()' or
'usb_host_lib_set_root_port_power()'.

Note: Also removed 'test_usb_common.h/c' as it is no longer necessary are the
function call replacements.
2024-09-05 12:27:27 +02:00
Tomas Rezucha
660319ecaf fix(usb/host): Use new cache aligned DMA alloc functions 2024-08-20 08:13:32 +02:00
Peter Marcisovsky
ddc3c2b78b refactor(usb_host): Update USB Host multiconfig public API
- previous usb_host_get_config_desc_free()
    - updated usb_host_free_config_desc()
2024-07-16 11:32:22 +02:00
Roman Leonov
97d30e7c48 fix(usb_dwc_hal): Enabled precise detection of VBUS 2024-07-12 10:51:31 +02:00
Peter Marcisovsky
6cabb68d12 feat(usb/host): multiconfiguration support
- usb host reads device's configuration on request
    - a control transfer is sent
    - memory is allocated for a new descriptor
    - user must manually free the memory
2024-06-19 09:40:57 +02:00
Darian Leung
4954884527 fix(usb): Make string descriptor checks in unit tests optional
Checking for an exact match for product or serial and string descriptors can
lead to test failures if the USB devices connected to the runner is changed. This
commit adds some kconfig options to make the string descriptor checks optional,
with the product and serial string checks being disabled by default.
2024-05-30 19:25:18 +08:00
Darian Leung
6a3bb3294d refactor(usb): Split test device descriptors from mock class files
Previously, descriptors of the test devices were stored direclty in the mock
device files (e.g., "mock_[hid|msc].[h|c]"). This commit splits out the device
descriptors to separate files (e.g., "dev_[hid|msc].c") along with getter
functions.

Users that want to run the tests locally on a different device simply need to
update the "dev_[hid|msc].c" file for their device.
2024-05-24 17:43:40 +08:00
Darian Leung
94e3b83bc0 refactor(usb): Rename mock class files
- Rename "test_usb_mock_..." class files to "mock_..."
- Fixed some codespell issues
- Fixed comment spacing
2024-05-23 17:47:24 +08:00
gaoxu
40f38bea6f feat(dma): refactor dma calloc function 2024-04-02 14:30:14 +08:00
Armando
f0518b3c16 feat(dma): advanced dma malloc helper 2024-04-02 14:30:14 +08:00
Tomas Rezucha
72f00d7c6d feat(usb/host): Update ISOC scheduler for HS endpoints
USB-OTG uses 'sched_info' field of HCTSIZ register to schedule transactions
in USB microframes.
2024-03-01 18:05:40 +01:00
Peter Marcisovsky
51d6296fde ci: Added esp32p4 usb tests to CI:
- added new test for usb_host_lib example for all targets
    - CI USB host test are run on esp32p4
    - CI USB device tests temporarily disabled until usb_device runner is fixed
    - hcd and usb_host tests which do not require PHY are run on esp32p4
2024-02-29 10:35:09 +01:00
Erhan Kurubas
f4acf0b378 refactor(espcoredump): format coredump component with astyle 2024-02-19 21:57:28 +01:00
Tomas Rezucha
f13ae0fc08 feat(esp32p4): Add USB-OTG support for ESP32-P4 2024-01-30 15:07:11 +01:00
Fu Hanxi
37a4c2ea01 Merge branch 'ci/nested_dynamic_pipeline' into 'master'
CI: Dynamic Pipeline!!!

Closes IDFCI-1211, IDFCI-1729, IDF-8500, IDF-8456, IDFCI-1828, RDT-610, and RDT-615

See merge request espressif/esp-idf!26662
2024-01-11 13:08:28 +08:00
Fu Hanxi
d44f236f7b ci(usb): migrate from .gitlab/ci/rules.yml to .build-test-rules.yml 2024-01-10 15:29:44 +01:00
Tomas Rezucha
ec004c788b fix(usb/host): Sync cache for memory shared by CPU and USB-OTG
Transfer descriptor list, frame list and transfer data buffers
are accessed by both CPU and USB-OTG. Sync CPU cache between the accesses.
2024-01-10 15:23:24 +01:00
Darian Leung
d7b83bfd3b refactor(usb/host): reformat code with astyle_py 2023-12-15 04:44:02 +08:00
Tomas Rezucha
c2660ce7c6 fix(usb/host): Correctly parse MPS fields in HighSpeed EP descriptors
Bits [11,12] in HighSpeed periodic endpoints specify
the number of additional transaction opportunities per microframe
2023-12-12 21:10:37 +01:00
Chen Yudong
2e11919f70 fix(ci): change build-test-rules files folder 2023-09-20 19:17:06 +08:00
Darian Leung
287bdc5e61 fix(test_apps): Trim builds of component test apps
Some component test apps do not use the "set(COMPONENTS main)" command in their
project level "CMakeLists.txt", thus leading to their builds pulling in all
ESP-IDF components.

This commit trims the build of multiple component test apps:

- Add "set(COMPONENTS main ...)" to project level "CMakeLists.txt"
- Add missing "PRIV_REQUIRES" in some "main" component "CMakeLists.txt"

Also removed repeated configuraiton options in legacy_i2c_driver/sdkconfig.ci.defaults
as they are already specified in legacy_i2c_driver/sdkconfig.defaults
2023-09-18 17:16:37 +08:00
Tomas Rezucha
f2f6278ba6 usb_host: Use up-to-date syntax in pytest 2023-04-19 11:06:25 +02:00
Tomas Rezucha
645592e157 usb: Refactor USB Host tests
* USB tests migrated to pytest
* Error messages improved
* Configurable for different mock devices
2022-11-30 18:12:54 +01:00