简体   繁体   English

USB大容量读取超时,协议分析仪称已传送数据

[英]USB bulk read times out, protocol analyzer says data delivered

I'm trying to make an open source libusb driver for a piece of hardware. 我正在尝试为一件硬件制作开源的libusb驱动程序。 Unfortunately, a time and data accurate packet replay on Linux causes a certain bulk read to repeatably time out and not return the bulk data (LIBUSB_ERROR_TIMEOUT, URB status: -ENOENT). 不幸的是,Linux上时间和数据准确的数据包重播会导致某些批量读取重复出现超时,并且不会返回批量数据(LIBUSB_ERROR_TIMEOUT,URB状态:-ENOENT)。 According to Wireshark, the Windows application is predictable and always returns this data when executed on VMWare Workstation through the same Linux laptop. 根据Wireshark的说法,Windows应用程序是可预测的,并且在通过同一Linux笔记本电脑在VMWare Workstation上执行时始终返回此数据。

I used Wireshark to generate packet captures from both the Windows app and my app and, as far as I can tell, they are identical up to the error. 我使用Wireshark从Windows应用程序和我的应用程序生成数据包捕获,据我所知,直到错误为止,它们都是相同的。 I went a step further and borrowed a USB protocol analyzer (Total Phase Beagle 12) and captured data on the wire. 我走了一步,借用了USB协议分析仪(Total Phase Beagle 12),并通过线路捕获了数据。 My previous testing was at high speed but I was able to make an equivalent test case at full speed so that I can use the analyzer. 我以前的测试是高速的,但是我可以全速制作一个等效的测试用例,以便可以使用分析仪。 It shows that the device is in fact correctly replying to the control request but somehow is not making it to userspace (or a URB for that matter). 它表明设备实际上在正确地响应控制请求,但是不知何故没有将其发送给用户空间(或与此相关的URB)。

A few packets before the error, there is a very similar packet (same bulk in request and same data returned). 错误之前的几个数据包,有一个非常相似的数据包(请求中的批量相同,返回的数据相同)。 The python libusb code does not throw an error but the URB status is -EREMOTEIO. python libusb代码不会引发错误,但是URB状态为-EREMOTEIO。 As far as I can tell, this may be normal and may simply be a difference between how VMWare and libusb set Linux kernel USB parameters. 据我所知,这可能是正常现象,可能只是VMWare和libusb如何设置Linux内核USB参数之间的区别。 But this is still probably a hint: some different setting is making a big difference. 但这可能仍是一个提示:某些不同的设置会产生很大的变化。

I tried this on a Linux 3.5 x64 and a Linux 3.18 x64 system under Ubuntu 12.04. 我在Ubuntu 12.04下的Linux 3.5 x64和Linux 3.18 x64系统上进行了尝试。 If this looks like it could be a kernel bug I can setup a more recent kernel. 如果这看起来可能是内核错误,那么我可以设置一个更新的内核。 Both systems have Intel 82801H USB controllers. 两种系统都具有Intel 82801H USB控制器。

The device does some weird startup magic where it repeatably resets the device and clears some bulk endpoints. 该设备执行了一些奇怪的启动操作,在此过程中,它会反复重置设备并清除一些批量端点。 Regardless of whether I do this dance the error occurs later on. 不管我是否跳舞,该错误都会在以后发生。

I'm hoping someone has seen this before and can give me some pointers. 我希望有人以前见过这个,可以给我一些指导。 Otherwise I imagine my next step would be to try to find workarounds (I might have a workaround but it creates other problems) or instrument Linux USB subsystem some more. 否则,我想我的下一步将是尝试找到解决方法(我可能有解决方法,但是它会产生其他问题),或者进一步检测Linux USB子系统。

Data: 数据:

-Full Wireshark and Total Phase logs can be found here: http://siliconpr0n.org/uv/bpm/so/ -完整的Wireshark和Total Phase日志可在以下位置找到: http : //siliconpr0n.org/uv/bpm/so/

-Full speed test code: bp1410_rst_12.py -全速测试代码:bp1410_rst_12.py

-Total phase screenshot showing the request made it: failed_reply.png (from 12_04_mein_startup_cold.tdc) -显示请求已完成的总阶段屏幕截图:failed_reply.png(来自12_04_mein_startup_cold.tdc)

-Wireshark screenshot (Windows reference): ws_ref.png -Wireshark屏幕截图(Windows参考):ws_ref.png

-Wireshark screenshot (my Linux libusb): ws_mine.png -Wireshark屏幕截图(我的Linux libusb):ws_mine.png

Is your code intentionally setting URB_SHORT_NOT_OK, whereas Windows code does not? 您的代码是否有意设置URB_SHORT_NOT_OK,而Windows代码没有? IIRC, a short packet will cause IN tokens to stop being sent until the next SOF or until next URB is submitted. IIRC,短数据包将导致IN令牌停止发送,直到下一个SOF或下一个URB提交为止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM