The esp32-s2/s3 usb phy does not appear to handle the ID and V
BUS pins like you'd normally expect from an integrated phy. It seems that most of the control signals of the usb core's phy interface are instead just hooked up to the gpio matrix:
Code: Select all
~/.../esp-idf/components$ grep -P 'USB_(OTG|SRP)_' soc/esp32s3/include/soc/gpio_sig_map.h
#define USB_OTG_IDDIG_IN_IDX 58
#define USB_OTG_AVALID_IN_IDX 59
#define USB_SRP_BVALID_IN_IDX 60
#define USB_OTG_IDPULLUP_IDX 60
#define USB_OTG_VBUSVALID_IN_IDX 61
#define USB_OTG_DPPULLDOWN_IDX 61
#define USB_SRP_SESSEND_IN_IDX 62
#define USB_OTG_DMPULLDOWN_IDX 62
#define USB_OTG_DRVVBUS_IDX 63
#define USB_SRP_CHRGVBUS_IDX 64
#define USB_SRP_DISCHRGVBUS_IDX 65
(See e.g. the UTMI+ specification for a description of these signals.)
The outputs are simply ignored and the inputs get muxed to constant-0 or constant-1 by software, which also manually controls the D+/D− pullups via phy registers, see:
- esp-idf/components/usb/usb_phy.c
- esp-idf/components/hal/usb_phy_hal.c
- esp-idf/components/hal/esp32s3/include/hal/usb_phy_ll.h
Note that the lack of V
BUS monitoring means that any esp32-s2/s3 based usb device that uses this code and isn't powered solely from V
BUS (but e.g. battery or external supply) will be in violation of the USB specification, which requires devices to refrain from pulling up D+ or D− unless V
BUS is present:
- "The voltage source on the pull-up resistor must be derived from or controlled by the power supplied on the USB cable such that when VBUS is removed, the pull-up resistor does not supply current on the data line to which it is attached."
—USB 2.0 Specification, section 7.1.5
- "No device shall supply (source) current on VBUS at its upstream facing port at any time. From VBUS on its upstream facing port, a device may only draw (sink) current. They may not provide power to the pull-up resistor on D+/D− unless VBUS is present. When VBUS is removed, the device must remove power from the D+/D− pull-up resistor within 10 seconds."
—USB 2.0 Specification, section 7.2.1
(This to ensure you're not sourcing current into the host via D+/D− pullups when the host is powered off, which could potentially be harmful to the host.)