USB Keyboard puzzle

Hans Petter Selasky hselasky at c2i.net
Fri Apr 9 17:31:50 UTC 2010


On Friday 09 April 2010 16:30:02 Rohit Grover wrote:
> Hello Dear Hackers,
> 
> This is about a puzzling behaviour which has affected me for quite
> some time now and has caused far too many unwanted reboots on my
> Macbook (running FreeBSD).
> 
> The problem appeared around when I transitioned from using 8.0/Release
> 8.0/STABLE; although I am not a 100% sure of that. If I were to switch
> back to 8.0/Release, things would work normally; but then many
> significant and necessary changes have gone into 8.0/STABLE and I do
> not have the option of reverting to 8.0/Release.
> 
> It has to do with the software around the USB keyboard. When booting a
> derivative of 8.0/Stable, about half the time my laptop boots into a
> state where the keyboard is unresponsive; i.e. keystrokes have no
> effect; and thus this condition forces me into a wasteful reboot. This
> state is very likely to reproduce if I do a cold boot.
> I have also discovered that if I boot the laptop with MacOSX, and then
> subsequently reboot into FreeBSD, I have a high chance of getting a
> usable keyboard.
> 
> I had previously suspected changes to code in the ukbd driver. But now
> I have confirmed for myself that ukbd is sane--I did this by adding
> printfs to the data-flow path, and ensured that the read_char()
> device-switch handler within ukbd is correctly able to return key
> scan-codes even when my keyboard appears to be dead.
> 
> I have also noticed that in the cases where my keyboard appears to be
> unresponsive, ukbd attaches as two separate instances: ukbd0 and
> ukbd1:
> 
> <verbatim>
> Apr  9 19:20:35 macbook kernel: ugen0.2: <vendor 0x05ac> at usbus0
> Apr  9 19:20:35 macbook kernel: ukbd0: <vendor 0x05ac product 0x1000,
> class 0/0, rev 2.00/19.65, addr 2> on usbus0
> Apr  9 19:20:35 macbook kernel: kbd0 at ukbd0
> Apr  9 19:20:35 macbook kernel: Root mount waiting for: usbus6
> Apr  9 19:20:35 macbook kernel: Trying to mount root from ufs:/dev/ad6p3a
> Apr  9 19:20:35 macbook kernel: ugen5.2: <Apple Computer, Inc.> at usbus5
> Apr  9 19:20:35 macbook kernel: GEOM_PART: Partition 'ad6p3' not
> suitable for kernel dumps (wrong type?)
> Apr  9 19:20:35 macbook kernel: ugen5.3: <Apple Computer> at usbus5
> Apr  9 19:20:35 macbook kernel: ukbd1: <Apple Internal Keyboard> on usbus5
> Apr  9 19:20:35 macbook kernel: kbd1 at ukbd1
> </verbatim>
> 
> whereas when the keyboard boots in an OK state, I see the following
> during boot--there is only ukbd0 and no ukbd1:
> 
> <verbatim>
> Apr  9 19:23:21 macbook kernel: ugen5.3: <Apple Computer> at usbus5
> Apr  9 19:23:21 macbook kernel: ukbd0: <Apple Internal Keyboard> on usbus5
> Apr  9 19:23:21 macbook kernel: kbd0 at ukbd0
> </verbatim>
> 
> I have attached my config file, and the dmesg dump from the good and bad
>  cases.
> 
> Could you please help me figure out what's going on with my keyboard?
> 
> thanks,
> Rohit.

Hi,

Some other device tries to attach like a keyboard:

Apr  9 19:23:21 macbook kernel: ugen0.2: <vendor 0x05ac> at usbus0
Apr  9 19:23:21 macbook kernel: ukbd0: <vendor 0x05ac product 0x1000, class 
0/0, rev 2.00/19.65, addr 2> on usbus0
Apr  9 19:23:21 macbook kernel: device_attach: ukbd0 attach returned 6
Apr  9 19:23:21 macbook kernel: ukbd0: <vendor 0x05ac product 0x1000, class 
0/0, rev 2.00/19.65, addr 2> on usbus0
Apr  9 19:23:21 macbook kernel: device_attach: ukbd0 attach returned 6

Because you kbdmux disabled in your kernel config, only the first keyboard 
attaching will work:

#device         kbdmux          # keyboard multiplexer

Hope that helps.

--HPS


More information about the freebsd-usb mailing list