
From: Alexander Sverdlin alexander.sverdlin@siemens.com
While there are happy users who successfully have been using DFU on TI AM62x [1][2], there are also others who were not so lucky up to now [3].
I felt into latter category and was wondering why I observe this:
-- U-Boot SPL 2024.04-61876f393762 (Apr 11 2024 - 09:27:15 +0000) ... Trying to boot from DFU dwc3-generic-peripheral usb@31000000: found 16 IN and 16 OUT endpoints dwc3-generic-peripheral usb@31000000: Event buf 81e0a200 dma 00000000x length -2115984896 ... dwc3-generic-peripheral usb@31000000: initializing ep0out ... dwc3-generic-peripheral usb@31000000: initializing ep15in registering UDC driver [] dwc3-generic-peripheral usb@31000000: gadget no-function data soft-connect dwc3-generic-peripheral usb@31000000: Enabling ep0out dwc3-generic-peripheral usb@31000000: Command Complete --> 0 dwc3-generic-peripheral usb@31000000: failed to enable ep0out failed to start : -110 g_dnl_register: failed!, error: -110 g_dnl_register failedSPL: failed to boot from all boot devices ### ERROR ### Please RESET the board ### --
It turned out the timeout happened in dwc3_send_gadget_ep_cmd() on DWC3_DEPCMD_SETEPCONFIG command and while the "timeout" has been increased in Linux from 500 to 1000 and later 5000, in my case it took more than 77000 1us cycles to successfully complete.
It turns out that Linux DWC3 gadget code has been improved in the meanwhile to follow DWC3 programming guide more precisely. Porting the following Linux patches solved the timeout issue in U-Boot SPL on TI AM6232.
Strictly speaking "usb: dwc3: gadget: Disable GUSB2PHYCFG.SUSPHY for End Transfer" and "usb: dwc3: gadget: properly check ep cmd" are not required to tackle the observed timeout, but it keeps the whole code block in sync with Linux v6.8.
Felipe Balbi (4): usb: dwc3: gadget: combine return points into a single one usb: dwc3: gadget: clear SUSPHY bit before ep cmds usb: dwc3: gadget: only resume USB2 PHY in <=HIGHSPEED usb: dwc3: gadget: properly check ep cmd
Thinh Nguyen (2): usb: dwc3: gadget: Check ENBLSLPM before sending ep command usb: dwc3: gadget: Disable GUSB2PHYCFG.SUSPHY for End Transfer
drivers/usb/dwc3/core.h | 2 ++ drivers/usb/dwc3/gadget.c | 47 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 3 deletions(-)
1: https://git.ti.com/cgit/ti-u-boot/ti-u-boot/tree/configs/am62x_evm_r5_usbdfu... 2: https://lore.kernel.org/all/20240112085317.1866449-1-sjoerd@collabora.com/T/ 3: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/11...