2024-02-19 08:19 AM
Hello,
I'm kind of stuck with my STM32MP157C custom board. In general, everything works fine except for the USB. I'm using the new Ecosystem 5 and using the USB OTG with the NCM Ethernet gadget. My USB has no ID pin wired and is in peripheral mode all the time.
When the system has booted and I connect my device via USB to the PC, I get the following output, and the Ethernet connection works fine:
dwc2 49000000.usb-otg: new device is high-speed
[ 96.736784] dwc2 49000000.usb-otg: new address 42
[ 97.115268] IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready
When I disconnect the device, I get no output at all, and also none when I reconnect. The connection then does not work in any way until I reboot. I think the system is not even recognizing the connection loss. But I don't know why. I use the script provided by ST (stm32_usbotg_eth_config.sh) for setting up the gadget, and I have tried all device tree configurations I found for STM32MP1 by now. I will attach mine below.
When I'm trying to stop the gadget manually, I get the following output:
sudo /sbin/stm32_usbotg_eth_config.sh stop
Stop usb gadget
[ 171.527296] dwc2 49000000.usb-otg: dwc2_hsotg_ep_stop_xfr: timeout GINTSTS.GOUTNAKEFF
[ 171.534034] dwc2 49000000.usb-otg: dwc2_hsotg_ep_stop_xfr: timeout DOEPCTL.EPDisable
[ 171.755671] dwc2 49000000.usb-otg: dwc2_hsotg_ep_stop_xfr: timeout GINTSTS.GOUTNAKEFF
[ 171.762413] dwc2 49000000.usb-otg: dwc2_hsotg_ep_stop_xfr: timeout DOEPCTL.EPDisable
[ 171.771005] dwc2 49000000.usb-otg: dwc2_hsotg_ep_stop_xfr: timeout GINTSTS.GOUTNAKEFF
[ 171.778243] dwc2 49000000.usb-otg: dwc2_hsotg_ep_stop_xfr: timeout DOEPCTL.EPDisable
And when I try starting again, the system just crashes.
I would be very grateful for help.
Best regards,
Julius
2024-02-23 09:37 AM - edited 2024-02-23 09:53 AM
Hey @JSala.3 , I got into a similar situation recently. I am sharing some of my observations in case you find them helpful.
In my configuration stopping the gadget after you have connected and disconnected a peripheral will always cause timeouts on dwc2 driver. It seems that the driver is trying to set the Global OUT NAK but since the endpoint is not present it fails. This is consistent with the following behaviour on my configuration:
Stoping the gadget after disconnecting the usb results in
dwc2_hsotg_ep_stop_xfr: timeout GINTSTS.GOUTNAKEFF
Stoping the gadget while usb is connected works as intended.
Although I am sure that there is a dwc2 patch somewhere (dwc2 has a significant amount of patches) to overcome such behaviours in my case it was not necessary since I can not find a lot of cases in which you want to stop the gadget after a usb connection was established and disconnected.
It seems that the bigger issue is that you get no usb interrupt when you disconnect the device. By looking at your dts doing the following modifications might help:
&usbotg_hs {
compatible = "st,stm32mp15-hsotg", "snps,dwc2";
phys = <&usbphyc_port1 0>; /* 0: UTMI switch selects the OTG controller */
phy-names = "usb2-phy";
dr_mode = "peripheral";
usb-role-switch;
role-switch-default-mode = "peripheral"; /* see USB generic bindings [4] */
status = "okay"; /* enable OTG */
port {
usbotg_hs_ep: endpoint {
remote-endpoint = <&con_usbotg_hs_ep>; /* point the Type-C controller endpoint node */
};
};
};
Setting usb-role-switch and role-switch-default-mode to peripheral might be helpful in case this behaviour is an dwc2 otg related conflict.
Another possibility is a dwc2 power related known issue as described in bugzilla. You can attempt some of the patches mentioned there too.
I hope this helps.