Jetson AGX USB gadget disconnects and reconnects at random

Hi,
The prints show the connection is intermittent:

[ +20.001554] android_work: send uevent USB_STATE=DISCONNECTED
[ +0.000191] tegra-xudc-new 3550000.xudc: ep 3 disabled
[ +0.000057] tegra-xudc-new 3550000.xudc: ep 2 disabled
[ +0.000224] configfs-gadget gadget: super-speed config #1.c
[ +0.000134] android_work: sent uevent USB_STATE=CONNECTED
[ +0.000070] android_work: sent uevent USB_STATE=CONFIGURED

From experience this is probably due to instable power supply. Sometimes the execution drains too much current and the power supply is not stable. Not sure if it help but please disable auto suspend and give it a try:
Unable to permanently turn off autosuspend for a USB device connected to a Xavier NX - #4 by linuxdev