Wykres commitów

51 Commity (b9cf89ac23a19a7da726007c6a63682779695658)

Autor SHA1 Wiadomość Data
wuzhenghui 236883728d
fix(esp_hw_support): fix lightsleep current leakage on usb-phy controlled pad 2023-11-20 11:25:28 +08:00
morris c4cb13cfe7 usbh: fix invalid assert on desc_status 2023-06-20 10:47:06 +08:00
Jiang Jiang Jian e6df66522a Merge branch 'feature/usb_host_interface_claim_debug_info_v4.4' into 'release/v4.4'
USB Host: better debugging information during usb_host_interface_claim() (backport v4.4)

See merge request espressif/esp-idf!23445
2023-06-09 12:02:59 +08:00
Roman Leonov 8a311cf8ad usb_host: better debugging information during hcd_pipe_alloc() when usb_host_interface_claim() is being fulfiled. 2023-04-25 12:52:45 +02:00
Darian Leung fd2d4a83e2 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-21 12:53:27 +08:00
Jason 8bebfaa6ee Fix usb enumeration stage error for some device 2023-04-21 12:53:27 +08:00
Roman Leonov 0f47fad650 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-10 07:07:38 +01:00
Saurabh Kumar Bansal f90ccf9613 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-13 18:15:36 +05:30
Darian Leung fd663b4ab1 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-13 18:15:16 +05:30
Tomas Rezucha 74f479151b 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-13 18:02:35 +05:30
Darian Leung 3eef9e7598 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-13 22:28:02 +08:00
Tomas Rezucha 5842aca69c usb: Refactor USB Host tests
* Error messages improved
* Configurable for different mock devices

Note: Backport 645592e157 to v4.4 without
migrating to pytest.
2022-12-13 22:26:47 +08:00
Darian Leung 7295933f5f 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-12-13 21:36:00 +08:00
Darian Leung c06346da35 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-12-13 21:36:00 +08:00
Darian Leung 9f3c0b1e38 usb_host: Fix incorrect memset() usage in HCD
This commit fixes incorrect usage of memset() in the HCD's various
_buffer_parse_...() functions. The memset was not clearing the qtd lists, and
were simply setting the first qtd to a non zero value (i.e., the length of
the QTD list).

However, no bug occurred as the subsequent _buffer_fill_...() functions would
overwrite the QTD list anyways.
2022-12-13 16:57:56 +08:00
Ivan Grokhotkov a82a530387 Merge branch 'staging/esp_static_assert_v4.4' into 'release/v4.4'
C/Cxx: unify static assertions with the macro ESP_STATIC_ASSERT  (v4.4)

See merge request espressif/esp-idf!21439
2022-12-07 16:58:01 +08:00
Omar Chebib 049d21bb12 C/Cxx: unify static assertions with the macro ESP_STATIC_ASSERT
Closes https://github.com/espressif/esp-idf/issues/9938
2022-12-05 18:16:08 +08:00
Tomas Rezucha 2c89caab9b usb: Don't access uninit pointer if usbh_install fails 2022-12-01 08:37:01 +01:00
Darian Leung 0d1bc3b2b6 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-11-07 13:52:05 +08:00
Darian Leung 1f5dc0f5a1 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-11-07 13:50:59 +08:00
Tomas Rezucha 87c415b11a 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-11-07 13:50:33 +08:00
Marius Vikhammer 90e58c3721 docs: fix all doxygen warnings
Doxygen warnings would previously not result in a failed pipeline.
Fixed this as well as all current warnings.
2022-07-05 11:14:40 +08:00
Nicholas Palmer cca9f93067 usbh_print_intf_desc prints wrong value for tbInterfaceClass (IDFGH-9000) 2022-05-24 14:28:54 +02:00
Martin Valik e898e4b2f5 Bugfix: make wTotalLength uint16_t to avoid truncation 2022-02-18 15:51:05 +08:00
Darian Leung c46b74191e usb: Add USB Host Library documentation
This commit adds the USB Host Library documentation and fixes some nitpicks
in the Host Stack types.

Closes https://github.com/espressif/esp-idf/issues/6408
2022-02-18 15:51:05 +08:00
Darian Leung ebd058c8c9 usb: Update USB Host Library
This commit updates the USB Host Library as follows:

- usb_helpers.h
    - Removed dependency on USB Host Library API
    - Added function to print string descriptors
- usbh
    - Fixed bug where an interface/endpoint could be claimed/allocated multiple times
    - Removed redundant device ref_count change
- Added unit test for USB Host Library API usage
2022-02-18 15:51:05 +08:00
Darian Leung 50bbdbc1de usb: Hub Driver and USBH recover port automatically after disconnection
This commit updates the Hub Driver and USBH as follows:
- Updated communication mechanism between Hub Driver and USBH
    - USBH notifies the Hub Driver via Hub request callback (usbh_hub_req_cb_t)
    - Hub Driver notifies the USBH via usbh_hub_pass_event()
