We are using s32K324 and RTD S32K3_RTD_2_0_0_D2203_ASR_REL_4_4_REV_0000_20220331
I have an Flash update routine that uses C40_Ip_MainInterfaceSectorErase and C40_Ip_MainInterfaceWrite to put data at an explicit location in memory (linker is set for a/b boot swap), and a Fee interface (eeprom emulation) to store persistent data.
I have a If no writes are done to the Fee interface (only reads), The Flash update routine works fine. If a Fee write is done (complete), and then the Flash update is done a the flash fails to write.
1) C40_Ip_pFlashBaseAddress->MCRS volatile uint32_t is 0xc100 (Hex) after Fee write before update is started.
2) C40_Ip_MainInterfaceSectorErase is called Flash is erased and C40_Ip_pFlashBaseAddress->MCRS volatile uint32_t 0x8100 (Hex). The data appears to have been erased. MCR is 0.
3) C40_Ip_MainInterfaceWrite is called for writing the update and it fails on the first access. C40_Ip_pFlashBaseAddress->MCRS volatile uint32_t is still 0x8100, and it fails in C40_Ip_MainInterfaceHVJobStatus FLASH_MCRS_PEG_MASK != ErrorFlags.
So, the erase was "done" and competed for the range, confirmed with flash dump. It appears to be successful though the MCRS is 0x8100 instead of 0xC100. That state remains through the write sequence (unlock passes) and fails on step 3 above.
What am I missing to check/clear after the flash erase?