This is an old revision of the document!
USB on FreeBSD
USB is short for Universial Serial BUS. There are currently five variants of USB. The new USB stack in FreeBSD -current supports Low, Full and High speed USB devices in Host- and Device Mode.
- Low Speed USB
- Full Speed USB
- High Speed USB
- Super Speed USB (not supported yet)
- Wireless USB (not supported yet)
This page describes HPSUSB/'USB2' which is available in FreeBSD 8-CURRENT.
HPSUSB FAQ
- Q: hald is using 100% CPU
- A: You need to re-link hald to use /usr/lib/libusb20.so which is now part of the base distribution.
- Q: xsane does not detect my scanner
- A: You need to re-link xsane to use /usr/lib/libusb20.so which is now part of the base distribution.
- Q: Do I need to recompile the software before it can use libusb20 instead of libusb-0.1.x?
- A: No, libusb20 is binary compatible with libusb-0.1.x.
- Q: How do I re-link an application to use libusb20?
- A: Add “-lusb20” when linking, modify “libmap.conf” or run the following commands like SuperUser:
mv -i /usr/local/lib/libusb-0.1.so.8 /root/ mv -i /usr/local/lib/libusb.a /root/ ln -s /usr/lib/libusb20.so.1 /usr/local/lib/libusb-0.1.so.8 ln -s /usr/lib/libusb20.a /usr/local/lib/libusb.a
- Q: How do I give other users access to my USB devices on my computer?
- A: Examples:
# This command gives access to a specific USB device given by BUS unit # and device address, until the device is unplugged: usbconfig -u xxx -a yyy set_owner user:group set_perm 0660 # This command gives permanent access to a specific # BUS unit and all sub devices: usbconfig -u xxx set_owner user:group set_perm 0660 # This command gives permanent access access to any USB device: usbconfig set_owner user:group set_perm 0660 # This command dumps the access restrictions: usbconfig dump_access # Also see man usb2_core
- Q: I see the following error and USB stops working “Page offset was not preserved!”
- A: Try this patch:
http://perforce.freebsd.org/chv.cgi?CH=154181
- Q: I can't boot my Freesbie using USB2.
- A: Try this patch:
--- vfs_mount.c.orig Mon Dec 22 14:43:36 2008
+++ vfs_mount.c Mon Dec 22 15:09:14 2008
@@ -58,6 +58,7 @@
#include <sys/sysent.h>
#include <sys/systm.h>
#include <sys/vnode.h>
+#include <sys/cons.h>
#include <vm/uma.h>
#include <geom/geom.h>
@@ -1606,7 +1607,11 @@
vfs_mountroot(void)
{
char *cp;
- int error, i, asked = 0;
+ const char *rootdevname_orig;
+ int error;
+ unsigned int i;
+ unsigned char asked = 0; /* set if asked for mount point */
+ unsigned char timeout = 16; /* seconds */
root_mount_prepare();
@@ -1624,6 +1629,10 @@
asked = 1;
}
+ /* store a copy of the initial root device name */
+ rootdevname_orig = ctrootdevname;
+ retry:
+
/*
* The root filesystem information is compiled in, and we are
* booted with instructions to use it.
@@ -1674,12 +1683,27 @@
if (!vfs_mountroot_try(ctrootdevname))
goto mounted;
/*
- * Everything so far has failed, prompt on the console if we haven't
- * already tried that.
+ * Check if we should try more times.
+ */
+ if (timeout != 0) {
+ timeout--;
+ pause("WROOT", hz);
+ if (cncheckc() == -1) {
+ /* no key press - try again */
+ ctrootdevname = rootdevname_orig;
+ goto retry;
+ }
+ }
+
+ /*
+ * Everything so far has failed, prompt on the console if we
+ * haven't already tried that.
*/
- if (!asked)
+ if (!asked) {
+ printf("\n");
if (!vfs_mountroot_ask())
goto mounted;
+ }
panic("Root mount failed, startup aborted.");
- Q: My mass storage device is not working.
- A: If your mass storage device needs a quirk, because it does not conform to the SCSI specification
you can add it in the following way:
1. Unload “usb2_storage_mass” if it loaded. 2. Plug your device.
- You might have to add a new entry for your device in /sys/dev/usb/usbdevs . After updating “usbdevs” you regenerate “usb2_devid.h” and “usb2_devtable.h” by running:
make -C /sys/dev/usb2/include
4. To get the VID+PID for your device you run “usbconfig -u X -a Y dump_device_desc” where X and Y are the numbers reported by ugen.
#For example: usbconfig -u 4 -y 7 dump_device_desc
5. Try adding an entry in the quirktable in /sys/dev/usb2/storage/umass2.c. Look at the other quirks for examples.