divendres, 4 de març del 2011

Enabling USB access for VirtualBox, and/or general libusb clients

Tipically, usb devices get a /dev node created automatically (provided you're on a recent Linux version) by udev system, with only root priviledges, so your applications have very limited raw access to them. This is ok if you have a driver, but when your application needs libusb access, this is a different matter.
Solution is quite easy: just ask udev to create specific nodes with your group access rights. Simpler way to do so is to create an udev rules file in /etc/udev/rules that instructs to set group to your own (instead of root).
For this example, we're about to make PicKit2 USB programmer to be accessible by its application (pk2cmd in this case), and also to VirtualBox running the Windows equivalent.
We go to /etc/udev/rules and create a file called 90-pickit2.rules (name is not very important, provided it doesn't overlap with another one, the initial number sets some sort of order upon load). File content could be something like this:

# Rules to make PicKit2 node readable and writable by users group

# Microchip 04d8, product 0033
ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="0033", GROUP="users"

Note that 04d8 is device manufacturer (you should use your own, in this case this is Microchip) and 0033 is product ID for such manufacturer (0033=PicKit2). We want that the node created when such device is plugged in belongs to group users, so we have RW access to it.
After that, simply plug in your device, and must appear on your application with no more troubles (provided you already installed it:-)

Cap comentari:

Publica un comentari a l'entrada