PIC USB Framework

About PUF

PUF is a USB application framework dedicated to Linux (on the host side) and to the PIC 18F4550 family of microcontrollers (on the device side). PUF includes: a bootloader that can flash the PIC application through the USB, a PIC demo and its corresponding application on the host side, and docker, the host-side flash programming utility.

PUF also contains gputils and sdcc as cross-building tools, and odyssey 0.4 vasco as a parallel port PIC programmer.



PUF is licensed under the terms of the LGPL 2.1. docker and demo are licensed under GPL 2.


You can download the current release of PUF, docker and demo at http://gforge.enseeiht.fr/frs/?group_id=10.

Build PUF

PUF is divided into 3 files :

docker and demo depend on libusb >=0.11.

tar xvzf puf-<release #>.tar.gz; cd puf-<release #>; make
will build everything for the device side, including the cross tools. The bootloader is then available as bootloader/bootloader.hex and the demo device application in application/application.hex.

tar xvzf docker-<release #>.tar.gz; cd docker-<release #>;./configure; make
will build docker in the src folder. demo can be built in the same way.



To use PUF, you will need a supported PIC, a PIC test board with a USB-B port, and a PIC programmer to burn the USB bootloader into the PIC. You can build your own parallel port PIC programmer and test board using our GPLed schematics:

Upload the bootloader

Odyssey, once configured for your hardware, can then be used to flash the bootloader with :

odyssey PIC18F4550 write bootloader.hex

Upload an application

You can then program your applications using docker and the bootloader with :

docker write application.hex

To do so, you need either to be root, or to install the stuff which is in the udev folder (provided you use udev, of course ;-) . I prefer this solution : it is never good to develop as root...

Use the demo application

When your device is started, it first toggles the signal on RA0, and stays in a neutral configuration (#1) until it receives a SET_CONFIGURATION request from the host. Configuration ID #2 is associated to the flashing function, and USB configuration ID > 2 are reserved for the application. demo can be used to switch to the application with :

demo -c <configuration ID>

When activated with configuration ID #3, the demo application toggles periodically the pin RA0.

Adapt PUF to your needs

Modify the PUF configuration

The device and the bootloader can be configured in the config.h and config.c files (including the PIC configuration words). USB configuration (including End Point callbacks) can be set up in the usb_descriptor.[ch] files. But it will only be used as long as no application code has been uploaded.

Configure your application

When an application code has been flashed in the PIC, the USB descriptors of the bootloaders are not used anymore : there are replaced by the descriptors of the application code. USB configuration (including End Point callbacks) is set up in the usb_descriptor.[ch] files of the application.

Improve PUF

The puf-<release #>/bootloader/models folder contains 2 or 3 UML2 diagrams describing shortly the bootloader structure. These models can be edited using the UML 2.0 editor of the TOPCASED project (see http://gforge.enseeiht.fr/projects/topcased-mm and http://gforge.enseeiht.fr/projects/topcased-uml2).

Bug reports, feature requests, patchs, remarks, questions are welcome on our mailing list (http://gforge.enseeiht.fr/mail/?group_id=10) and on our trackers (http://gforge.enseeiht.fr/tracker/?group_id=10).

© 2006 Gilles Ballanger & Pierre Gaufillet