- Hub Driver now defers all event handling to hub_process.
- Hub Driver and USBH will now automatically recover the port after a disconnected
    device has been closed.
- Fixed incorrect assert in usbh_dev_close()
2022-02-18 15:51:05 +08:00
Darian Leung ea6de613bf usb: Hub Driver Update and Refactor
Hub Driver is refactored as follows:

This commit update and refactors the Hub Driver as follows:

- Refactored enumeration state machine and stage functions
    - Enumeration stage is now incremented
    - Combined transfer stages of enumeration into common functions
- Comments updated
- Fixed usbh_hal_disable_debounce_lock() that would cause root_port_handle_events()
    to fail the HCD_PORT_CMD_RESET call because the previous port connection interrupt
    was not cleared.

The following features were added to the Hub Driver

- Enumeration config descriptor is now fetched in two separate stages
    - Header is fetched first to determine the wTotalLength of the descriptor
    - Fetching the full descriptor will request exactly wTotalLength bytes
    - This works around some non-compliant devices that will babble/return zero
        when requesting a length > wTotalLength
    - Closes https://github.com/espressif/esp-idf/issues/7799
- Enumeration now stores string descriptors
    - The Manufacturer, Product, and Serial Number string descriptors are
        now read and stored during enumeration
    - String descriptors are now part of usb_device_info_t
- Added unit test to test enumeration
2022-02-18 15:51:05 +08:00
Darian Leung 7f09fe1b23 usb: USB Host stack uses USB PHY driver
This commit updates the USB Host stack to use the USB PHY driver. The
USB PHY and the OTG Controller should now both be setup/deleted using
usb_new_phy() and usb_del_phy() respectively.

- The hcd_install() now expects the USB PHY and OTG Contorller to be
    already setup before it is called
- usb_host_install() now has an option to skip calling usb_del_phy() if
    the user wants to setup their own USB PHY (e.g., in the case of using
    and external PHY).
- CDC-ACM and MSC examples/test updated to use internal PHY

Closes https://github.com/espressif/esp-idf/issues/8061
2022-02-18 15:51:05 +08:00
Darian Leung b3b8ed79c8 usb: HCD multiple fixes
This commit fixes the following bugs in the HCD

- HCD control pipes fill incorrect transfer size

_buffer_fill_ctrl() would fill the transfer descriptors length with
wLength instead of transfer->num_bytes. Therefore, the remaining length
would be incorrect when a control transfer requests more bytes than are
available.

- Fix USB_TRANSFER_FLAG_ZERO_PACK behavior

The previous behavior of USB_TRANSFER_FLAG_ZERO_PACK was incorrect, and did not
support interrupt pipes. A zero length packet can now be added to Bulk/Interrupt
OUT transfers where the length is a multiple of the endpoint's MPS.

- Fixed HCD port suspend and resume test case

Halting a control pipe mid control transfer can lead some test devices to get stuck
2022-02-18 15:51:05 +08:00
Darian Leung 8888179439 usb: Tidy up usbh
- Remove enum_todo_flags from usbh
- USBH move config_desc to constant fields
2022-02-18 15:51:05 +08:00
Martin Valik 204aa05d0b USB: added MSC Host Driver with VFS support
Closes https://github.com/espressif/esp-idf/issues/6401
2021-12-23 18:30:24 +01:00
Tomas Rezucha e04eae6659 usb: Add USB host CDC-ACM class driver 2021-12-10 10:04:16 +01:00
Darian Leung 1af36a5b9d usb: Change API and refactor tests
This commit updates the USB Host Library API in the following wasy:
- usb_host_client_handle_t and usb_device_handle_t made into struct pointers
  to generate compiler warnings about conflicting handle types
- usb_host_client_config_t changed to future proof API for Synchronous Clients
- Added usb_host_lib_unblock()
- Added usb_host_device_addr_list_fill()
- Return of usb_host_device_free_all() updated to indicate whether there
  are still devices yet to be freed.
- Blockg APIs are now marked explicitly
- Fixed a bug in usb_host_transfer_submit_control() when checking the bEndpointAddress
  of a control transfer.

Tests are also refactored to move some common macros into shared headers

Closes https://github.com/espressif/esp-idf/issues/7786
2021-11-11 16:26:56 +08:00
Darian Leung 891c979c64 usb: Add USB Host Library sudden disconnect tests 2021-11-11 16:26:35 +08:00
Darian Leung 0a948594cb usb: Fix USBH handling of disconnections
This commit fixes how the USBH handling of a sudden device disconnection,
more specifically handling of device gone.
- Previously the USBH would only halt, flush, and dequeue the device's
default EP, then send a device gone event to the Host Library layer.
- Now the USBH will also halt and flush all non-default EPs, allowing
all of the URBs to be dequeud.
- Some internal object members are now protected by a mutex instead of
a spinlock.

