Wednesday, September 27, 2006

hacking usb device drivers->part 1

This is the first article from “Hacking USB device drivers” series. In this part briefly review of one very simple hack: adding missed vendor and product IDs for USB drivers.

  • Adding vendor and product IDs for USB drivers
    • Introduction
    • Changing USB IDs database
    • Result
  • Adding support for new devices to USB drivers (read)

Adding vendor and product IDs for USB drivers

Introduction
I have USB Bluetooth adapter and after plugging this device i got the following new strings in dmesg:
ubt0 at uhub2 port 2 configuration 1 interface 0
ubt0: vendor 0x1131 ISSCBTA, rev 1.10/3.73, addr 2
That’s mean: driver ubt(4) support this device, but vendor and product IDs not present in /usr/src/sys/dev/usb/usbdevs file. Let’s fix it!

Changing USB IDs database
Add the following lines to /usr/src/sys/dev/usb/usbdevs file:
vendor ISSC 0x1131 Integrated System Solution Corp.
...
/* ISSC products */
product ISSC ISSCBTA 0x1001 KY-BT100
Vendor ID must be placed to beginning of file, after vendor with lesser ID. Product IDs must be written in alphabetical order of vendor string. This patch illustrate this rule. And, finally, run make in /usr/src/sys/dev/usb directory for updating usbdevs.h and usbdevs_data.h files.

Result
Now you can build new kernel. Reboot, attach the device and run dmesg. Here is what you finally got:
ubt0 at uhub2 port 2 configuration 1 interface 0
ubt0: Integrated System Solution Corp. KY-BT100, rev 1.10/3.73, addr 2

1 comment:

Anonymous said...

Nice tutorial, thanks :)

Dusan