Commit Graph

90 Commits

Author SHA1 Message Date
morris
344db9a7e7 Merge branch 'feature/usb_hs_periodic_scheduler_v5.2' into 'release/v5.2'
feat(usb/host): Update ISOC scheduler for HS endpoints (backport 5.2)

See merge request espressif/esp-idf!29399
2024-03-07 10:03:20 +08:00
Tomas Rezucha
e3f811b5b8 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-04 10:00:35 +01:00
Darian Leung
50282f1e7a
fix(usb): Fix bug where usbh_process() misses an event
This commit fixes a bug where if multiple concurrent USBH API calls trigger
multiple events on the same device, some events will be lost. As a result,
those lost events don't get processed by the subsequent usbh_process() call.
2024-02-29 16:02:30 +08:00
Peter Marcisovsky
d786f187e9 feat(us/host): set device cfg during enumeration
- user callback funciton to set device configuration
      as a part of usb_host_install
    - callback provides device descriptor of a device being enumerated
    - user can set which cfg descriptor the USB device will be set with
    - user can filter device enumeration
    - Kconfig menu to enable callback function
    - usb_host_lib example demonstration
2024-02-21 12:34:04 +01:00
Darian Leung
b07a43e630
refactor(soc): Rename usb_otg_periph to usb_dwc_periph
- Renamed usb_otg_periph.h/c to usb_dwc_periph.h/c to match naming convention
of other DWC OTG related files
- Added compatibility header for usb_otg_periph.h
2024-02-19 15:45:04 +08:00
Darian Leung
2f6e45c79b
refactor(usb): Deprecate CONFIG_USB_OTG_SUPPORTED, use SOC_USB_OTG_SUPPORTED instead
Previously, USB build dependencies used the CONFIG_USB_OTG_SUPPORTED. However,
they could depend on `soc_caps.h` instead.
2024-02-19 15:45:02 +08:00
Darian Leung
f0219b73f9
refactor(hal/usb): Rename usb_fsls_phy API to match header/source names
Note: Also fixed some formatting issues in usb_wrap_struct.h
2024-02-19 15:45:02 +08:00
Darian Leung
f2ede42191
refactor(hal/usb): Rename usb_phy files to usb_fsls_phy
This commit renames USB PHY related HAL files from "usb_phy_xxx" to
"usb_fsls_phy_xxx" since they are only designed to support Full-Speed/Low-Speed
Serial USB PHYs. This renmaing is done to accommodate future USB PHYs that use
other PHY interfaces (e.g., UTMI, ULPI etc).
2024-02-19 15:45:01 +08:00
Darian Leung
3964fb2d04
refactor(usb/host): reformat code with astyle_py 2024-02-19 15:45:00 +08:00
Tomas Rezucha
1e2c271bd0
fix(usb/host): Correctly parse bInterval field in HighSpeed EP descriptors
For LS and FS interrupt endpoint: interval = bInterval
For isochronous and HS interrupt endpoint: interval = 2^(bInterval-1)
2024-02-19 15:44:59 +08:00
Tomas Rezucha
0ce4aa114e
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
2024-02-19 15:44:59 +08:00
Darian Leung
b7c3f01ac8
change(usb/host): Remove some handler function event flags
This commit removes internal event flags in the USB Host Library event handling
functions (i.e., usb_host_lib_handle_events() and usb_host_client_handle_events()).

Previously, these flags were added to reduce the number of times semaphores
were given. However, these flags were removed as the performance gain is
negligible and made the logic more complicated.

For usb_host_client_handle_events(), the following flags were removed:

- Remove 'events_pending' flag. The semaphore is now always given
- Remove 'blocked' flag. The 'handling_events' flag is already sufficient
- Critical sections are now shortened due to simplication of semaphore usage.

For usb_host_lib_handle_events(), the following flags were removed:

