NetBSD Problem Report #50142

From www@NetBSD.org  Mon Aug 10 20:58:02 2015
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 2AC6EA5B2E
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 10 Aug 2015 20:58:02 +0000 (UTC)
Message-Id: <20150810205800.C06E6A65CC@mollari.NetBSD.org>
Date: Mon, 10 Aug 2015 20:58:00 +0000 (UTC)
From: edwin@etorok.net
Reply-To: edwin@etorok.net
To: gnats-bugs@NetBSD.org
Subject: Cannot install NetBSD on machine with USB keyboard
X-Send-Pr-Version: www-1.0

>Number:         50142
>Category:       kern
>Synopsis:       Cannot install NetBSD on machine with USB keyboard
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 10 21:00:00 +0000 2015
>Last-Modified:  Thu Aug 13 00:35:01 +0000 2015
>Originator:     Török Edwin
>Release:        7.0-RC2
>Organization:
Skylable Ltd.
>Environment:
(unknown, haven't been able to install yet)
>Description:
I am trying to install NetBSD 7.0-RC2/amd64 on a machine with M5A99FX PRO R2.0 motherboard, UEFI BIOS, and a Tesoro Durandal USB keyboard.

I have enabled Compatibility Setup Module (legacy boot) in the BIOS, and legacy USB support, and although the keyboard works in the NetBSD bootloader (I am able to type '1'), by the time it reaches the installer's keyboard layout selection it stops working (none of the arrow or letter keys produce any effect).

If I unplug/replug the keyboard I get this message:
uhub7: at uhub1 port 5: Genesys Logic USB2.0 Hub, class...
uhub7: single transaction translator
uhidev2 at uhub7 port 2 configuration 1 interface 0
uhidev2: EST Gaming keyboard, rev 2.00/0.97, addr3, ic...
ukbd1 at uhidev2
wskbd1 at ukbd1 mux 1
uhidev3: EST Gaming keyboard, rev 2.00/0.97, addr 3, icl...
uhid1 at uhidev3: input=4, output=0, feature=0
uhidev4 at uhub7 port 2 configuration 1 interface 2
uhidev4: EST Gaming Keyboard, rev 2.00/0.97, addr 3, icl...
ukbd2 at uhidev4
ukbd2: attach failed, too many modifier keys


On Linux lsusb shows:
Bus 001 Device 004: ID 0665:6000 Cypress Semiconductor 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0665 Cypress Semiconductor
  idProduct          0x6000 
  bcdDevice            0.97
  iManufacturer           1 EST
  iProduct                2 Gaming keyboard
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           84
    bNumInterfaces          3
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      1 Keyboard
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      65
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               2
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      25
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval               2
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      37
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x000f  1x 15 bytes
        bInterval               2
Device Status:     0x0000
  (Bus Powered)

And dmesg on Linux shows:
[    2.498191] usb 1-5.2: New USB device found, idVendor=0665, idProduct=6000
[    2.498193] usb 1-5.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    2.498195] usb 1-5.2: Product: Gaming keyboard
[    2.498197] usb 1-5.2: Manufacturer: EST
[    2.499184] input: EST Gaming keyboard as /devices/pci0000:00/0000:00:12.2/usb1/1-5/1-5.2/1-5.2:1.0/0003:0665:6000.0003/input/input4
[    2.554914] hid-generic 0003:0665:6000.0003: input,hidraw2: USB HID v1.11 Keyboard [EST Gaming keyboard] on usb-0000:00:12.2-5.2/input0
[    2.556064] input: EST Gaming keyboard as /devices/pci0000:00/0000:00:12.2/usb1/1-5/1-5.2/1-5.2:1.1/0003:0665:6000.0004/input/input5
[    2.610868] hid-generic 0003:0665:6000.0004: input,hidraw3: USB HID v1.11 Device [EST Gaming keyboard] on usb-0000:00:12.2-5.2/input1
[    2.611647] input: EST Gaming keyboard as /devices/pci0000:00/0000:00:12.2/usb1/1-5/1-5.2/1-5.2:1.2/0003:0665:6000.0005/input/input6
[    2.666849] hid-generic 0003:0665:6000.0005: input,hidraw4: USB HID v1.11 Keyboard [EST Gaming keyboard] on usb-0000:00:12.2-5.2/input2
>How-To-Repeat:
1. Boot NetBSD-7.0-RC2 installer from USB mass storage
2. Press '1' at installer bootloader (works)
3. Press arrow keys or letters on the installer's layout selection (doesn't work)
4. Unplug and replug the keyboard
5. notice message on console about 'too many modifier keys'
>Fix:

