2 Critical bugs in Emulated EEPROM component, negative effect on all users. DO NOT USE.

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

cross mob
kemic_264446
Level 4
Level 4
First like received

 Just a quick heads up for everyone. (Are you listening Cypress?)

   

There are 2 serious bugs in the Emulated EEPROM component which make it not suitable for use in any application.

   

It has to do with the way the internal addresses within the flash arrays are calculated. The user has no control over these and a work around is only possible by editing the generated-source or modifying the supplied library source.

   

1. If the constant structure, variable or array you have defined just happens to live outside of flash array-0 then writing to it will corrupt other areas of flash. The data will get saved to the wrong flash array and could overwrite code, or configuration data.

   

2. If the data you are storing in flash just happens to occupy part of the last row of a flash array (again you have no control over this) then the last row will be written to the wrong flash array, which could damage code or configuration data. 

   

 

   

I have raised tickets with Cypress for both of these issues. I have given them sample code which demonstrates the issues and I am sure a fix will be forth coming, but until then you canot use the Emulated EEPROM component.

   

If you are currently using this component and not suffering any bad effects, then it is only by chance - a small change to ANY part of your code could push your flash data into one of the affected areas and cause your code to behave in strange ways.

   

For those on PSoC 5 or PSoC 5LP here is a work around:

   

After you code is built and compiled, find the generated source for the Em_EEPROM_Write() method. [Its name will depend on what you names the component in the schematic, for example if your component is named 'FlashSave' then the method will be FlashSave_Write() ]

   

Then edit the four lines at approximately line 121 in the file and replace them with this:

   

   

        rowNumber = dataAddress / CY_FLASH_SIZEOF_ROW;

   

        arrayNumber = dataAddress / CY_FLASH_SIZEOF_ARRAY;

   

        rowOffset = dataAddress - (CY_FLASH_SIZEOF_ROW * rowNumber);

   

        readSrcIndex = 0u;

   

And then add this line immediately following the previous four:

   

rowNumber &= 0x000000ff; 

   

 

   

This will allow the rowNumber and arrayNumber to be calculated properly for any address in flash.

   

 

   

I hope this helps.

0 Likes
1 Solution
Anonymous
Not applicable

This problem is mostly contained to PSoC 5 / 5LP.  Those devices can have up to 4 Flash blocks.  PSoC 3 and PSoC 4 have just a single Flash block.  Therefore they are only prone to the second problem that you describe that can occur if you are trying to write the last row of flash.  Flash is allocated by the linker sequentially, so for PSoC 3 /  4 the problem doesn't occur unless you fill all the Flash in the device and the location you attempt to write got allocated to that last piece of Flash.

View solution in original post

0 Likes
18 Replies