# FreeBSD 9.2 USB peripherals



## umphy (Oct 2, 2013)

Hi,

I just upgraded my system to FreeBSD 9.2 following the instructions in the Handbook, but my USB keyboard and mouse stopped working. They worked fine in 9.1. When I plug them in I get:


```
usb_alloc_device: device init 2 failed (USB_ERR_IOERROR, ignored)
ugen0.2: <Unknown> at usbus0 (disconnected)
uhub_reattach_port: could not allocate new device
```

I just checked with a USB thumbdrive and it has the same problem. Looks like it's a general USB issue.

Edit: looks like my problem is described in detail here: http://freebsd.1045724.n5.nabble.com/usb-181159-Problem-attaching-USB-device-td5835018.html. Does anyone know the progress on that issue?


----------



## SirDice (Oct 2, 2013)

umphy said:
			
		

> Edit: looks like my problem is described in detail here: http://freebsd.1045724.n5.nabble.com/usb-181159-Problem-attaching-USB-device-td5835018.html. Does anyone know the progress on that issue?


Have a look at the PR: PR 181159

And have you tried updating to the full release? It came out a few days ago. It may have already been fixed.


----------



## umphy (Oct 3, 2013)

SirDice said:
			
		

> Have a look at the PR: PR 181159
> 
> And have you tried updating to the full release? It came out a few days ago. It may have already been fixed.



Looking at that PR, the issue seems to be still open.

And yes, sorry I forgot to mention that my version is the 9.2-RELEASE.


----------



## hedgehog (Oct 3, 2013)

Today I installed the new hardware (replaced motherboard from ASUS M2N-E to ASUS Z87-PRO, plus CPU and RAM). Now I'm experiencing the same issue. Mouse works in BIOS but when the FreeBSD boots up it simply gets powered off with the following error output:

```
Oct  4 06:48:47 lair kernel: usb_alloc_device: device init 2 failed (USB_ERR_IOERROR, ignored)
Oct  4 06:48:47 lair kernel: ugen0.2: <Unknown> at usbus0 (disconnected)
Oct  4 06:48:47 lair kernel: uhub_reattach_port: could not allocate new device
Oct  4 06:48:47 lair kernel: usb_alloc_device: device init 2 failed (USB_ERR_IOERROR, ignored)
Oct  4 06:48:47 lair kernel: ugen0.2: <Unknown> at usbus0 (disconnected)
Oct  4 06:48:47 lair kernel: uhub_reattach_port: could not allocate new device
```

`$ pciconf -lv`

```
hostb0@pci0:0:0:0:	class=0x060000 card=0x85341043 chip=0x0c008086 rev=0x06 hdr=0x00
    vendor     = 'Intel Corporation'
    class      = bridge
    subclass   = HOST-PCI
pcib1@pci0:0:1:0:	class=0x060400 card=0x85341043 chip=0x0c018086 rev=0x06 hdr=0x01
    vendor     = 'Intel Corporation'
    class      = bridge
    subclass   = PCI-PCI
pcib2@pci0:0:1:1:	class=0x060400 card=0x85341043 chip=0x0c058086 rev=0x06 hdr=0x01
    vendor     = 'Intel Corporation'
    class      = bridge
    subclass   = PCI-PCI
xhci0@pci0:0:20:0:	class=0x0c0330 card=0x85341043 chip=0x8c318086 rev=0x05 hdr=0x00
    vendor     = 'Intel Corporation'
    class      = serial bus
    subclass   = USB
none0@pci0:0:22:0:	class=0x078000 card=0x85341043 chip=0x8c3a8086 rev=0x04 hdr=0x00
    vendor     = 'Intel Corporation'
    class      = simple comms
em0@pci0:0:25:0:	class=0x020000 card=0x859f1043 chip=0x153b8086 rev=0x05 hdr=0x00
    vendor     = 'Intel Corporation'
    class      = network
    subclass   = ethernet
ehci0@pci0:0:26:0:	class=0x0c0320 card=0x85341043 chip=0x8c2d8086 rev=0x05 hdr=0x00
    vendor     = 'Intel Corporation'
    class      = serial bus
    subclass   = USB
hdac1@pci0:0:27:0:	class=0x040300 card=0x855f1043 chip=0x8c208086 rev=0x05 hdr=0x00
    vendor     = 'Intel Corporation'
    class      = multimedia
    subclass   = HDA
pcib3@pci0:0:28:0:	class=0x060400 card=0x85341043 chip=0x8c108086 rev=0xd5 hdr=0x01
    vendor     = 'Intel Corporation'
    class      = bridge
    subclass   = PCI-PCI
pcib4@pci0:0:28:5:	class=0x060400 card=0x85341043 chip=0x8c1a8086 rev=0xd5 hdr=0x01
    vendor     = 'Intel Corporation'
    class      = bridge
    subclass   = PCI-PCI
ehci1@pci0:0:29:0:	class=0x0c0320 card=0x85341043 chip=0x8c268086 rev=0x05 hdr=0x00
    vendor     = 'Intel Corporation'
    class      = serial bus
    subclass   = USB
isab0@pci0:0:31:0:	class=0x060100 card=0x85341043 chip=0x8c448086 rev=0x05 hdr=0x00
    vendor     = 'Intel Corporation'
    class      = bridge
    subclass   = PCI-ISA
ahci1@pci0:0:31:2:	class=0x010601 card=0x85341043 chip=0x8c028086 rev=0x05 hdr=0x00
    vendor     = 'Intel Corporation'
    class      = mass storage
    subclass   = SATA
none1@pci0:0:31:3:	class=0x0c0500 card=0x85341043 chip=0x8c228086 rev=0x05 hdr=0x00
    vendor     = 'Intel Corporation'
    class      = serial bus
    subclass   = SMBus
vgapci0@pci0:2:0:0:	class=0x030000 card=0x040110b0 chip=0x0dc410de rev=0xa1 hdr=0x00
    vendor     = 'nVidia Corporation'
    device     = 'GF106 [GeForce 450 GTS]'
    class      = display
    subclass   = VGA
hdac0@pci0:2:0:1:	class=0x040300 card=0x040110b0 chip=0x0be910de rev=0xa1 hdr=0x00
    vendor     = 'nVidia Corporation'
    device     = 'GF106 High Definition Audio Controller'
    class      = multimedia
    subclass   = HDA
ahci0@pci0:4:0:0:	class=0x010601 card=0x858d1043 chip=0x06121b21 rev=0x01 hdr=0x00
    vendor     = 'ASMedia Technology Inc.'
    class      = mass storage
    subclass   = SATA
```
`$ usbconfig`

