9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] Raspberry Pi: won't recognize the USB mouse
Date: Mon,  3 Mar 2014 08:39:32 -0500	[thread overview]
Message-ID: <7eb8d06c7b498d05cd789e415b0e0b63@mikro.quanstro.net> (raw)
In-Reply-To: <4541e42666533df9ef7bcdb09acac1fc@hamnavoe.com>

> /n/sources/plan9/sys/src/cmd/usb/lib/dev.c:228,233 - dev.c:233,245
>         memset(buf, 0, Ddevlen);
>         if((nr=usbcmd(d, type, Rgetdesc, Ddev<<8|0, 0, buf, nr)) < 0)
>                 return -1;
> +       if(nr == 17){
> +               print("%s: langid %.4ux\n", argv0, buf[3]<<8|buf[2]);
> +               if((nr = usbcmd(d, type, Rgetdesc, Ddev<<8|0, buf[3]<<8|buf[2], buf, 18)) < 0)
> +                       return -1;
> +               print("%s: nr = %d; buf[%d] = %.2ux\n", argv0, nr, nr, buf[nr]);
> +       }
> +
>
> This is in function loaddevdesc which loads a device descriptor, not a
> string descriptor.  The device descriptor doesn't have a language id
> in offset 2:3, it has bcdUSB and bDeviceClass in those fields.  And
> the specification for the Rgetdesc command says "the wIndex field
> specifies the LanguageID for string descriptors or is reset to zero
> for other descriptors".

you're right.  looks like sloppy junk copied in mindlessly.

it seems that asking for exactly 18 bytes is enough.
i wonder if this will work for all devices.  it does work for all
the ones i've got.

/n/sources/plan9/sys/src/cmd/usb/lib/dev.c:218,224 - dev.c:223,229
  int
  loaddevdesc(Dev *d)
  {
- 	uchar buf[Ddevlen+255];
+ 	uchar buf[Ddevlen];
  	int nr;
  	int type;
  	Ep *ep0;
/n/sources/plan9/sys/src/cmd/usb/lib/dev.c:226,245 - dev.c:231,241
  	type = Rd2h|Rstd|Rdev;
  	nr = sizeof(buf);
  	memset(buf, 0, Ddevlen);
- 	if((nr=usbcmd(d, type, Rgetdesc, Ddev<<8|0, 0, buf, nr)) < 0)
+ 	if((nr = usbcmd(d, type, Rgetdesc, Ddev<<8|0, 0, buf, Ddevlen)) < 0)
  		return -1;
- 	/*
- 	 * Several hubs are returning descriptors of 17 bytes, not 18.
- 	 * We accept them and leave number of configurations as zero.
- 	 * (a get configuration descriptor also fails for them!)
- 	 */
  	if(nr < Ddevlen){
- 		print("%s: %s: warning: device with short descriptor\n",
- 			argv0, d->dir);
- 		if(nr < Ddevlen-1){
- 			werrstr("short device descriptor (%d bytes)", nr);
- 			return -1;
- 		}
+ 		werrstr("short device descriptor (%d bytes)", nr);
+ 		return -1;
  	}
  	d->usb = emallocz(sizeof(Usbdev), 1);
  	ep0 = mkep(d->usb, 0);

interestingly, on the pc i plugged the imac keyboard into,
usb/kb hung.  this is the kernel stack even *after* pulling
the keyboard.

acid; stk()
sleep(r=0xf0daba30,arg=0xf0d55680,f=0xf013fc71)+0x16a /sys/src/nix/port/proc.c:928
epiowait(io=0xf0dab9e0,hp=0xf0d4d6b0,tmout=0x0,load=0x11)+0x37e /sys/src/nix/port/usbehci.c:2289
epio(io=0xf0dab9e0,ep=0xf0dab720,count=0x8,a=0x442917,mustlock=0x1)+0x38e /sys/src/nix/port/usbehci.c:2423
epread(ep=0xf0dab720,count=0x8,a=0x442917)+0x16f /sys/src/nix/port/usbehci.c:2534
usbread(c=0xf0dab840,a=0x442917,n=0x8,offset=0x0)+0x17d /sys/src/nix/port/devusb.c:1070
read(list=0xf056be24,ispread=0x0)+0x269 /sys/src/nix/port/sysfile.c:745
syspread(ar0=0xf0dafa90,list=0xf056be04)+0x1c /sys/src/nix/port/sysfile.c:766
syscall(scallnr=0x32,ureg=0xf0dafad8)+0x22e /sys/src/nix/k10/syscall.c:273
syscallreturn()+0x0 /sys/src/nix/k10/l64syscall.s:52

- erik



  reply	other threads:[~2014-03-03 13:39 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-01  5:43 Michael Hansen
2014-03-01 12:09 ` Richard Miller
2014-03-01 12:12 ` erik quanstrom
2014-03-02 10:46   ` Richard Miller
2014-03-02 14:57     ` erik quanstrom
2014-03-02 19:54       ` Richard Miller
2014-03-02 23:22         ` Winston Kodogo
2014-03-03  1:29         ` erik quanstrom
2014-03-03 11:05           ` Richard Miller
2014-03-03 11:24   ` Richard Miller
2014-03-03 13:39     ` erik quanstrom [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-03-02  1:12 Michael Hansen
2014-03-02  1:39 ` erik quanstrom
2014-02-26 16:27 Ramakrishnan Muthukrishnan
2014-02-26 17:19 ` Richard Miller
2014-02-27 16:27   ` Ramakrishnan Muthukrishnan
2014-02-27 16:35     ` Ramakrishnan Muthukrishnan
2014-02-27 17:05       ` Ramakrishnan Muthukrishnan
2014-02-27 17:08         ` Lyndon Nerenberg
2014-02-27 17:31           ` Ramakrishnan Muthukrishnan
2014-02-27 18:03             ` Bakul Shah
2014-02-28 11:10             ` Ramakrishnan Muthukrishnan
2014-02-28 11:28               ` Richard Miller
2014-02-28 14:12                 ` Ramakrishnan Muthukrishnan
2014-02-28 14:35                   ` Bakul Shah
2014-02-28 15:12                     ` Ramakrishnan Muthukrishnan
2014-02-28 14:45             ` Anthony Sorace
2014-02-28 15:15               ` Ramakrishnan Muthukrishnan
2014-02-28 16:24               ` Bakul Shah
2014-03-04 14:12                 ` Ramakrishnan Muthukrishnan
2014-03-04 14:27                   ` erik quanstrom
2014-03-04 15:54                     ` Ramakrishnan Muthukrishnan
2014-03-04 16:26                       ` erik quanstrom
2014-03-04 18:18                         ` Bakul Shah
2014-03-04 18:26                           ` erik quanstrom
2014-03-08 14:56                           ` Ramakrishnan Muthukrishnan
2014-03-08 14:59                             ` erik quanstrom
2014-03-09 13:25                               ` Ramakrishnan Muthukrishnan
2014-03-09 13:46                                 ` erik quanstrom
2014-03-05 10:57                     ` Richard Miller
2014-03-05 10:59                     ` Richard Miller
2014-02-27 17:10         ` erik quanstrom
2014-02-27 17:15       ` Steve Simon
2014-02-26 17:22 ` Ramakrishnan Muthukrishnan
2014-02-28  4:31   ` Grant Mather
2014-02-28  9:05     ` erik quanstrom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7eb8d06c7b498d05cd789e415b0e0b63@mikro.quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).