From 25571321854fe99283ed8e43f1fad60cd3868609 Mon Sep 17 00:00:00 2001 From: John Boiles Date: Fri, 9 May 2025 15:40:45 -0700 Subject: [PATCH] fix(usb/phy): Fix ability to switch back to USB/JTAG after uninstalling TinyUSB Fixes #15912. This is a revert of a change made in 005ae0554 that breaks the ability to re-initalize the USB/JTAG device after uninstalling TinyUSB. Closes https://github.com/espressif/esp-idf/issues/15912 --- components/usb/usb_phy.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/usb/usb_phy.c b/components/usb/usb_phy.c index 83d1930040..46d5a17ed0 100644 --- a/components/usb/usb_phy.c +++ b/components/usb/usb_phy.c @@ -13,6 +13,7 @@ #include "esp_private/usb_phy.h" #include "esp_private/critical_section.h" #include "soc/usb_dwc_periph.h" +#include "hal/usb_serial_jtag_hal.h" #include "hal/usb_wrap_hal.h" #include "hal/usb_utmi_hal.h" #include "esp_rom_gpio.h" @@ -347,6 +348,12 @@ esp_err_t usb_new_phy(const usb_phy_config_t *config, usb_phy_handle_t *handle_r usb_wrap_hal_phy_set_external(&phy_context->wrap_hal, (phy_target == USB_PHY_TARGET_EXT)); #endif } +#if SOC_USB_SERIAL_JTAG_SUPPORTED && USB_SERIAL_JTAG_LL_EXT_PHY_SUPPORTED + else if (config->controller == USB_PHY_CTRL_SERIAL_JTAG) { + usb_serial_jtag_hal_phy_set_external(NULL, (config->target == USB_PHY_TARGET_EXT)); + phy_context->otg_mode = USB_OTG_MODE_DEVICE; + } +#endif // For FSLS PHY that shares pads with GPIO peripheral, we must set drive capability to 3 (40mA) if (phy_target == USB_PHY_TARGET_INT) {