Part Number: TMS570LC4357-EP
I have encountered some bug while developing a bootloader. After writing all data to the flash I run a CRC32. But it seems that the first chunk (sixteen 32-bit values) is not updated unless I run the crc32 first but this is too late and results in the wrong crc. If I insert the crc32 twice, the first call gets the flash addresses update and I get the correct crc value from the second call. The application runs perfectly if I jump to it so I know it gets written to flash correctly. I tried running a loop (shown below) and this did work too.
I also noticed section 4.4.9 in the f021 flash API and called the Fapi_flushPipeline() and that didn't affect anything. I also observed the note there to try 2 dummy reads 128 bytes apart from the flash addresses I modified - didn't solve anything either.
I also confirmed that running the code without the debugger resulted in the exact same behavior. So it seems that running the crc32 twice or running the dummy read loop can work but this is just covering the issue.
Any suggestions? Is this a known thing? Is this an ECC, flash, or cache problem?
Shown below are screenshots of how it looks before running a crc32/loop and after.
Before:

After:
// This code inserted before the crc32 did seem to resolve the issue too volatile uint64_t warmup = 0ULL; // ECC warmup variablefor(uint32_t addr = VALID_APP_FLASH_BASE; addr < VALID_APP_FLASH_BASE + APP_FLASH_SIZE_WORDS; addr += 8){ warmup = *(volatile uint64_t*)addr;}