>Audit-Trail:
From: =?UTF-8?B?VMO2csO2ayBFZHdpbg==?= <edwin@etorok.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/50142: Cannot install NetBSD on machine with USB keyboard
Date: Tue, 11 Aug 2015 00:43:15 +0300

 If it helps here is the usbhid-dump outputs from Linux, 001:004 should be the keyboard:

 # usbhid-dump
 001:004:002:DESCRIPTOR         1439242686.123876
  05 01 09 06 A1 01 05 07 19 E0 29 E7 15 00 25 01
  75 01 95 08 81 02 19 00 29 6F 15 00 25 01 75 01
  95 70 81 02 C0

 001:004:001:DESCRIPTOR         1439242686.125255
  05 0C 09 01 A1 01 05 0C 19 00 2A FF 0F 15 00 26
  FF 0F 75 10 95 02 81 00 C0

 001:004:000:DESCRIPTOR         1439242686.126804
  05 01 09 06 A1 01 05 07 19 E0 29 E7 15 00 25 01
  75 01 95 08 81 02 75 08 95 01 81 01 05 07 19 00
  2A FF 00 15 00 26 FF 00 75 08 95 06 81 00 05 08
  19 01 29 03 25 01 75 01 95 03 91 02 95 05 91 01
  C0

 008:002:001:DESCRIPTOR         1439242686.129381
  05 01 09 02 A1 01 85 01 09 01 A1 00 05 09 19 01
  29 05 15 00 25 01 95 05 75 01 81 02 95 01 75 03
  81 01 05 01 16 01 80 26 FF 7F 75 10 95 02 09 30
  09 31 81 06 15 81 25 7F 75 08 95 01 09 38 81 06
  05 0C 0A 38 02 95 01 81 06 C0 06 00 FF 09 01 15
  00 26 FF 00 75 08 95 07 B1 02 C0 05 0C 09 01 A1
  01 85 03 15 00 26 FF 02 19 00 2A FF 02 75 10 95
  01 81 00 C0

 008:002:000:DESCRIPTOR         1439242686.131370
  05 01 09 06 A1 01 05 07 19 E0 29 E7 15 00 25 01
  75 01 95 08 81 02 95 01 75 08 81 01 05 08 19 01
  29 05 95 05 75 01 91 02 95 01 75 03 91 01 05 07
  19 00 2A FF 00 15 00 26 FF 00 95 06 75 08 81 00
  C0

 Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
 Bus 011 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
 Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
 Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
 Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
 Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
 Bus 010 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
 Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
 Bus 009 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
 Bus 001 Device 004: ID 0665:6000 Cypress Semiconductor 
 Bus 001 Device 003: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
 Bus 008 Device 002: ID 1bcf:08d8 Sunplus Innovation Technology Inc. 
 Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

From: matthew green <mrg@eterna.com.au>
To: gnats-bugs@NetBSD.org, edwin@etorok.net
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
    netbsd-bugs@netbsd.org
Subject: re: kern/50142: Cannot install NetBSD on machine with USB keyboard
Date: Tue, 11 Aug 2015 10:59:56 +1000

 looks like the code maxxes out at 8, but should work if limited to that.

 i've tested a patch on my system where i limited it to 4 and it seems
 to at least work minimally.  

 i should have a image for testing available shortly.  it won't try to
 support more, but should allow the keyboard to work for upto 8.


 .mrg.

From: matthew green <mrg@eterna.com.au>
To: kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
    netbsd-bugs@netbsd.org, gnats-bugs@NetBSD.org, edwin@etorok.net
