Hi Roy:
I've been fighting with this as well: I wanted to point out that even after running the FW through srec_cat or using the obj-copy --srec-len command we still ran into an issue where the last record could still be 4 or 12 byte aligned as the firmware wasn't evenly divisible by 8 bytes and the last write could fail. I ended up having to add padding functionality in the mem_man.c mem_man_write() function.
AFAIK this works right, but I'm experiencing some inconsistency issues that I'm still debugging.
I also added checks of the return value of the FlashProgram() and added in a call to FlashProgramCheck() to verify that the data actually got written correctly. NXP in their rush to get something to "work" and keep it "small" really skimped on the error handling and it has bitten us hard.
/* Check alignment and pad if needed.
* S32 Flash Program takes 8 byte phrases. Misalligned bytes will result in a failed write.
*/
uint16_t sizeMod = data_size % 8;
if(0 != sizeMod){
/* set remaining bytes of array to 0xFF (default erased value)
* extend data_size to match new length.
*/
sizeMod = data_size + (8 - sizeMod); /* Generate new size */
memset((void *) (BP->F.PhraseData + data_size), 0xFF, MAX_DATA_BP - data_size);
data_size = sizeMod;
}