```
ugen0.1: <XHCI root HUB 0x8086> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen1.1: <EHCI root HUB Intel> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen2.1: <EHCI root HUB Intel> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen1.2: <product 0x8008 vendor 0x8087> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen2.2: <product 0x8000 vendor 0x8087> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
```

I currently have 9.2RC3-p1, updating it to 9.2-RELEASE


----------



## hedgehog (Oct 3, 2013)

There are patches already in SVN: http://svnweb.freebsd.org/base?view=revision&revision=255965

Don't know yet if they're work. Do you think I can grab these three changed files from HEAD, replace them in /usr/src/ and rebuild the kernel with that?


----------



## break19 (Oct 4, 2013)

Odd.. I have both a USB mouse and a USB keyboard.  Mine both work fine in FreeBSD 9.2.  I do have issues at boot, but that is because I have Legacy USB disabled in the BIOS.  If I need BIOS / Boot Loader access, I do have a PS/2 keyboard I could use.

Both of my USB peripherals work in both the console, and in Xorg.


----------



## hedgehog (Oct 4, 2013)

break19 said:
			
		

> Odd.. I have both a USB mouse and a USB keyboard.  Mine both work fine in FreeBSD 9.2.  I do have issues at boot, but that is because I have Legacy USB disabled in the BIOS.  If I need BIOS / Boot Loader access, I do have a PS/2 keyboard I could use.
> 
> Both of my USB peripherals work in both the console, and in Xorg.



I had no problems with that while using old Motherboard. What USB controller do you have? I think this is the issue only with Intel controllers and xhci drivers.

@umphy: could you try updating your BIOS and see if that's changes anything? I don't have physical access to my PC at the moment, but I'm trying to rebuild the kernel remotely.


----------



## hedgehog (Oct 4, 2013)

OK, here is an update:


I downloaded patches for this particular revision: http://svnweb.freebsd.org/base?view=revision&revision=255965
Applied them
Rebuilt kernel and rebooted

Mouse works. However, dmesg still complains with the same errors:

