pk2cmd linux port under FreeBSD

21 views
Skip to first unread message

Xiaofan Chen

unread,
Nov 1, 2007, 8:17:50 AM11/1/07
to pickit-devel
I have tried pk2cmd linux port under FreeBSD. It is not working with the stock
USB stack (was using 6.2 stable and now 7.0 beta). I need to get the
new alternative USB Stack from Hans Petter Selasky (HPS).

To get the HPS USB stack for FreeBSD, follow the following instruction.

svn --username anonsvn --password anonsvn checkout svn://svn.turbocat.net/i4b
cd i4b/trunk/i4b/FreeBSD.usb
make S=../src package
make install
Follow the "make help" instructions.

One patch required is the file "ugen.c". In the function
"ugen_open_pipe_read()",
find the line "case UE_INTERRUPT:" and then some lines further down
you will find:
/* first transfer clears stall */
sce->read_stall = 1; //---> Chaneg this to "0".
Then recompile and install the "ugen" module and/or kernel.

PICkit 2 with FreeBSD (old):
http://lists.freebsd.org/pipermail/freebsd-usb/2007-April/003177.html

PICkit 2 with FreeBSD (new):
http://lists.freebsd.org/pipermail/freebsd-usb/2007-October/004057.html

Sample running session:
===[mcuee] ~/Desktop/build/pk2cmd4bsd # uname -a
FreeBSD FreeBsd.Mshome 7.0-BETA1 FreeBSD 7.0-BETA1 #2: Thu Nov 1
19:56:07 SGT 2007
ro...@FreeBsd.Mshome:/home/obj/home/src/sys/USBDEBUG i386
===[mcuee] ~/Desktop/build/pk2cmd4bsd # sudo ./pk2cmd -PPIC12F675 -I

Locating USB Microchip PICkit2 (vendor 0x04d8/product 0x0033)
Found USB PICkit as device '/dev/ugen0' on USB bus /dev/usb1
Communication established. PICkit2 firmware version is 2.10.0

Device ID = 0FC3

Operation Succeeded
===[mcuee] ~/Desktop/build/pk2cmd4bsd # sudo ./pk2cmd -PPIC12F675 -GF12F675.hex

Locating USB Microchip PICkit2 (vendor 0x04d8/product 0x0033)
Found USB PICkit as device '/dev/ugen0' on USB bus /dev/usb1
Communication established. PICkit2 firmware version is 2.10.0

Read successfully.

Operation Succeeded
===[mcuee] ~/Desktop/build/pk2cmd4bsd # sudo ./pk2cmd -PPIC12F675 -Y
-F12F675.hex

Locating USB Microchip PICkit2 (vendor 0x04d8/product 0x0033)
Found USB PICkit as device '/dev/ugen0' on USB bus /dev/usb1
Communication established. PICkit2 firmware version is 2.10.0

PICkit 2 Verify Report
1-11-2007, 20:04:10
Device Type: PIC12F675

Verify Succeeded.

Operation Succeeded

Jeff

unread,
Nov 1, 2007, 9:35:47 AM11/1/07
to pickit...@googlegroups.com
On Thu November 1 2007 05:17, Xiaofan Chen wrote:
>
> ro...@FreeBsd.Mshome:/home/obj/home/src/sys/USBDEBUG i386
> ===[mcuee] ~/Desktop/build/pk2cmd4bsd # sudo ./pk2cmd -PPIC12F675 -I
>
Why do you need to run as root?

Jeff

Xiaofan Chen

unread,
Nov 1, 2007, 9:38:01 AM11/1/07
to pickit...@googlegroups.com

I have not yet setup the udev rules under FreeBSD. I will do it later now
that I just cleared a bit of the mess after updating to FreeBSD 7.0 Beta.

Xiaofan

Xiaofan Chen

unread,
Nov 1, 2007, 11:05:13 AM11/1/07
to pickit...@googlegroups.com
On 11/1/07, Xiaofan Chen <xiao...@gmail.com> wrote:
> On 11/1/07, Jeff <j_p...@pacbell.net> wrote:
> >
> > On Thu November 1 2007 05:17, Xiaofan Chen wrote:
> > >
> > > ro...@FreeBsd.Mshome:/home/obj/home/src/sys/USBDEBUG i386
> > > ===[mcuee] ~/Desktop/build/pk2cmd4bsd # sudo ./pk2cmd -PPIC12F675 -I
> > >
> > Why do you need to run as root?

Thanks for asking.

>
> I have not yet setup the udev rules under FreeBSD. I will do it later
> now that I just cleared a bit of the mess after updating to FreeBSD 7.0 Beta.
>

Done. And I found a great resources about Linux/BSD USB device rules.
I also learned that there is no udev under FreeBSD. It is called devfs rules.

http://www.gphoto.org/doc/manual/permissions-usb.html

Steps:
1. Create group "usb" and add the user name to it.
2. Edit /etc/devfs.rules to add the following lines.
[usb_devices=10]
add path 'ugen*' mode 0660 group usb
add path 'da*s*' mode 0660 group usb
3. Edit /etc/devfs.conf and add following lines: [Confirmed that this
is necessary]
perm usb0 0660
own usb0 root:usb
perm usb1 0660
own usb1 root:usb
4. Edit /etc/rc.conf and add the following lines:
# Set the default devfs ruleset.
devfs_system_ruleset="usb_devices"
5. Activate the changes by running the following command (no reboot required):
host:~# /etc/rc.d/devfs start

6. Testing:
===[mcuee] ~/Desktop/build/pk2cmd4bsd # ls -la /dev/ugen0*
crw-rw---- 1 root usb 0, 138 Nov 1 22:31 /dev/ugen0
crw-rw---- 1 root usb 0, 120 Nov 1 22:56 /dev/ugen0

===[mcuee] ~/Desktop/build/pk2cmd4bsd # ./pk2cmd -PPIC12F675 -I

Locating USB Microchip PICkit2 (vendor 0x04d8/product 0x0033)
Found USB PICkit as device '/dev/ugen0' on USB bus /dev/usb1
Communication established. PICkit2 firmware version is 2.10.0

Device ID = 0FC3

Operation Succeeded


Regards,
Xiaofan

Reply all
Reply to author
Forward
0 new messages