Cc: 
Subject: re: kern/50142: Cannot install NetBSD on machine with USB keyboard
Date: Tue, 11 Aug 2015 16:52:01 +1000

 please try this image:

    http://ftp.netbsd.org/pub/NetBSD/misc/mrg/NetBSD-7.0_RC2-amd64.iso

 which has the patch below applied.


 .mrg.

 Index: sys/dev/usb/ukbd.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/usb/ukbd.c,v
 retrieving revision 1.129.4.1
 diff -p -u -r1.129.4.1 ukbd.c
 --- sys/dev/usb/ukbd.c	21 Mar 2015 17:30:43 -0000	1.129.4.1
 +++ sys/dev/usb/ukbd.c	11 Aug 2015 06:45:55 -0000
 @@ -410,15 +410,14 @@ ukbd_attach(device_t parent, device_t se
  	sc->sc_flags = 0;

  	aprint_naive("\n");
 +	aprint_normal("\n");

  	if (!pmf_device_register(self, NULL, NULL)) {
 -		aprint_normal("\n");
  		aprint_error_dev(self, "couldn't establish power handler\n");
  	}

  	parseerr = ukbd_parse_desc(sc);
  	if (parseerr != NULL) {
 -		aprint_normal("\n");
  		aprint_error_dev(self, "attach failed, %s\n", parseerr);
  		return;
  	}
 @@ -437,7 +436,7 @@ ukbd_attach(device_t parent, device_t se
  #endif

  #ifdef DIAGNOSTIC
 -	aprint_normal(": %d modifier keys, %d key codes", sc->sc_nmod,
 +	aprint_normal_dev(self, "%d modifier keys, %d key codes\n", sc->sc_nmod,
  	       sc->sc_nkeycode);
  	if (sc->sc_flags & FLAG_APPLE_FN)
  		aprint_normal(", apple fn key");
 @@ -446,7 +445,6 @@ ukbd_attach(device_t parent, device_t se
  	if (sc->sc_flags & FLAG_GDIUM_FN)
  		aprint_normal(", Gdium fn key");
  #endif
 -	aprint_normal("\n");

  	/*
  	 * Remember if we're the console keyboard.
 @@ -1048,10 +1046,10 @@ ukbd_parse_desc(struct ukbd_softc *sc)
  	struct hid_item h;
  	int size;
  	void *desc;
 -	int imod;
 +	int imod, imodfull;

  	uhidev_get_report_desc(sc->sc_hdev.sc_parent, &desc, &size);
 -	imod = 0;
 +	imod = imodfull = 0;
  	sc->sc_nkeycode = 0;
  	d = hid_start_parse(desc, size, hid_input);
  	while (hid_get_item(d, &h)) {
 @@ -1082,8 +1080,8 @@ ukbd_parse_desc(struct ukbd_softc *sc)
  				sc->sc_mods[imod].mask = 1 << imod;
  				sc->sc_mods[imod].key = HID_GET_USAGE(h.usage);
  				imod++;
 -			} else
 -				return ("too many modifier keys");
 +			}
 +			imodfull++;
  		} else {
  			/* Array */
  			if (h.loc.size != 8)
 @@ -1099,6 +1097,9 @@ ukbd_parse_desc(struct ukbd_softc *sc)
  		}
  	}
  	sc->sc_nmod = imod;
 +	if (imod != imodfull)
 +		aprint_error_dev(sc->sc_hdev.sc_dev, "too many modifier keys, "
 +			"found %d, only support %d\n", imodfull, imod);
  	hid_end_parse(d);

  	hid_locate(desc, size, HID_USAGE2(HUP_LEDS, HUD_LED_NUM_LOCK),

From: =?UTF-8?B?VMO2csO2ayBFZHdpbg==?= <edwin@etorok.net>
To: matthew green <mrg@eterna.com.au>, kern-bug-people@netbsd.org,
 gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/50142: Cannot install NetBSD on machine with USB keyboard
Date: Tue, 11 Aug 2015 10:27:38 +0300

 On 08/11/2015 09:52 AM, matthew green wrote:
 > please try this image:
 > 
 >    http://ftp.netbsd.org/pub/NetBSD/misc/mrg/NetBSD-7.0_RC2-amd64.iso
 > 
 > which has the patch below applied.

 Thanks, could you upload the -install.img variant please? The ISO won't boot from my USB flash drive, not even with Unetbootin.

 --Edwin

From: matthew green <mrg@eterna.com.au>
To: =?UTF-8?B?VMO2csO2ayBFZHdpbg==?= <edwin@etorok.net>
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
    netbsd-bugs@netbsd.org, gnats-bugs@NetBSD.org
Subject: re: kern/50142: Cannot install NetBSD on machine with USB keyboard
Date: Tue, 11 Aug 2015 17:57:21 +1000

 T?r?k Edwin writes:
 > On 08/11/2015 09:52 AM, matthew green wrote:
 > > please try this image:
 > > =

 > >    http://ftp.netbsd.org/pub/NetBSD/misc/mrg/NetBSD-7.0_RC2-amd64.iso
 > > =

 > > which has the patch below applied.
 > =

 > Thanks, could you upload the -install.img variant please? The ISO won't =
 boot from my USB flash drive, not even with Unetbootin.

 try this.  i have no idea if it works, but i think i found the right
 target to build it :-)

    http://ftp.netbsd.org/pub/NetBSD/misc/mrg/NetBSD-7.0_RC2-amd64-install.=
 img.gz

From: =?UTF-8?B?VMO2csO2ayBFZHdpbg==?= <edwin@etorok.net>
To: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
 gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc: 
Subject: Re: kern/50142: Cannot install NetBSD on machine with USB keyboard
Date: Tue, 11 Aug 2015 12:53:41 +0300

 On 08/11/2015 11:00 AM, matthew green wrote:
 > The following reply was made to PR kern/50142; it has been noted by GNATS.
 > 
 > From: matthew green <mrg@eterna.com.au>
 > To: =?UTF-8?B?VMO2csO2ayBFZHdpbg==?= <edwin@etorok.net>
 > Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
 >     netbsd-bugs@netbsd.org, gnats-bugs@NetBSD.org
 > Subject: re: kern/50142: Cannot install NetBSD on machine with USB keyboard
 > Date: Tue, 11 Aug 2015 17:57:21 +1000
 > 
 >  T?r?k Edwin writes:
 >  > On 08/11/2015 09:52 AM, matthew green wrote:
 >  > > please try this image:
 >  > > =
 >  
 >  > >    http://ftp.netbsd.org/pub/NetBSD/misc/mrg/NetBSD-7.0_RC2-amd64.iso
 >  > > =
 >  
 >  > > which has the patch below applied.
 >  > =
 >  
 >  > Thanks, could you upload the -install.img variant please? The ISO won't =
 >  boot from my USB flash drive, not even with Unetbootin.
 >  
 >  try this.  i have no idea if it works, but i think i found the right
 >  target to build it :-)
 >  
 >     http://ftp.netbsd.org/pub/NetBSD/misc/mrg/NetBSD-7.0_RC2-amd64-install.=
 >  img.gz

 Not sure what went wrong, but I get:
 NetBSD MBR boot
 Boot error

 I'll try to compare your image to the official one, and perhaps just copy your kernel inside the official install-img and see if that works.
 Will keep you posted if I succeed.


From: =?windows-1252?Q?T=F6r=F6k_Edwin?= <edwin@etorok.net>
To: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org, 
 gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc: 
Subject: Re: kern/50142: Cannot install NetBSD on machine with USB keyboard
Date: Tue, 11 Aug 2015 13:45:07 +0300

 Succeeded booting (by copying /netbsd and netbsd-*.gz from your -install.img to the 7.0-RC2 install.img), many thanks for the patch and the install images.
 Now when I unplug and replug the keyboard there is some progress, I get a different message, so it IS running the kernel with your patch:

 ukbd2: too many modifier keys, found 120, only support 8
 wskbd2 at ukbd2 mux 1

 However the keys still don't work (tried letters, arrows, ctrl-alt-del).
 I don't have any more errors output from the NetBSD kernel, how can we debug what else is wrong?


From: =?UTF-8?B?VMO2csO2ayBFZHdpbg==?= <edwin@etorok.net>
To: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
 gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc: 
Subject: Re: kern/50142: Cannot install NetBSD on machine with USB keyboard
Date: Wed, 12 Aug 2015 09:58:02 +0300

 Thanks to  phadtai on #netbsd for pointing out that it might be related to this FreeBSD bug: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=181425
 Indeed my keyboard has Full N-key rollover, and it might explain why they keys are reported differently from normal (or 6-KRO) keyboards.

 Can the patch (or the usbconfig command) be adapted to NetBSD?

From: matthew green <mrg@eterna.com.au>
To: =?UTF-8?B?VMO2csO2ayBFZHdpbg==?= <edwin@etorok.net>
Cc: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
    gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: re: kern/50142: Cannot install NetBSD on machine with USB keyboard
Date: Thu, 13 Aug 2015 10:32:54 +1000

 T?r?k Edwin writes:
 > Thanks to  phadtai on #netbsd for pointing out that it might be related =
 to this FreeBSD bug: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D1=
 81425
 > Indeed my keyboard has Full N-key rollover, and it might explain why the=
 y keys are reported differently from normal (or 6-KRO) keyboards.
 > =

 > Can the patch (or the usbconfig command) be adapted to NetBSD?

 not easily.

 i found thsi code in uhidev.c, which is similar to what it needs,
 but it is not enabled:

 151 #if 0
 152
 153         qflags =3D usbd_get_quirks(sc->sc_udev)->uq_flags;
 154         if ((qflags & UQ_NO_SET_PROTO) =3D=3D 0 &&
 155             id->bInterfaceSubClass !=3D UISUBCLASS_BOOT)
 156                 (void)usbd_set_protocol(iface, 1);
 157 #endif

 so we're never seting this now.

 possible, reversing the above to set the protocol to 0 if there
 is a quirk for it would work.

 it would be best if someone added real support for this kind of
 keyboard...


 .mrg.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.