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

libusb Project Now Has a Website

http://libusb.org/

Announcement from Daniel Drake, the current lead developer of libusb project.

On Fri, Jul 31, 2009 at 12:27 AM, Daniel Drake wrote:
> Hi,
>
> Peter Stuge (our git host) kindly purchased www.libusb.org and set up a
> trac instance there for us. It is even nicely linked to git :)
>
> I just moved the wiki and open bugs over to there, and disabled the
> corresponding features on sourceforge. Actually, sourceforge today is
> closing down its wiki service so it is a good time to move :)
>
> Wiki editing is now public until we get spammed -- at that point we'll
> limit it to people that ask for access.
>
> sf.net/projects/libusb remains active for hosting of API docs, mailing
> list, and downloads.
>
> Thanks Peter!
> Daniel
>

Sunday, July 5, 2009

OpenOCD -- a promissing project

Project website:
http://openocd.berlios.de/web/
http://developer.berlios.de/projects/openocd

Mailing list archive
https://lists.berlios.de/pipermail/openocd-development/

Forum
http://forum.sparkfun.com/viewforum.php?f=18

I started to really trying it out (with J-Link) this May. It has really progressed very fast. Before that, it did not work at all with J-Link V3. Now I can use J-Link (V3, V6 and V7) with several targets I have (STM3210E-Eval, TMS470R1A256, ADuC7060 and LPC-2148) under Linux (and Windows). I am still in the process of learning to use OpenOCD but I can see it as a very promissing project.

V0.2 is slated to be released any time now.

In the future, I would like to see a more stable J-Link driver.

On the other front, right now it used libusb 0.1 and libusb-win32 0.1 and synchronous USB I/O. In the future, maybe it can be switched to libusb 1.0 under Linux and Mac OS X and use asynchronous USB I/O to boost the performance.

For FTDI2232x based JTAG debuggers, right now it uses either FTD2XX (proprietory) or libftdi+libusb 0.1. Hopefully the features of libftdi can be improved to match the performance of FTD2xx, especailly under Windows. The situation is rather complicated under Windows due to the fact that libftdi uses libusb-win32 and libusb-win32 does not work under Vista 64 right now. Maybe WinUSB is a better solution (for XP/Vista and later).