USB cable replug crash XU216

Discussions about USB Audio on XMOS devices
stanbleszynski
Newbie
Posts: 1
Joined: Tue Nov 04, 2025 9:41 pm

USB cable replug crash XU216

Post by stanbleszynski »

XU216 USB replug crash:
Running app_usb_aud_xk_216_mc - crashes after replugging the USB, playing or stopped!

I have XMOS chip VBUS connected to USB VBUS, so when the USB cable is unplugged, VUSB at the chip port goes to zero.
When it is plugged VBUS=+5V.

1/ Crash occurs when the cable is unplugged and in the moment when it is plugged back in.
Crash occurs in file xua_endpoint.c function XUD_ResetEndpoint
line:

asm volatile("ldw %0, %1[2]":"=r"(c2):"r"(two)); // Load EP chanend

as if the value of variable two was out of range (it is not zero)

Error message from xrun:

>xrun --xscope app_usb_aud_xk_216_mc\bin\2AMi16o16xxxaax\app_usb_aud_xk_216_mc_2AMi16o16xxxaax.xe
xrun: Program received signal ET_ILLEGAL_RESOURCE,Resource exception.
0x000413a4 in XUD_ResetEndpoint (one=<optimized out>, two=<optimized out>)
at C:/XMOS2/sw_usb_audio/lib/lib_xud/lib_xud/src/user/client/XUD_EpFunctions.xc:168

QUESTION: Is there a simple software fix to prevent the above crash?


2/ I was able to replug the USB cable without crashing if I permanently tie VBUS port on
the XMOS chip to +3.3V thru 10k, but then I cannot always start xrun,
it shows intermittent xrun crashon load & startup with eror messsag:

>xrun --xscope app_usb_aud_xk_216_mc\bin\2AMi16o16xxxaax\app_usb_aud_xk_216_mc_2AMi16o16xxxaax.xe
xrun: Internal error: Operation cannot be completed: Xcore 0 is not enabled. Has the device been locked?
xrun: xgdbserver failed to launch correctly, return code 1

I cannot tie VBUS to #RST pin because XMOS is driving the 2 input USB mux input select signal USB_SEL2 .
VBUS is also muxed.

QUESTION: Why would it not load reliably the xrun file when VBUS is tied high? How to make it load reliably?

Thank You,
SMB 04/11/2025