I have gotten little help from the community and not any communication from the mods at all.
I did get this to work though.
Long story short, there's lots of issues with the generated MCC code.
Any code I talk about below is 100% auto generated using the MCC tool in MPLAB. Follow the instructions in the Unified Bootloader Application documentation found here:
http://www.microchip.com/mymicrochip/filehandler.aspx?ddocname=en573289 If that link above gets broken, that document is found under microchip's bootloader main page:
http://www.microchip.com/promo/unified-bootloaders Here's how I got this to work:
My Setup
I am using a PIC16F1619 with the Curiosity development kit. I was trying to use the generated MCC code to create a bootloader application to work with the Microchip Unified Bootloader Application.
My target app is a simple LED blink application and will be loaded to 0x400 over UART.
Fixing pic16f1_bootload.c
Any flash read code in pic16f1_bootload.c just doesn't work.
Instead, use the FLASH_ReadWord() function found in memory.c .
There seems to be a slight difference between the FLASH_ReadWord() function code and the generated code in pic16f1_bootload.c . I'm not exactly sure what this difference is but nothing I had done was able to get the pic16f1_bootload.c code to work.
I had to replace this code in the Bootload_Required() and Calc_Checksum().
Unified Bootloader Settings
Where the target application is written
The Bootloader Offset and the Program Memory Size setting have nothing to do with where the target application is loaded onto the PIC. Yes, the intel hex files are well documented but it is not clear whether the Unified Bootloader Application settings affect where this hex file is loaded.
These settings are only used during the erase flash and checksum phases of the bootload process.
Bootloader Offset(Address)
Firstly, this is not the bootloader offset. This is the target app location.
The PIC16F1619 is word addressed, while the Unified Bootloader Application is byte addressed. The addressing is talked about in a few small sentences in various manuals. Because of this, the poorly named Bootloader Offset, should be double the target location of the loaded application. Since my target location was 0x400 I had to put in 0x800 in the Unified Bootloader Application Bootloader Offset setting.
Program Memory Size
I could not find helpful documentation of this setting anywhere! Through trial and error I was able to figure it out though. This should be the full size of the PIC memory. Remember this is byte addressed, so it should be double the PIC16F1619's memory size. In my case I had this set to 0x4000.
During the flash erase call the Unified Bootloader Application subtracts the Program Memory size from the Bootloader Offset and then divides this by the erase block size. In my case the erase block size is 32 words or 64 bytes.
During the checksum phase the Unified Bootloader Application again subtracts the Program Memory size from the Bootloader Offset and uses this length to calculate the checksum. The checksum is calculated over the entire region of flash memory between the Bootloader Offset and the end of flash memory. The Unified Bootloader Application builds a copy of the PIC state in local memory and then compares this with the resulting checksum from the PIC.
I hope this helps.