- Remove 'process_pending' flag. The semaphore is now always given
- Renamed 'blocked' flag to 'handling_events'
2024-02-19 06:57:31 +08:00
Darian Leung
d9de61cbad
change(usb/host): Remove data buffer headers from URBs
This commit removes the ability to reserve a header in the data buffer of an
allocated URB. The header was required for a now defunct implementation of a
synchronous USB Host library API. Thus, headers are no longer required in
URB data buffers.
2024-02-19 06:57:30 +08:00
Tomas Rezucha
9b40d39120 refactor(usb/host): Move FIFO size configuration to HAL layer
The logic of calculating FIFO sizes is DWC OTG specific.
We move it to the HAL layer to provide better abstraction in the HDC layer.
2023-12-21 10:34:56 +01:00
Tomas Rezucha
71cd4df75a refactor(usb/host): Make private hal types USB_DWC specific 2023-12-21 10:34:46 +01:00
Tomas Rezucha
42277ac868 feat(usb/host): Add High Speed enumeration types 2023-12-21 10:33:49 +01:00
Roman Leonov
bc2ef597a4 fix(usb/host): remove bInterval verification during pipe opening for INTR and ISOC EPs 2023-12-05 16:44:53 +01:00
Tomas Rezucha
4cf3acb594 fix(usb/host): Do not abort on string descriptor overflow
Some devices return full LANGID table, even if short LANGID table was requested.
No memory overflow occurs, because we have allocated enough memory for transfers to the
default pipe. So we can ignore the error and continue with string desc fetching.
2023-12-05 16:44:53 +01:00
Darian Leung
af4991fb39 refactor(hal/usb_dwc): Add DWC OTG configuration values
This commit adds a subset of the DWC OTG configuration values to the
'usb_dwc_ll.h' file. Only relevant configuration values have been added.

Some DWC OTG releated constants have also been moved from 'usb_dwc_hal.h'
to 'usb_dwc_ll.h' and renamed.
2023-12-05 16:44:53 +01:00
wuzhenghui
b7f1aa5292 fix(esp_hw_support): fix lightsleep current leakage on usb-phy controlled pad 2023-11-16 17:18:43 +08:00
Jakob Hasse
548022fbe6 refactor(linux): excluded all non-Linux components from build
* All components which won't build (yet) on Linux are excluded.
  This enables switching to Linux in an application without
  explicitly setting COMPONENTS to main in the main
  CMakeLists.txt.
* ESP Timer provides headers for Linux now
* automatically disabling LWIP in Kconfig if it is not available

doc(linux): brought section
  "Component Linux/Mock Support Overview" up to date
2023-10-16 17:06:54 +08: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
Roman Leonov
c29db70510 bugfix(usb/host): Fix transfer direction determination during argument checking for regular EP transfer 2023-09-13 21:55:34 +02:00
Roman Leonov
e297470e62 Merge branch 'bugfix/usb/host/urb_compliance_verification_add' into 'master'
feature(usb/host) added URB check args and transfer check compliance for regular EP transfer submit

See merge request espressif/esp-idf!24106
2023-08-03 16:20:49 +08:00
Darian Leung
a1ed398481 usb_host: Fix coverity issues with hcd_install()
- Use single "err_ret" variable for returning errors
- Simplify bail out procedure by using more labels
2023-06-21 17:50:20 +08:00
morris
8885d20482 usbh: fix invalid assert on desc_status 2023-06-19 10:59:46 +08:00
Roman Leonov
093bb5cab6 usb_host: added URB check args and transfer check compliance for regular EP transfer submit 2023-06-07 12:08:51 +02:00
Darian Leung
cbed197e10 usb_host: Run formatting script 2023-05-29 17:30:41 +08:00
Darian Leung
1ffbbf5aef usb_host: Fix spelling errors 2023-05-29 17:30:41 +08:00
Darian Leung
bab1c61a4c usb_host: Refactor USBH and USB Host Library calls to HCD
This commit refactors the USBH and the USB Host Library in the following ways:

- USBH now presents an abstraction of an endpoint (via usbh_ep_handle_t)
    - Added separate functions to enqueue/dequeue URBs to a particular endpoint
    - USB Host Library no longer calls HCD API directly. Calls USBH endpoint API
      instead.
- Renamed "notif_cb" to "proc_req_cb" (Processing Request Callback)
    - This is to avoid confusion with FreerTOS task notifications and Host
      Library client event notifications.
    - The processing functions of each layer (i.e., "xxx_process()") request
      calls via the "proc_req_cb"
    - The main handling function (i.e., usb_host_lib_handle_events()) is
      responsible for calling the required "xxx_process()" of each layer
2023-05-29 17:30:41 +08:00
Roman Leonov
1be6977a9d usb_host: better debugging information during hcd_pipe_alloc() when usb_host_interface_claim() is being fulfiled. 2023-04-24 08:37:57 +02:00
Tomas Rezucha
f2f6278ba6 usb_host: Use up-to-date syntax in pytest 2023-04-19 11:06:25 +02:00
Darian Leung
525de5bd21 usb_host: Update docs and comments regarding first configuration enumeration
This commit updates some comments and documentation regarding changes made in
PR https://github.com/espressif/esp-idf/pull/11113.
2023-04-17 17:06:54 +08:00
Jason
9d1c8f4f18 Fix usb enumeration stage error for some device 2023-04-03 21:03:07 +08:00
Roman Leonov
be899f6653 usb_host: add recovering interval after SetAddress(). Possibility to change constant delay value via menuconfig.
Closes https://github.com/espressif/esp-idf/issues/10444
Closes https://github.com/espressif/esp-idf/issues/10718
2023-03-09 08:11:05 +01:00
Tomas Rezucha
31ff3bc0c2 usb_host: Fix interface descriptor parsing
Previously the USB host driver did not accept interface number greater or equal bNumInterfaces, even though these are valid interface numbers
2023-02-10 15:49:11 +01:00
Saurabh Kumar Bansal
7010349a9a usb_host: Hub driver skips fetching string descriptors if their index is 0
When a USB does not support a particular string dsecriptor (e.g.,
manufacturer, product, and serial number), the string descriptors corresponding
index will be set to 0 in the device descriptor (e.g., iManufacturer, iProduct,
iString).

