All current PIC32 chips are programmed with low voltages (3V3) and via state machines,
so no damage is done if it fails (provided you didn't connect any higher voltages or
negative voltages).

Here's how to use a Raspberry Pi (RPi) to program a PIC32.

1. plan that your target PIC32 board will be powered (not from the RPi)
2. connect from RPi GPIO pins (P1 on the board) to your target's ICSP:
   GND to GND, GPIO 4 to RESET (MCLR/), GPIO 7 to PGC, GPIO 8 to PGD
   (do not connect 3V3 or - if using an ICSP connector - PGM i.e. pin 6)
3. plug boards in (to USB / power) and boot RPi into Linux (I used Raspbian)
4. open shell window (such as konsole)
5. become root or run as root
6. run rpipic32 with -h
    i.e. type in
        ./rpipic32 -h		if you put the files in the current directory
    or
    	sudo ./rpipic32 -h	if you're not root
    and press Enter
    (Depending on how your PATH is set you can leave off the "./")
7. normally you want to Erase your PIC32 so use
        rpipic32 -e
    (you can interrupt it with ^C (Control+C) as soon as the Erase finishes if you want)
8. to flash your chip it's best to use -v (verify) like this:
        ./rpipic32 -v file.hex
    where file.hex is the HEX file you want programming in to your PIC32
    You can combine with -e like this:
        ./rpipic32 -e -v file.hex
9. if it fails but got part way through the programming, try this command:
        rpipic32 -R -v file.hex
    as it generally skips the correct parts fairly quickly then resumes

Failures are usually obvious, such as endlessly printing
    (something, such as XferInstruction) cv = 0
Just abort it and try it again.

Note: rpipic32 is a bit chatty still - just ignore the output unless you get any errors.

Some examples:

./rpipic32 -h			show help

./rpipic32 -e -v micromite.hex	erase, verify during programming, file micromite.hex

./rpipic32 -e -v boot.hex	erase, then program boot.hex, verifying as it goes
./rpipic32 prog.hex		don't erase, don't verify, proram prog.hex
	(those two are a way to program boot.hex & prog.hex if they're separate files)

Although you can use -t try not to.  The program knows all the current PIC32s.  If it
reports the wrong DEVID (IDCODE) it is almost certain to be a sign of bad wiring or
some such.

