Friday, July 31, 2009

Piklab Wiki Page USB Port Permission Archive

The following content was originally from Piklab Wiki page. But Sourceforge has retired the Wiki.
The URL was: http://piklab.wiki.sourceforge.net/USB+Port+Problems
The following is the text version.

You need to have read and write access to the port (serial, parallel or USB).
Some distributions do not grant read/write access to regular users by default.
Some additional information written by Linus Walleij regarding interaction
between "libusb" and "udev"/"hotplug" is provided here.
http://piklab.sf.net/files/libusb_udev_hotplug.txt


For distributions using "hotplug" (Fedora Core 4, Ubuntu 5,...)
The following procedure may be used, to be able to connect to the ICD2/Pickit programmers
as a regular user on those distributions, using hotplug [thanks to Xiaofan Chen]:

* Add the following to /etc/hotplug/usb.usermap:

pickit 0x0003 0x04d8 0x0032 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000
pickit2 0x0003 0x04d8 0x0033 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000
icd2 0x0003 0x04d8 0x8000 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000
icd21 0x0003 0x04d8 0x8001 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000

* Add hotplug scripts "pickit", "pickit2", "icd2", "icd21" in /etc/hotplug:

#!/bin/bash
if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
then
echo "changing ${DEVICE}" >> /tmp/debug-hotplug
chown root "${DEVICE}"
chgrp microchip "${DEVICE}"
chmod 660 "${DEVICE}"
fi

* Create group "microchip" and add your username to this group.


For distributions using "udev" (Debian Sid, Ubuntu 6,7,8,...)
The following procedure may be used to be able to connect to the ICD2/Pickit programmers
as a regular user on distributions using udev [thanks to David Williams]:

* Create file /etc/udev/rules.d/026_microchip.rules:

#PICKit
SYSFS{idVendor}=="04d8", SYSFS{idProduct}=="0032", MODE="0660", GROUP="microchip"
#PICKit2
SYSFS{idVendor}=="04d8", SYSFS{idProduct}=="0033", MODE="0660", GROUP="microchip"
#ICD2
SYSFS{idVendor}=="04d8", SYSFS{idProduct}=="8000", MODE="0660", GROUP="microchip"
#ICD21
SYSFS{idVendor}=="04d8", SYSFS{idProduct}=="8001", MODE="0660", GROUP="microchip"

* Create a group named "microchip" and add your username to this group:

sudo addgroup microchip
(Note: for Arch Linux, it is "groupadd".)
sudo gpasswd -a your_user_name microchip


Similarly for Suse/OpenSuse and Arch Linux and newer version of Ubuntu
http://usbpicprog.org/?page_id=13
[Thanks to Robert Currie]

#PICKit 1
ATTR{idVendor}=="04d8", ATTR{idProduct}=="0032", OWNER:="root", GROUP:="microchip",MODE:="0660"
#PICKit 2
ATTR{idVendor}=="04d8", ATTR{idProduct}=="0033", OWNER:="root", GROUP:="microchip",MODE:="0660"
#ICD2
ATTR{idVendor}=="04d8", ATTR{idProduct}=="8000", OWNER:="root", GROUP:="microchip",MODE:="0660"
#ICD21
ATTR{idVendor}=="04d8", ATTR{idProduct}=="8001", OWNER:="root", GROUP:="microchip",MODE:="0660"
#PICDEM FS USB Bootloader
ATTR{idVendor}=="04d8", ATTR{idProduct}=="000b", OWNER:="root", GROUP:="microchip",MODE:="0660"


For distributions using "PolicyKit" (Fedora 9,10,...)
The following procedure may be used to be able to connect to the ICD2/Pickit programmers
as a regular user on distributions using udev [thanks to Xiaofan Chen]:

* Create file /usr/share/hal/fdi/policy/10osvendor/10-microchip.fdi

http://groups.google.com/group/pickit-devel/browse_thread/thread/86c67b83202815cf?pli=1


* Create a group named "microchip" and add your username to this group.

For distributions using "udev" and PAM (Fedora Core 5/6,...)
The following procedure may be used to be able to connect to the ICD2/Pickit programmers
as a regular user on distribution using udev [thanks to Linus Walleij]:

* Create file /etc/udev/rules.d/026-microchip.rules:

#PICKit
SUBSYSTEM=="usb_device", ACTION=="add", SYSFS{idVendor}=="04d8", SYSFS{idProduct}=="0032", SYMLINK+="pickit1-%k"
#PICKit2
SUBSYSTEM=="usb_device", ACTION=="add", SYSFS{idVendor}=="04d8", SYSFS{idProduct}=="0033", SYMLINK+="pickit2-%k"
#ICD2
SUBSYSTEM=="usb_device", ACTION=="add", SYSFS{idVendor}=="04d8", SYSFS{idProduct}=="8000", SYMLINK+="icd2-%k"
#ICD21
SUBSYSTEM=="usb_device", ACTION=="add", SYSFS{idVendor}=="04d8", SYSFS{idProduct}=="8001", SYMLINK+="icd2-%k"

* Create file /etc/security/console.perms.d/pickit2.perms (and similar files for the other devices):

=/dev/pickit2*
0600 0600 root

3 comments:

Douglas said...

Hi,

First of all, congrats for your work.

I'm working to develop my own programmer based on fsusb (do you still remember it?). I'm using Microchip bootload so PUF will not work for me.

There is a few parts of the new code you posted on Microchip forum that is missing. Like fsusb.h and bootload.h

Could you please forward the last source code you have to my email address?

THanks,
Douglas

Xiaofan said...

I see. The original website is now down. It was here last time.
http://www.internetking.org/fsusb/

I will post the original code in the Microchip forum thread.
http://www.microchip.com/forums/tm.aspx?m=106426

Xiaofan said...

I have just posted the zip archives.