The PIC is a family of microcontrollers developed by Microchip. On this page we will focus on the PIC18F4550 which is a microcontroller with USB support. Back in 2007 I did a lot of work on this, but due to lack of time I was forced to put it aside for a while, until now. In the meantime the development software has changed a bit, as well as the Linux distributions, so we will be going back to square one, which is a good opportunity for newcomers to join in.

First you need the microcontroller itself of course, and you need a programmer in order to program the microcontroller. You can build a programmer for yourself, as I did back then. However nowadays it is not really worth the effort as you can buy the Pickit 2 programmer for under 50 euro's, and it is often more reliable than a low cost self made programmer.

Installing the software for the Pickit 2 programmer

We will install and use pk2cmd which allows you to control your Pickit 2 programmer:

install the package libusb-dev:

aptitude install libusb-dev

download the source of pk2cmd from http://www.microchip.com/pickit2. The software is nearly at the bottom of the page, section "Linux & Mac OS X software (Unsupported)".

According to the readme file, the dat file should be copied to /usr/share/pk2 instead, and that directory should be added to your PATH, but the solution above also works, and it is less dirty IMHO.

Now connect your Pickit 2 and verify it is working by using this command:

pk2cmd '-S#'

The required firmware version on the Pickit 2 is v2.32.00 or later, so if an earlier version is reported, it is time to upgrade the firmware:

download the firmware v2.32 from the website

unzip it:

unzip PK2V023200.zip

flash the hex file:

pk2cmd -DPK2V023200.hex

check if it worked:

pk2cmd '-S#'

If the firmware version reported is 2.32.00 or higher then you are okay.

Here is a list of commands commonly used:

pk2cmd '-S#'

list all connected Pickit 2 devices and their firmware version

pk2cmd -Dfile

replace the firmware by the contents of the specified file

pk2cmd -Ppart -R -T

power on the target, part is for example PIC18F4550. The -R option is needed to release the Vpp line, which is also the MCLR (reset) on many PIC's.

pk2cmd -Ppart -W

power off the target

pk2cmd -Ppart -Ffile -M

program the target using specified file

Connecting the programmer to the microcontroller

The pinout of the Pickit 2 is:

1

Vpp (programming voltage)

2

Vdd (target power, often 5V)

3

Vss (Gnd)

4

PGD (program data)

5

PGC (program clock)

6

Aux (not used)

To connect the Pickit 2 to the PIC18F4550:

Pickit 2

PIC18F4550

Optional, if PIC is programmed in application circuit

1

1

pullup 10k to +5V

2

11+32

do not make this connection if using external power

3

12+31

4

40

10k series resistor to application circuit

5

39

10k series resistor to application circuit

6

n.c.

It is possible to use the Pickit 2 programmer as (limited) power supply for your application circuit.

Getting and building PUF

The latest release of PUF is at the time of writing from 2007, so you are probably better of using the nightly CVS snapshot which you can find here: http://gforge.enseeiht.fr/snapshots.php?group_id=10. To build, first install flex and bison, extract PUF, cd to it, then do the following: