Hi Edward,
Thank you for your opinion and ideas.
You are right, the MCU reset is not a solution of P-Flash or EEPROM ECC issue itself. It is just one of the ways how to leave machine exception “ISR”.
You are right, the flash controller does not have a specific command for checking integrity by ECC without machine exception. The ECC checksum is automatically checked during Flash/EEPROM reading and also during some of Flash/EEPROM commands (signalized by FSTAT.MGSTATx bits).
As you correctly mentioned, the proper code should register somehow EEPROM address. I used EEPROM_Read_Byte()/EEPROM_Read_Word() functions in my example code, which fulfil this condition (address is function parameter). In case of any issue, the volatile/static keywords may be used for registering specific memory area for this variable by compiler/linker.
The example code does not solve data recovery itself. The erase fault EEPROM word is one of the ways how to “solve” EEPROM ECC issue. The ECC issue solution is strongly application dependent, therefore I didn’t conclude it into example code. In some cases, the variable erase may be enough, sometimes the recovery from backup may be the correct way, in other cases just report of critical fault without repair attempt is the best solution. It strongly depends on application requirements.
Yes, I agree that triggering of machine exception configurable on/off for each ECC protected resource may be a good feature, however, I am not sure whether it fits original MCU security requirements. Anyway, thank you for a good idea.
The FERSTAT.DFDF is Double Bit Fault Detect Flag. I guess that you rather mean FCNFG.FDFD Force Double Bit Fault Detect. When FDFD is set, any Flash array read operation will force the DFDF flag in the FERSTAT register to be set, but it will not cause machine exception. Forcing the DFDF status bit by setting FDFD has effect only on the DFDF status bit value and does not result in an invalid access. Since, the double bit ECC issue is only one of possible machine exception sources, the FERSTAT.DFDF is not useless.
Since it is already some time when I play with this area, I will have to check your concerns about FERSTAT.DFDF bit on hardware. Could you please provide more details related to this topic?
Best regards
Radek