xmos / lib_xud

XMOS USB code and associated examples
Other
8 stars 25 forks source link

CDC communication is broken #6

Closed ThomasGmeinder closed 6 years ago

ThomasGmeinder commented 6 years ago

I tried the AN00124_CDC_VCOM_class unmodified on the xCORE-200 explorer. When I type any letter, that letter gets echoed back repeatedly and not only once as expected. At this point the CoolTerm application on the Mac hangs.

When I run the same AN00124_CDC_VCOM_class from lib_usb, the behaviour is as expected. I.e. characters are only echoed back once.

ThomasGmeinder commented 6 years ago

I investigated this further with the USB Analyser and the AN00124_CDC_VCOM_class. It shows invalid PID sequence errors on EP1 Out. The XUD responds to the first "CDC out data" transaction with 5 PING-NAK. This is followed by a "CDC out data" with a PING-ACK error. The same thing can be observed when using instead of lib_xud: module_xud+module_usb_shared+module_usb_device

Because the Host keeps getting NAK it keeps resending the same data (the character that is entered into coolTerm). This character is received and looped back by the app_virtual_com. This causes the character to be printed repeatedly on Host terminal application (coolTerm)

Interestingly, the latter works fine within a UAC2+CDC composite device. in that case the XUD responds to "CDC OUT Data" with ACK and there are no PID sequence errors. CDC communication works.

The code for the CDC handler task is exactly the same in both cases. Here it is for the UAC2+CDC composite device as implemented by app_usb_radar: https://github.com/henkmuller/sc_usb_audio/blob/master/module_usb_audio/endpoint0/cdcrequests.xc#L98

And I took care to compile with the same optimisation level (O3)

The USB Analyser shows no enumeration errors so the descriptors seem to be fine.

All of the evidence points to a bug in the XUD in both lib_xud and sc_xud that causes it to NACK CDC OUT Data transactions.

This is on tools 14.3.2. I also tried 14.3.0.