Closes https://github.com/espressif/esp-idf/issues/7505
2021-11-11 16:26:09 +08:00
Darian Leung de6bf09f40 usb: Fix how the HCD handles sudden disconnection
This commit fixes how the USB Host HCD handles sudden disconnections.

Bugs:
- HW channels remain active when the port suddenly disconnects, and
previously the channel would be disabled by setting the disabled bit,
then waiting for a disabled interrupt. However, ISOC channels do not
generate the disabled interrupt when the port is invalid, thus leading
to tasks getting indefinitely blocked in hcd_pipe_command().

Fix:
On a sudden disconnection, forcibly treat all channels as halted even
if their HCCHAR.ChEna bit is still set. We do a soft reset after a port
error anyways, so the channels will eventually be reset.

Closes https://github.com/espressif/esp-idf/issues/7505
2021-11-11 16:25:01 +08:00
songruojing 1fcd639224 usb: Add usb_phy driver to support operations on USB PHY 2021-09-13 12:39:56 +08:00
Darian Leung 963836f491 Add USB Host Library API docs
- This commit adds the API documentation for the USB Host Library.
- Warnings about the beta API are also added.
- usb_host_misc.h renamed to usb_helpers.h
2021-09-02 18:40:24 +08:00
Darian Leung accbaee57c Add USB Host Library
This commit adds the preliminary version of the USB Host Library. This commit contains:

- USBH (USB Host Driver)
- Hub Driver that only supports a single device and device enumeration
- USB Host Library (asychronous API)
- Test cases for USB Host Library asychronous API

The following changes were made to the existing HCD:
- Removed HCD_PIPE_STATE_INVALID. Pipes are no longer invalidated
- Changed pipe commands to halt, flush, and clear. Pipes need to be manually
  halted, flush, and cleared.
- Halting and flushing a pipe will execute the pipe callback if it causes a
  HCD_PIPE_EVENT_URB_DONE event
2021-08-24 23:28:00 +08:00
morris 81448dcae8 tiny_usb: rename Kconfig name
1. Renamed Kconfig file of tinyusb (distinguish tinyusb stack from usb
   peripheral)
2. bugfix/typofix/doc update of tinyusb
2021-07-22 10:43:10 +08:00
Renz Bagaporo 7c22cccb9c esp32: cleanup build script 2021-07-16 20:14:27 +08:00
Darian Leung d37451f2c7 USB HCD: Add pipe persistence feature
This commit adds a pipe persistence feature allowing HCD pipes
to survive a port reset.
2021-06-29 21:09:27 +08:00
Darian Leung b901cbd273 USB: Make unit test mock classes common
This commit moves the mock classes used for HCD unit tests into
a common header so that other layers of the USB Host stack can
also utilzie them for their own unit tests.
2021-06-28 15:02:58 +08:00
Darian Leung 5f9692ae97 HCD: Fix multiple bugs
This commit fixes the following bugs with the HCD and USB Host HAL

- Make the setting to periodic frame list and scheduling to occur after
  a reset command
- All port errors states should put the port into the HCD_PORT_STATE_RECOVERY
  state.
- Fixed incorrect return type of hcd_port_command() function
2021-06-15 18:52:56 +08:00
Darian Leung 18f9dabce1 USB: Change IRP to URBs
This commit changes the IRP (I/O Request Packet) structure to
the URB (USB Request Block) in order to represent USB transfers
in the host stack. The new URB strcuture:

- Add extra safety with const fields
- Allows each layer of the stack to add their own overhead variables

The HCD layer API and tests have been updated to use this new URB structure
2021-06-09 22:09:46 +08:00
Alex Lisitsyn 46020fe13a usb/hal/soc: initial copy of usbh support from esp32s2
copy required usbh driver files from esp32s2
check usb host functionality using unit tests on esp32s3
2021-06-02 17:57:50 +08:00
Darian Leung 7f42104893 HCD: Add support for interrupt and isochronous pipes
This commit adds support for interrupt and isochronous pipes to the HCD:
- HCD now internally uses double buffering
- Added test cases for interrupt and isochronous transfers
- Reorganized test cases for each transfer type
- Updated API comments and maintainer's notes

Some minor bugs were also fixed
2021-05-26 22:55:12 +08:00
Darian Leung 738af3fd38 USB HCD uses IRPs directly for transfer
This commit updates the HCD so that transfer requests are no longer used.
The USB IRP object is updated so that the it can be directly passed to the HCD
to start a transfer. HCD API, tests, and documentation updated accordingly.
2021-04-25 21:52:07 +08:00
Darian Leung 2906a25988 Separate USB HAL and common USB types
This commit separates out the common USB types used throughout most of the stack into its
own header file inside the USB component. The types used in the USB HAL are now exclusive
to the HAL.
2021-04-22 19:24:48 +08:00