PORTS Forum

Ports and Interfaces => USB => Topic started by: swaroop on March 16, 2018, 04:42:50 pm

Title: USB Host not detecting device reset in Linux
Post by: swaroop on March 16, 2018, 04:42:50 pm
I am developing a USB device driver in Linux 4.9.11.  The device uses Vendor Specific class.  I have the driver working up until a point where device is expected to be reset and re-enumerated.  Windows seems to handle this fine but I can't get Linux to call any of the driver callback functions.  Following sequence of events.

- Device is connected to Host.
- Setup sequence is completed successfully.
- Some data is transferred back and fourth between device & host over vendor specific ep0.
- After this, device issues a signal and is looking to be reset.  (Marked as <High-speed> in attached Beagle USB logs)

I am not familiar with lower level signals and how Linux is supposed to handle this.  Posting here after looking around for few days.  I do not have access to device side code or Windows host driver code.

Attached Beagle USB Logs
Title: Re: USB Host not detecting device reset in Linux
Post by: Jan Axelson on March 17, 2018, 09:27:46 am
The host will reset a device if:

the host requests the device's upstream hub to reset the device

or

the device emulates detach and reattach.

Is your driver sending a request to have the hub reset the device and if so, what happens when it does so?

If previously exchanged data is supposed to instruct the device to emulate detach and reattach, can you find any difference in the previous communications (Windows/Linux) and the device's response to them?
Title: Re: USB Host not detecting device reset in Linux
Post by: swaroop on March 17, 2018, 09:59:08 am
Hi Jan, Thank you for replying to my question and helping me out.

My understanding from the Beagle logs is that the device is trying to emulate detach in this case.  My driver is not called when device is trying to detach because the lower level controller doesn't see or handle the "<High-speed>" event?  I can see from logs that device keeps on trying this every 2 seconds, waiting for handshake from host controller.

Looking at the previously exchanged data, I didn't notice any differences.  The only difference I noticed was after this "<High-speed>" event, as I posted in attached logs.  I am wondering if there is a setting I am missing to instruct host controller to handle this or something else I am missing?
Title: Re: USB Host not detecting device reset in Linux
Post by: Jan Axelson on March 17, 2018, 12:28:34 pm
It looks like the Linux host isn't seeing the emulated detach/re-attach.

See 7.1 in the USB 2.0 spec for how the hub uses the Disconnection Envelope Detector to detect when a high-speed device detaches from the bus. The spec doesn't define how a device would emulate detaching.

The device would then need to emulate re-attaching at full speed (by pulling D+ high) to prompt the host to re-enumerate and switch the device to high speed.

Perhaps the problem is with the device, and Windows is more tolerant of it.

Here is a description of enumeration from USB Complete 5th Edition:

http://janaxelson.com/usbcenum.htm

I found this (related):

https://patents.google.com/patent/EP1183611A2