XMC4400: How to recover from E_EEPROM_XMC4_STATUS_ERROR_OLD_DATA ?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
GoKl_4594211
Employee
Employee
My question is about how to recover from E_EEPROM_XMC4_STATUS_ERROR_OLD_DATA in an application with a XMC4400 microcontroller.

I use the E_EEPROM_XMC4_0 app to store some data in flash, that must remain in memory also after a reboot (it is actually a reboot counter, that must be incremented and stored after each reboot).
E_EEPROM_XMC4_ReadByte( REBOOT_COUNT_OFFSET, &rebootCount ); 
rebootCount ++;
E_EEPROM_XMC4_WriteByte( REBOOT_COUNT_OFFSET, rebootCount );
flashStatus = E_EEPROM_XMC4_UpdateFlashContents();


This system works, but after an unexpected power off and a restart, the function E_EEPROM_XMC4_Init returns the error code E_EEPROM_XMC4_STATUS_ERROR_OLD_DATA.

This behaviour is quite normal, but I would like to know what the correct procedure is to be followed in case of this kind of error in order to erase the corrupted flash and clear the error.
(Data loss is not an issue for this application.)

I have tried to write new values on the E_EEPROM and then update the flash:
E_EEPROM_XMC4_WriteByte( REBOOT_COUNT_OFFSET, MAX_SYSTEM_FAULT_REBOOT_COUNT + 1 ); 
flashStatus = E_EEPROM_XMC4_UpdateFlashContents();


The operation is carried out without mistakes and a new call to E_EEPROM_XMC4_Init returns no error.
But after a new reboot (/PORST) the function E_EEPROM_XMC4_Init returns once again the error code E_EEPROM_XMC4_STATUS_ERROR_OLD_DATA.
0 Likes
2 Replies
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

We have tried to reproduce your issue without success.
1. Save data in the first block in EEPROM
2. Use and corrupt second block artificially. Reset. DAVE_Init returns E_EEPROM_XMC4_STATUS_ERROR_OLD_DATA
3. Save data in the third block in EEPROM. Reset. DAVE_Init returns no error.

The error should vanish after the next valid data being stored in FLASH.

What do you mean by "but after an unexpected power off and a restart"? Did this happen during the update of the flash contents?

In this sentence, "The operation is carried out without mistakes and a new call to E_EEPROM_XMC4_Init returns no error.".
Did you do a reset after the call to E_EEPROM_XMC4_UpdateFlashContents(); or did you just call the E_EEPROM_XMC4_Init()?

Best regards,
Jesus
0 Likes
Not applicable
jferreira wrote:
Hi,

We have tried to reproduce your issue without success.
1. Save data in the first block in EEPROM
2. Use and corrupt second block artificially. Reset. DAVE_Init returns E_EEPROM_XMC4_STATUS_ERROR_OLD_DATA
3. Save data in the third block in EEPROM. Reset. DAVE_Init returns no error.

The error should vanish after the next valid data being stored in FLASH.

What do you mean by "but after an unexpected power off and a restart"? Did this happen during the update of the flash contents?

In this sentence, "The operation is carried out without mistakes and a new call to E_EEPROM_XMC4_Init returns no error.".
Did you do a reset after the call to E_EEPROM_XMC4_UpdateFlashContents(); or did you just call the E_EEPROM_XMC4_Init()?

Best regards,
Jesus


What do you mean when you say that you write in three different EEPROM sectors? Is it something that is selected by user code or it is managed automatically? What happens if you use again the corrupted sector, i.e. sector number 2? I always use the same location of the EEPROM, hence i need to recover it after data corruption (no matter if I lose data). Any ideas? Thank you!
0 Likes