[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: How do I allow automatic non root access to my non standard USB device ?



Linuxguy123 wrote:
> I'm doing some embedded development and my flash programmer has a USB
> interface.  Everything works fine if I program the device as root, but
> I'd like to be able to do it as a regular user.  I get port permission
> errors if I try to run the programmer as a regular user.
> 
> $ lsusb
> Bus 002 Device 003: ID 064e:a101 Suyin Corp. Laptop integrated WebCam
> Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> Bus 007 Device 006: ID 15ba:0003 Olimex Ltd. OpenOCD JTAG
> Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
> Bus 006 Device 002: ID 046d:c512 Logitech, Inc. LX-700 Cordless Desktop
> Receiver
> Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
> Bus 005 Device 004: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial
> Port
> Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
> Bus 001 Device 004: ID 07ca:a321 AVerMedia Technologies, Inc.
> Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
> Bus 003 Device 003: ID 03f0:171d Hewlett-Packard Wireless (Bluetooth +
> WLAN) Interface [Integrated Module]
> Bus 003 Device 002: ID 08ff:2580 AuthenTec, Inc. AES2501 Fingerprint
> Sensor
> Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
> 
> 
> My programmer is the Olimex Ltd. OpenOCD JTAG device on bus 7.
> 
> The documentation for the device says it needs access to /proc/bus/usb.
> 
> I can allow regular user access by manually issuing a chown command for
> the port, but then I'd have to do it every time I reboot or unplug the
> programmer.   How do I set it up to happen automatically in F10 ?
> 
> Thanks !
> 
One way is to create a udev rule that sets the permission for the
device. You may also want to create a symlink to a consistant device
name at the same time.

If there isn't a device created for it, it gets a bit more
interesting. I have a small script that I call from the udev rule
that sets the permissions for the specific device in /proc/bus/usb.
I actually wrote it for use with VirtualBox, but it should work for you.

====================================================

# Rules for VirtualBox USB devices.

ACTION!="add",SUBSYSTEM!="usb", GOTO="vbox_rules_end"

# eBookwise eBook reader.
ATTR{idVendor}=="0993", ATTR{idProduct}=="0002",
run="/lib/udev/set-usb-group %s{uevent}"

LABEL="vbox_rules_end"

====================================================

#! /bin/sh
ret=false
if [ "$DEVICE" != "" ]; then
 if [ -e $DEVICE ]; then
  chgrp vboxusers $DEVICE && \
  chmod g+rw $DEVICE && \
  logger udev/set-usb-group: $(ls -l $DEVICE)
    ret=true
 fi
fi

====================================================

The group is hard coded in the script, and it only give group
permissions, but that is easy to change. One of these days I will
get around to cleaning it up, and let it get the
user/group/permissions as input.

Mikkel
-- 

  Do not meddle in the affairs of dragons,
for thou art crunchy and taste good with Ketchup!

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]