5

I'm writing boot firmware on a PowerPC board, and I have a problem with spurious USB keyboard repeating. My firmware is based on u-boot: after enumeration it puts the keyboard into boot protocol, then polls it by sending GET_REPORT control packets. From my reading of the HID specification, the keyboard should simply send back the key states and leave my firmware to detect key changes.

This brings back the key states correctly almost all the time, but every keyboard I have tested also sends back occasional empty packets, which the firmware interrupts as a key-up event. In the worst case this happens every 7ms. Here's a trace from the analyzer:

Empty HID report

In the image above transfers 76 and 78 show the correct key code (I'm holding down 'a' throughout), but transfer 77 is all zeroes.

Is there some configuration I'm missing here, or is the only workaround to ignore empty reports unless I see two in a row?

Adrian Cox
  • 171
  • 5
  • What tool did you use to generate this trace ? Is it a in-circuit tool or external ? I have similar USB keyboard timeout issues in u-boot on FS p4080 platform: EHCI timed out on TD - token=0x80008c80 –  Apr 07 '14 at 13:27
  • It's a Mercury T2 from Teledyne LeCroy: http://teledynelecroy.com/protocolanalyzer/protocoloverview.aspx?seriesid=414&capid=103&mid=511 – Adrian Cox Apr 07 '14 at 13:30

2 Answers2

3

Interesting. As a developer of keyboard firmware my guess would be that these boards internally rebuild the report each key-matrix scan cycle without blocking interrupts while doing so. This would work fine if sending the report is initiated by the keyboard controller (it'll just write the new report into the IN pipe buffer), but could cause empty packets if the report is read asynchronously via GET_REPORT (EP0 handler is invoked by an interrupt.)

Detlef M.
  • 31
  • 2
2

After more investigation, I've come to the conclusion that USB keyboards can not be reliably used by polling the control endpoint. The same keyboards work 100% reliably via the interrupt endpoint, as used by the PC BIOS.

My solution has been to fix the U-Boot bugs that prevented us using interrupt mode.

Adrian Cox
  • 171
  • 5