Friday, May 18, 2007

PIC Development Tools under FreeBSD

I am mainly a Linux user and Ubuntu is my preferred distribution. However from time to time I will also try other Linux distributions and FreeBSD.

Right now I have a small installation of FreeBSD 6 Stable. It is not as easy to use as Linux but it is definitely usable. The following is a list of links for PIC MCU development tools under FreeBSD.

FreeBSD has ports for gputils/sdcc/gpsim/picp/pikdev.
http://www.freebsd.org/ports/

It is also possible to build Piklab under FreeBSD.
http://piklab.sourceforge.net/wiki/index.php/Compilation_for_FreeBSD

PICStart+ works under FreeBSD with picp.

Wisp628 works under FreeBSD with xwisp2.
http://www.robh.nl/picsoft.php

JALv2 works under FreeBSD as well.
http://www.casadeyork.com/jalv2/
http://www.casadeyork.com/jalv2/jalv21src.zip

The main problem under FreeBSD is the lack of device drivers. But they are catching up. One of the things in development is the alternative USB stack by Hans Petter Selasky (http://www.turbocat.net/~hselasky/usb4bsd/). With his help I am now able to run pk2 and piklab to support PICKit 2 under FreeBSD.

For more detail, please refer to the following mailing list thread.

http://lists.freebsd.org/pipermail/freebsd-usb/2007-April/003182.html

You need to run the alternative USB stack (maybe you will need to use the stable or current branch) and apply the following patch to ugen.c in order to get pk2 to work. Maybe the patch is already in the latest version of the USB stack.

==== ugen.c#12 - ugen.c ====
@@ -637,9 +637,12 @@
{
return (EIO);
}
- /* setup clear stall */
- sce->xfer_out[0]->clearstall_xfer =
- sce->xfer_out[1];
+
+ if ((ed->bmAttributes & UE_XFERTYPE) == UE_BULK) {
+ /* setup clear stall */
+ sce->xfer_out[0]->clearstall_xfer =
+ sce->xfer_out[1];
+ }
break;

case UE_ISOCHRONOUS:
@@ -759,10 +762,6 @@
return (EIO);
}

- /* setup clear stall */
- sce->xfer_in[0]->clearstall_xfer =
- sce->xfer_in[1];
-
usbd_transfer_start(sce->xfer_in[0]);
PRINTFN(5, ("interrupt open done\n"));
break;
@@ -1322,6 +1321,17 @@

USBD_CHECK_STATUS(xfer);

+ tr_error:
+ if (xfer->error != USBD_CANCELLED) {
+ /* setup clear stall */
+ xfer->clearstall_xfer = sce->xfer_out[1];
+
+ /* start clear-stall */
+ usbd_start_hardware(xfer);
+ return;
+ }
+ return;
+
tr_transferred:

PRINTFN(5, ("xfer=%p actlen=%d\n",
@@ -1362,7 +1372,7 @@
return;

tr_setup:
- tr_error:
+ xfer->clearstall_xfer = NULL;
usbd_start_hardware(xfer);
return;
}

No comments: