6 years, 11 months ago.

USBKeyboard on KL25Z - only works intermittently

I'm having a lot of trouble running the "Hello World" USBKeyboard example with a KL25Z connected to a MacBook Air running OS X 10.9.3.

After flashing the code and replugging USB to the KL25Z port:

  • most of the time nothing happens (code stuck in USBKeyboard constructor?), but I can replug to the SDA port and reflash the board.
  • occasionally, the desired text is typed. The latency between power up and first text is very variable (from 1-2 seconds to 30 seconds).
  • sometimes, the entire USB port on the laptop goes down and I have to reboot.

Sometimes the device shows up as a composite device, sometimes as HID, sometimes not at all. Plugging the KL25Z port into a Windows 7 machine also yielded a "failed to load driver" message.

Here's a relevant output of system_profiler SPUSBDataType on OS X, when the device registered as composite:

USB 3.0 Hi-Speed Bus:

Host Controller Location: Built-in USB Host Controller Driver: AppleUSBXHCI PCI Device ID: 0x1e31 PCI Revision ID: 0x0004 PCI Vendor ID: 0x8086 Bus Number: 0x0a

Composite Device:

Product ID: 0x0050 Vendor ID: 0x1235 Version: 0.01 Speed: Up to 12 Mb/sec Location ID: 0x14200000 / 15 Current Available (mA): 500 Current Required (mA): Unknown (Device has not been configured)

Question relating to:

I just posted a question on a similar issue here: https://developer.mbed.org/questions/4828/USBDevice-on-FRDM-K64F-sometimes-crash-m/

posted by H. Chanon 07 Oct 2014

1 Answer

6 years, 11 months ago.

Ah this is a nice one :)

Not for you, but because there has been a possible fix for this that should be included soon, but no one knows for sure if it is the solution for an issue which looks alot like yours, but in general comes down to the KL25 (and friends) having issues on USB3 ports.

So can you throw out the USBDevice libary, and instead import this one: https://mbed.org/users/mjr/code/USBDevice/. Then report back if that solves your problems.

Accepted Answer

Erik: Thank you for this excellent pointer - which helped in two ways:

1) Substituting mjr's library successfully made the HelloWorld USBKeyboard example work for me.

2) I also tried the original library, but with a USB 2 hub interposed between the laptop and the KL25Z. This also worked.

posted by Bjoern Hartmann 05 Aug 2014

Ah yes, the USB2.0 hub is indeed also a solution that worked for me too. But it is of course alot better if it works directly, and glad to hear this solved it for you :D

posted by Erik - 05 Aug 2014