Previously, the Hub driver would always attempt to fetch the all three string
descriptors, thus leading an error in CHECK_SHORT_SER_STR_DESC if the device
did not support the descriptor.

This commit fixes the Hub drvier by skipping the enumeration stages of a
particular descriptor if its index is 0 (i.e., not supported by the device).
2023-02-08 23:12:54 +05:30
Darian Leung
6ae151db8c usb_host: Fix error when fetching LANGID table
USB devices may support string descriptors in multiple languages. The supported
languages are stored in a LANGID table, which itself is a string descriptor at
index 0.

When fetching the LANGID table itself, the USB 2.0 specification does not
specify what LANGID to use, thus the Hub driver would use the default LANGID
"ENUM_LANGID". However, this would cause some devices to stall.

This commit fixes the issue by always requesting the LANGID table itself using
a LANGID of 0.
2023-02-08 22:36:01 +08:00
Darian Leung
c2bc34ee84 usb: Fix incorrect bmRequestType direction flag in USB Host Library
usb_host_transfer_submit_control() uses the incorrect bmRequestType direction
flag. Therefore, when doing a transfer check, all transfers were mistakenly
treated as OUT transfers (only affects transfer check and not actual transfer).
2022-12-06 18:10:45 +08:00
Tomas Rezucha
7ae5705977 Merge branch 'feature/usb_v5_update' into 'master'
usb: Run usb_host tests in CI

See merge request espressif/esp-idf!19468
2022-12-01 15:29:01 +08:00
Tomas Rezucha
a0dacf826f usb: Don't access uninit pointer if usbh_install fails 2022-11-30 18:48:31 +00: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
Omar Chebib
cd21058097 C/Cxx: unify static assertions with the macro ESP_STATIC_ASSERT
Closes https://github.com/espressif/esp-idf/issues/9938
2022-11-21 16:18:08 +08:00
Darian Leung
4e84212077 usb_host: Test host library inflight transfer resubmission check
This commit updates the USB Host Library unit tests to test that resubmitting
an inflight transfer will return an error.
2022-10-31 13:56:59 +08:00
Darian Leung
e17e066828 usb_host: Add check to prevent submitting already inflight transfers
This commit adds a simple flag/check in the USB Host Library that prevents
users from submitting a transfer that is already inflight.

- A transfer is considered inflight as soon as it is submitted by calling
usb_host_transfer_submit() or usb_host_transfer_submit_control()
- An inflight transfer remains inflight up until right before its callback
is called by one of the USB Host Library handler functions.

Closes https://github.com/espressif/esp-idf/issues/8748
2022-10-31 13:56:59 +08:00
Tomas Rezucha
27078ac34c usb_host: Fixed incorrect opening devices from multiple clients
1. During USBH device open both queues (idle and pending) must be checked.
2. Don't overwrite already allocated endpoints
2022-10-31 13:56:44 +08:00
Tomas Rezucha
dc705312a3 usb: Allow settings of all signals in usb_phy
Until now, only usb_phy signals for external PHY were defined.
This is now extended with all OTG signals.
2022-10-18 09:18:29 +02:00
Darian Leung
d333833f59 usb_host: Rename struct/ll/hal symbols to use "usb_dwc" prefix
Following the file renaming to use the "usb_dwc" prefix, this commit
updates the symbol names of those files to use the "usb_dwc" as well.

Some LL functions were also renamed so that the register name is
mentioned.
2022-09-16 16:45:26 +08:00
Darian Leung
d8d4e3acb0 usb_host: Rename struct/ll/hal files to use "usb_dwc" prefix
This commit updates the DWC_OTG based struct/ll/hal file names to
use the prefix "usb_dwc". This naming scheme reduces ambiguity if
another USB controller implementation is added.

As a result, "hcd.c" has been renamed to "hcd_dwc.c"
2022-09-16 16:45:26 +08:00