```
Timecounter "TSC-low" frequency 1750688198 Hz quality 1000
Root mount waiting for: usbus2 usbus1 usbus0
uhub1: 2 ports with 2 removable, self powered
uhub2: 2 ports with 2 removable, self powered
uhub0: 21 ports with 21 removable, self powered
Root mount waiting for: usbus2 usbus1 usbus0
xhci0: Port routing mask set to 0x00000000
usb_alloc_device: device init 2 failed (USB_ERR_IOERROR, ignored)
ugen0.2: <Unknown> at usbus0 (disconnected)
uhub_reattach_port: could not allocate new device
ugen1.2: <vendor 0x8087> at usbus1
uhub3: <vendor 0x8087 product 0x8008, class 9/0, rev 2.00/0.05, addr 2> on usbus1
ugen2.2: <vendor 0x8087> at usbus2
uhub4: <vendor 0x8087 product 0x8000, class 9/0, rev 2.00/0.05, addr 2> on usbus2
uhub3: 6 ports with 6 removable, self powered
uhub4: 8 ports with 8 removable, self powered
xhci0: Port routing mask set to 0x00000000
usb_alloc_device: device init 2 failed (USB_ERR_IOERROR, ignored)
ugen0.2: <Unknown> at usbus0 (disconnected)
uhub_reattach_port: could not allocate new device
Root mount waiting for: usbus2
ugen2.3: <Asmedia> at usbus2
uhub5: <Asmedia ASM107x, class 9/0, rev 2.10/1.00, addr 3> on usbus2
uhub5: MTT enabled
uhub5: 4 ports with 4 removable, self powered
Root mount waiting for: usbus2
Root mount waiting for: usbus2
ugen2.4: <vendor 0x0b05> at usbus2
ubt0: <vendor 0x0b05 product 0x17d0, class 224/1, rev 1.10/0.01, addr 4> on usbus2
Root mount waiting for: usbus2
ugen2.5: <Logitech> at usbus2
ums0: <Logitech USB Optical Mouse, class 0/0, rev 2.00/54.00, addr 5> on usbus2
ums0: 8 buttons and [XYZT] coordinates ID=0
Trying to mount root from zfs:zroot []...
WARNING: attempt to domain_add(bluetooth) after domainfinalize()
WARNING: attempt to domain_add(netgraph) after domainfinalize()
ugen2.5: <Logitech> at usbus2 (disconnected)
ums0: at uhub4, port 7, addr 5 (disconnected)
ugen2.5: <Logitech> at usbus2
ums0: <Logitech USB Optical Mouse, class 0/0, rev 2.00/54.00, addr 5> on usbus2
ums0: 8 buttons and [XYZT] coordinates ID=0
```

But the mouse is recognized, powered up and it's working.

```
$ usbconfig 
ugen0.1: <XHCI root HUB 0x8086> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen1.1: <EHCI root HUB Intel> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen2.1: <EHCI root HUB Intel> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen1.2: <product 0x8008 vendor 0x8087> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen2.2: <product 0x8000 vendor 0x8087> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen2.3: <ASM107x Asmedia> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (100mA)
ugen2.4: <product 0x17d0 vendor 0x0b05> at usbus2, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen2.5: <USB Optical Mouse Logitech> at usbus2, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (98mA)
```

I have applied the patches to sources of my currently installed system, which is:

```
$ uname -srm
FreeBSD 9.2-RELEASE amd64
```


----------



## SirDice (Oct 4, 2013)

I've seen BIOS/UEFI that had a setting for XHCI hand-off. Not really sure what it does but it might be something to try and turn it off or on.


----------



## hedgehog (Oct 4, 2013)

SirDice said:
			
		

> I've seen BIOS/UEFI that had a setting for XHCI hand-off. Not really sure what it does but it might be something to try and turn it off or on.



My USB issue seems resolved with the patches, but I'll check if there is the mentioned option in my BIOS.


----------



## umphy (Oct 4, 2013)

hedgehog said:
			
		

> I had no problems with that while using old Motherboard. What USB controller do you have? I think this is the issue only with Intel controllers and xhci drivers.
> 
> *umphy*: could you try updating your BIOS and see if that's changes anything? I don't have physical access to my PC at the moment, but I'm trying to rebuild the kernel remotely.



I've checked but unfortunately there are no BIOS updates for my laptop. It is a BIOS with UEFI, but I have it disabled at the moment. Also there doesn't seem to be an XHCI option in my BIOS.

I'm not familiar with building the kernel myself, so I think most likely I'll wait til an update is available via `freebsd-update`.


----------



## hedgehog (Oct 4, 2013)

umphy said:
			
		

> I'm not familiar with building the kernel myself, so I think most likely I'll wait til an update is available via `freebsd-update`.


The problem is that most likely it won't be there untill next minor release, like 9.3-RELEASE. If I'm not mistaken, there are only security fixes available between minor release versions.

Actually, building kernel is not that hard. Anyway, I could send you patched kernel which can be placed under directory, for instance, /boot/usb-test , then you could load it by escaping to boot loader's prompt and selecting the kernel to load, the more details can be found here: http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-trouble.html

However, booting kernel downloaded from the person you don't know is a security risk 

This will only work if your system's arch is amd64.


----------



## umphy (Oct 5, 2013)

Thanks for the encouragement @hedgehog. In the end I did checkout HEAD via `svn`, updated /usr/src/sys/dev/usb/ to the said revision, rebuilt the kernel using the GENERIC configuration, and it's working now


----------



## hedgehog (Oct 5, 2013)

umphy said:
			
		

> Thanks for the encouragement @hedgehog. In the end I did checkout HEAD via `svn`, updated /usr/src/sys/dev/usb/ to the said revision, rebuilt the kernel using the GENERIC configuration, and it's working now



Awesome, glad it helped. I've sent a note that it works in response to PR 181159, hope that will help the developers to gather more test data.


----------



## s_gammons (Nov 15, 2013)

I'm having USB problems with 10.0-BETA3 #0 r257580. I get a fatal error, failed to attach to device.  The chipset is an Intel ICH6 which works with 9.1-RELEASE but has been broken from 9.2 and later.

Is there a fix for this now?


Stan


----------

