Re: EZBL OTA for PIC24 without dual-partitions
I will answer my own question in case anyone else has this problem. I found a method that works for OTA updates or serial updates without BL2 protocol handshaking. I can just load a bl2 file into program memory, check it entirely to see it's OK, then perform the update from the bootloader.
I was going to use the fileio library so I could use EZBL_InstallFILEIO2Flash, it checks and installs a firmware update stored on a USB drive, but the FILEIO library was too large. It was also unnecessary because I didn't need FAT compatibility, I only needed to store a single bl2 file in program memory before an update. Instead, I made a copy of EZBL_InstallFILEIO2Flash() called it EZBL_InstallFlash2Flash(), and replaced FILEIO_Read()'s with a wrapper function that does the same thing with EZBL_ReadPackedFlash(). EZBL_InstallFlash2Flash() parameters are just the bl2 file program memory address and the commit value.
I use EZBL_WriteROM() in my application to place the bl2 file in program memory. I use EZBL_AllocFlashHole() in the application to reserve space in program memory that will not be erased by the bootloader during the update. I'm not sure if that's the best way to reserve the space but it is working.
After the file is downloaded, I perform the update by setting a flag and calling the bootloader task. It checks the flag and calls the new function commit=0 to check the file and again with commit =1 to perform the update if it checks out.
It also works with the serial port, I don't need any handshaking, at least at 115200, I can just binary send the file over serial with the bootloader task disabled, EZBL_WriteROM() keeps up with the UART but I haven't tested any higher rates. I'm currently letting the application control the download this way, it recognizes the header, writes the received data to program memory. I might move some of that functionality into the bootloader.