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.

It is also possible to build Piklab under FreeBSD.

PICStart+ works under FreeBSD with picp.

Wisp628 works under FreeBSD with xwisp2.

JALv2 works under FreeBSD as well.

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 ( 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.

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];
+ }

@@ -759,10 +762,6 @@
return (EIO);

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


+ 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;

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

- tr_error:
+ xfer->clearstall_xfer = NULL;

Wednesday, May 16, 2007

Microchip PIC MCU Development Tools under Linux

I've collected some links about PIC MCU Development Tools under Linux.

1. MPLAB under Linux with Wine (my mini-howto):

2. PICkit 2 under Linux
pk2 by Jeff Post:
pyk by Mark Rages: search pyk
piklab by Nicolas Hadacek:

3. MPLAB ICD 2 under Linux

4. PICStart+ under Linux
PICP by Jeff Post:

5. PICDEM FS USB related project
1) PICDEM FS USB bootloader for Linux using libusb
2)PICDEM FS USB demo appliation under Linux using libusb

6. PICkit 1 under Linux

7. Basic tools: gputils assembler/linker, gpsim simulator and sdcc C compiler

SEEVAL32 EEPROM programmer

My blog is born today: 16-May-2007!

Today I borrowed a Microchip SEEVAL 32 Serial EEProm Designer Kit from local Microchip. The kit seems quite neat. The cost is US$99.

The URL for SEEVAL is at

I am a big fan of Microchip PICKit 2 USB programmer and I am an active member of the pickit-devel Google group. Technically speaking, PICkit 2 ( should be able to support EEProm programming as well. Hopefully they can add the support soon.