USB communication fails on ESD test / USB response status == EPROTO (-71) in Wireshark/USBmon

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
dsteinwe
XCore Addict
Posts: 144
Joined: Wed Jun 29, 2016 8:59 am

Post by dsteinwe »

Fabrice, you are not alone ;-). I suspect that lib_XUD from version 2.2.0 to 2.2.1 has changed the runtime behavior. However, I have not yet verified this thesis.


User avatar
fabriceo
XCore Addict
Posts: 186
Joined: Mon Jan 08, 2018 4:14 pm

Post by fabriceo »

Hello,
I ve just rolled back 2.2.4 to 2.2.1 and got same exception described earlier. the strange thing is that I have a version of my application using 2.2.1 which doesn't show this exception... so at first it means this is my "new" version of application, and not the new xud version.
still I m skeptical because I have not changed this area related to usb-host buffer-decouple-i2s for a while. I will try to investigate a potential stack corruption impacting xud task.
User avatar
dsteinwe
XCore Addict
Posts: 144
Joined: Wed Jun 29, 2016 8:59 am

Post by dsteinwe »

It's just an idea: maybe one of the downstream threads is causing a backlog, causing the exception in lib_xud.
User avatar
fabriceo
XCore Addict
Posts: 186
Joined: Mon Jan 08, 2018 4:14 pm

Post by fabriceo »

hi dsteinewe, in fact when I see that the I2S frequency is not the same than the expected USB Host, then I have a global flag which force the behavior to not push to or pull from the fifobuffers, this way so far I had no any problems with the host either on mac linux or win.

after some deeper investigation, in fact I always comme to an error (resource or load_store) somewhere inside the XUD_LLD_IoLoop() assembly code, and not always in the same subroutine (depends on mac or win and sample rate).
I see in the code that Ross is using both events and interrupts to capture special situations, I suspected that may be a register is corrupted in a special case, but reading his code is giving hard headache :)

Also FYI, I have extended all the stack of each task by using #pragma stackfunction and this didn't solve the problem.
let see if this night brings new idea to explore
User avatar
fabriceo
XCore Addict
Posts: 186
Joined: Mon Jan 08, 2018 4:14 pm

Post by fabriceo »

Hi , I have solved the error discussed in previous posts.
Basically when I had a different frequency between host and i2s, I was not sinking the buffers sent by the host and I was not calling again XUD_SetReady_OutPtr() in buffer.xc.
now, I systematically rearm the buffer request by calling XUD_SetReady_OutPtr() and I don't have any more exceptions.

still it is strange to me that not calling XUD_SetReady_OutPtr() brought exceptions error in the XUD_LLD_IoLoop but I havent enough experience of the USB protocol and I cannot provide usb traces to suggest improvement. Thanks for reading.
User avatar
dsteinwe
XCore Addict
Posts: 144
Joined: Wed Jun 29, 2016 8:59 am

Post by dsteinwe »

Well done!
User avatar
Ross
XCore Expert
Posts: 968
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

fabriceo wrote: Thu Jan 25, 2024 10:44 am still it is strange to me that not calling XUD_SetReady_OutPtr() brought exceptions error in the XUD_LLD_IoLoop but I havent enough experience of the USB protocol and I cannot provide usb traces to suggest improvement. Thanks for reading.
Yes, that doesn't sound correct. If you have a small example program please include it on an issue on www.github.com/xmos/lib_xud
User avatar
fabriceo
XCore Addict
Posts: 186
Joined: Mon Jan 08, 2018 4:14 pm

Post by fabriceo »

FYI, I ve tried to reproduce my situation on a vanilla usb Audio 7.3.1, by not setting the g_aud_from_host_flag in ep_buffer.xc but this didn't give any exception in xud_ioLoop(). lets park it for the moment.