Latest version now reads, parses, and programs a .hex file. with --verbose it shows all data and the address it is programmed at. This looks fine, but the actual data dumped from the PIC is of by bytes or pages after the first few pages.
I left the hex parser and sendfirmware routines in a bit of a mess. They had to be converted from the 3byte (4 byte?) words of the 24FJ bootloader to the 2byte words of the 18F. Eventually they will both need to be made adjustable/universal so that it can parse HEX files with different lengths (all this needs to be stored in a struct or XML file somewhere).
It does it really fast, and without entering and exiting ICSP on every write like the .net programmer. I think that is due to the new commands that read/write 20bit commands directly, instead of tiny chunks. It's much, much faster.
XX00YYYY
XX=delay, 0=none, 1=1ms, 10=2ms, 11=3ms
YYYY=4bit command (second byte of PIC programmer write command)
Also added a delay option to the PIC write command. the upper two unused bits of the 4/6bit command byte give a delay in ms. If it is >0, the last clock bit of the command will be held for 1, 2, or 3 MS. The 18F24J50 needs 1.2ms (1 seems ok), lower parts in that family need 3ms, we might need to adjust the values depending on future families. A nightly with this change is in the piratePICprog folder.
Changes:
*load and parse HEX seems to work
*passes HEX to write, address seems off
*only enters ICSP once, not on every page
*updated hex parser for 16bit data
To do:
*Clean HEX parser, make it universal/configurable (different PIC word lengths/page size/flash length in variables instead of defines)
*Make sendFirmware function adjustable, configurable (page size, pic flash length)
*Fix addressing issue that writes to wrong address in PIC flash
*Massive code cleanup (move functions to other files)
*Better read with timeout (smaller delay?), binmode entry
*Enable options - --id --e(rase) --pic:18F24J50 --r(ead):dump.hex
*Add read??
*search through .HEX and mark 0xff pages unused.
*Determine a structure to store the various PIC constants: (see update in the post below)
E:\Work\dp-svn\trunk\PiratePICprog>gcc piratePICprog.c -o piratePICprog.exe
E:\Work\dp-svn\trunk\PiratePICprog>piratePICprog --dev=COM3 --hex=pump.hex --verbose
+++++++++++++++++++++++++++++++++++++++++++
piratePICprog for the Bus Pirate
Loader version: 1.0.2 OS: WINDOWS
+++++++++++++++++++++++++++++++++++++++++++
Parsing HEX file [pump.hex]
Found 1040 words (3120 bytes)
Opening serial device COM3...OK
Configuring serial port settings...OK
Entering binary mode...BBIO1(OK)
Entering rawwire mode...RAW1(OK)
Setup mode...(OK)
Setup peripherals...(OK)
Entering ICSP...
Set mode for MCLR (MSB)...(OK)
Set mode for PIC programming (LSB)...(OK)
PIC ID: 0X260 (18F24J50) REV: 0X2
Erasing the PIC (please wait)...(OK)
Exit ICSP...
Entering ICSP...
Set mode for MCLR (MSB)...(OK)
Set mode for PIC programming (LSB)...(OK)
Writing page 0, 0000...
F8 6A F7 6A 03 D0 00 00 04 EF 04 F0 75 D2 FF FF FF FF FF FF FF FF A1 D0 0C EF 04
F0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F
F FF FF 12 01 00 02 00 00 00 40
Writing page 1, 0040...
D8 04 90 FC 22 00 01 02 00 01 09 02 22 00 01 01 00 80 32 09 04 00 00 01 03 00 00
00 09 21 01 01 00 01 22 17 00 07 05 81 03 40 00 01 05 0C 09 00 A1 02 09 00 95 4
0 75 08 81 00 09 00 95 40 75 08
Writing page 2, 0080...
91 00 C0 04 03 09 04 0E 03 44 00 69 00 6F 00 6C 00 61 00 6E 00 FF 08 0E 81 51 80
6B 7F D8 0D 0E 83 6F A6 88 84 D8 04 0E F7 26 83 2F FA D7 12 00 72 D8 00 EE C4 F
0 09 00 F5 CF EE FF 60 2F FB D7
^CTerminate batch job (Y/N)?