The bootloader is working now, I got help compiling the update app and successfully modified it. Attached is a complete toolchain for the PUMP.
The 2550 chips have a 32byte write page size, but the 24j50 has a 64byte page size. USB HID packets are limited to 64bytes, so there's no way to pack the header and data into a single packet. I started an alternating packet protocol, but instead used the 2byte write size available on the 24j50 chips. This is a MUCH slower way to update, we transfer 64bytes for each 2bytes programmed, but it works and can be improved upon later.
I used a reserved byte in the write packet to signal that the PIC should write the current data to FLASH, previously it happened at the end of every packet. This will make it possible to send 64bytes over 2 packets and not save until a flush is flagged in the second packet. This will require further modifying the application software, but no further bootloader changes should be needed.
I also updated everything to give a version number with the pump-loader utility (hardware, firmware, bootloader), and added a command to jump to the bootloader from the rom update mode (no jumper required).
Changes follow
----------------------------------
Bootloader firmware:
*adapted to write 2 bytes at a time.
*removed auto-write at end of packet, now uses reserved byte to signal flush (flush when reserved byte !=0)
*added version number constant at 0x7fe
*added new jump entry point
Bootloader app:
*adapted to send 2 bytes at a time
*sends 0xff as the reserve byte to flush on every packet.
*created multiple .bat files to ease operations
ROM updater (main firmware):
* Added version string command, read firmware version constant
* Added jump to bootloader command (no jumper needed, thus no header required on production models)
* Added support in pump-loader.pl script.
This is the current command protocol for the rom update mode, as documented in pump-loader.pl:
# Protocol:
# 00 00 00 00 - get PUMP hardware/firmware/bootloader string (return 7bytes)
# 01 00 00 00 - get 4 byte JDEC ID (returns 4 bytes)
# 02 XX YY 00 + 264 data bytes + CRC - XX=page (upper 4 bits XXXXA987) YY=page (lower 7 bits = 6543210X), CRC = 2s compliment, (returns 1 when done, 0 for CRC error)
# 03 XX YY 00 - XX=page (upper 4 bits XXXXA987) YY=page (lower 7 bits = 6543210X), (returns 264 bytes, 1 page)
# 04 00 00 00 - erase chip (returns 1 on completion, takes up to 6 seconds)
# 05 00 00 00 - get status byte (returns 1 byte)
# $ $ $ $ - jump to bootloader