cancel
Showing results for 
Search instead for 
Did you mean: 

EEPROM emulation Fails after constant Read and Write operation.

Srave.1
Associate II

Hi,

I am currently working on a project which requires to save 127 bytes of configuration parameters to EEprom. Micro controller is stm32l552x series. 

We have emulated eeprom from flash using X-CUBE-EEPROM_V3.0.0 software package to store configuration parameters. it was working fine most of the time. I could read and write to EEPROM whenever I needed to change the parameters.

But problem occurs from time to time, without knowing exactly what is the cause.. sometimes program stucks at eeprom read cycle(EE_ReadVariable8bits ). some times it stucks at EE_Init() function itself and returns page write error status.

Is this a problem associated with flash endurance ?. For firmware testing, we were updating the parameters constantly.

This is the Configuration of eeprom emulation in flash.

#define START_PAGE_ADDRESS   0x08020000U

#define CYCLES_NUMBER      1U

 /

#define GUARD_PAGES_NUMBER   2U 

#define CRC_POLYNOMIAL_LENGTH  LL_CRC_POLYLENGTH_16B

#define CRC_POLYNOMIAL_VALUE  0x8005U

#define NB_OF_VARIABLES     160U

Thank you.

6 REPLIES 6
Srave.1
Associate II

When I changed #define START_PAGE_ADDRESS   0x08020000U to 0x 0x0807B000U in configuration file, I could resolve EE_Init() stuck issue. But eeprom stuck during continuous read operation.

Uwe Bonnes
Principal III

Constantly at what frequency? Expect failure after 10^4 to 10^5 accesses!

Hi Uwe Bonnes,

Thanks for your comments. Frequency is very less in normal case. But for aggressive testing we were updating and reading 127 bytes of parameters data(Each parameter of 1 byte) frequently.

we have been testing the application in 2 STM boards and the problem appears frequently only in one of the boards which is being used for aggressive testing.

Stuck issue occurs only during continuous read cycle(ie Reading 127 bytes from eeprom in a loop) and the page state returned during this issue is STATE_PAGE_ERASING.

Application code is not entering to the following IF condition in ReadVariable() API(in eeprom_emul.c file provided with emulation software package ) during read cycle issue.

/* Compare the read address with the virtual address */

    if (EE_VIRTUALADDRESS_VALUE(addressvalue) == VirtAddress)

    {

     /* Calculate crc of variable data and virtual address */

     crc = CalculateCrc(EE_DATA_VALUE(addressvalue), EE_VIRTUALADDRESS_VALUE(addressvalue));

     /* if crc verification pass, data is correct and is returned.

       if crc verification fails, data is corrupted and has to be skip */

     if (crc == EE_CRC_VALUE(addressvalue))

     {

      /* Get content of variable value */

      *pData = EE_DATA_VALUE(addressvalue);

      return EE_OK;

     }

    }

Do we need to add any delay in between eeprom read?

Srave.1
Associate II

Even though we use 127 byte location in eeprom, we are updating only first 76 byte location(virtual address from 1 to 76) frequently.

1 to 76 byte virtual address locations are used to store parameter value and the 127 th location is used to store chcksum. checksum is calculated by reading 1 to 126 byte location data and updated the 127th byte location.

Virtual address from 77 to 126 are only used to read the initially entered data(during power up 0 is filled at 77 to 126) to calculate checksum.

stuck issue appears in between 77 to 126 virtual address read cycle.

Writing large blocks of data you'd be better off learning how to use the Flash directly, and optimize so it only updates/journals if the data actually changes.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Srave.1
Associate II

After some testing, Following is my understanding.

Reading a virtual address location continuously which was not previously written by any values is making the stuck issue. Then the code stuck in the following loop inside eeprom emulation driver. This loop is in ReadVariable() API in eeprom_emul.c file.

 if (EE_VIRTUALADDRESS_VALUE(addressvalue) == VirtAddress)

    {

     /* Calculate crc of variable data and virtual address */

     crc = CalculateCrc(EE_DATA_VALUE(addressvalue), EE_VIRTUALADDRESS_VALUE(addressvalue));

     /* if crc verification pass, data is correct and is returned.

       if crc verification fails, data is corrupted and has to be skip */

     if (crc == EE_CRC_VALUE(addressvalue))

     {

      /* Get content of variable value */

      *pData = EE_DATA_VALUE(addressvalue);

      return EE_OK;

     }

    }

Also this stuck issue occurs only after several read to the same location which was not previously written by any values.