更快的 USB HID 输出
我正在尝试加速一个相当缓慢的引导加载程序。目前,我在单个 USB HID 输出端点上发送数据,由于它是一种低速设备,因此我显然仅限于每 10 毫秒间隔发送一个 8 字节数据包,速度高达 800 字节/秒。
是否有可能以某种方式增加报告频率?或者在单个接口中或作为复合设备的一部分使用多个输出端点?或者也许滥用控制端点来发送额外的数据?
我认为更好的压缩始终是一种替代方案,但这是一个收益递减的领域,并且重新设计硬件以允许全速 USB 并不是真正的选择。
根据记录,我很乐意使用仅限 Windows 的解决方案。
I'm attempting to speed up a rather sluggish bootloader. Currently I'm sending data on a single USB HID output endpoint, and as it's a low-speed device I'm apparently limited to one 8-byte packet per 10 ms interval for a whopping 800 bytes/second.
Is it possible to increase the reporting frequency somehow? Or to use multiple output endpoints in a single interface or as part of a composite device? Or perhaps to abuse the control endpoint to send additional data?
Better compression is always an alternative I suppose, but it's an area of diminishing returns, and redesigning the hardware to allow full-speed USB isn't really an option.
For the record I'd be happy with a Windows-only solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我不确定 Windows 的情况,但大多数主机提供中断端点服务的速度会比规范要求的更快 - 甚至低至 2 毫秒/中断。尝试更改配置描述符以请求 2ms 速率。
我相信这实际上是规范允许的 - 速率是主机可以遵守或不遵守的请求(我读过,例如,即使请求 10 毫秒,某些主机也会以 8 毫秒进行轮询)。您不能依赖您插入的任何随机主机都符合您的费率。
编辑:嗯,不,规范明确指出“中断管道的端点指定其所需的总线访问周期。 […]低速端点仅限于指定 10 毫秒到 255 毫秒。”尽管如此,这在实践中对我有用......
I’m not sure about Windows, but most hosts will service an interrupt endpoint faster than what the spec requires - even down to 2ms/interrupt. Try changing your configuration descriptor to ask for a 2ms rate.
I believe this is actually allowed by the spec - the rate is a request that the host can comply with or not (I’ve read, for example, that some hosts will poll at 8ms even if 10ms is requested). You just can’t rely on any random host you plug into complying with your rate.
Edit: Hmm, no, the spec clearly says “ An endpoint for an interrupt pipe specifies its desired bus access period. […] Low-speed endpoints are limited to specifying only 10 ms to 255 ms.” Nevertheless, this has worked for me in practice…
您可以为此使用“供应商特定请求”。据我所知,TI TUSB3410 芯片就是这样工作的。许多 USB 堆栈已经具备相应的挂钩。
然而,这需要主机端有驱动程序或 libusb。
You can use "Vendor specific requests" for that. The TI TUSB3410 Chip works that way AFAIK. Many USB stacks have the hooks for them already in place.
This requires a driver or libusb on the host side, however.
通过在控制端点上使用 SET_REPORT 请求,我能够将上传速度提高几个数量级,而不是声明单独的中断输出端点。这样您就可以获得可用于控制传输的所有带宽。
此外,使用分成多个段的较大报告有助于减少所需的 SETUP 数据包的数量。
I was able to speed up the upload by orders of magnitude by using SET_REPORT requests on the control endpoint, instead of declaring a separate interrupt out endpoint. That way you get all of the bandwidth available for control transfers.
Also using a larger report split into multiple segments helped reduce the number of SETUP packets needed.
谁说每 10 毫秒只能传输 8 字节数据包?我不知道确切的数字,但我知道你可以发送比这个更大的数据包。我做了一个 HID 设备并使用 64 字节数据包。我想我可以做得更大,但这个限制可能是特定于硬件的。您使用什么硬件?
另外,您是否咨询过USB in a NutShell?
Who says you are limited to an 8-byte packet per 10ms? I don't know the exact numbers off the top of my head, but I know you can send larger packets than that. I did an HID device and was using 64-byte packets. I think I could go larger, but that limit is probably hardware-specific. What hardware are you using?
Also, have you consulted USB in a NutShell?
对于每个基于中断的端点,低速设备的实际限制是每 10 毫秒 8 个字节,高速设备每 1 毫秒 64 个字节。
因此,如果硬件支持的话,似乎首先要尝试的是切换到高速模式。列表中的下一件事是使用多个端点。如果您确实想获得尽可能高的传输速率,HID 类是一个糟糕的选择。
The actual limit is 8 bytes every 10ms for low-speed devices, and 64 bytes every 1ms for high-speed devices, per interrupt-based endpoint.
So it seems that the first thing to try is switching to high-speed mode, if the hardware supports it. The next thing on the list is using multiple endpoints. If you really want to get the highest possible transfer rate, the HID class is a bad choice.