I'm working on writing to a flash sector using CAN and flash on the s32k144. I have written two different flash drivers at this point, one that writes 8 bytes at a time only if it is 8-byte-aligned; This can be tricky when sending 6 or 7 bytes via CAN at a time. Not terrible but not optimal.
More recently I wrote another flash driver to write an arbitrary number of bytes at any address. It aligns the data itself and writes in 8-byte chunks. In places where the data is not a full 8 bytes (the start or end of an unaligned set of bytes), the driver will read what is currently in flash to fill the 8 byte buffer before writing. This works fine when writing to the 0x5000 sector for example but not in 0x7F000. In the later sector I write 7 bytes at a time at 0x7F000, 0x7F007, and at 0x7F00E. When trying to write to 0x7F00E all 16 bytes from 0x7F000 to 0x7F010 get set to 0x00. Again, this behavior is not consistent everywhere; the same procedure works fine at 0x5000 but not at 0x7F000.
What makes these sectors behave differently?