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

cross mob

Em_EEPROM Component Read Function Returns Incorrect Data when Restored from a Redundant Copy - KBA227530

Em_EEPROM Component Read Function Returns Incorrect Data when Restored from a Redundant Copy - KBA227530

ChaitanyaV_61
Employee
Employee
50 questions asked 25 likes received 25 sign-ins

Author: OleksandrP_61          Version: **

Context:
PSoC® Creator™ 4.2 project with the Em_EEPROM Component v2_0, v2_10 or v2_20, for PSoC 3, PSoC 4, PSoC 5LP, or PSoC 6 MCU devices.

ModusToolbox™ IDE project with psoc6sw-1.0 or psoc6sw-1.1 libraries which uses the Emulated EEPROM middleware for PSoC 6 MCU.

Issue:
When a redundant copy is enabled and data is restored from the redundant copy, the Em_EEPROM_Read() and Cy_Em_EEPROM_Read() functions restore the data in Em_EEPROM, but return incorrect data as a result. The second read operation returns the correct data from Em_EEPROM.

Cause:
This issue is caused by an error in the pointer arithmetic – the sum operation is performed on two operands with different types (uint32_t * and uint32_t), which causes unpredictable operation results.

Workaround:
You can fix the issue using the following workaround:

1. Locate the cy_em_eeprom.c file and create a backup for it. Depending on the PSoC family and Component version, this file is located in the following directory:

     PSoC Creator 4.2 and PSoC 3, PSoC 4, or PSoC 5LP:

     a. Em_EEPROM v2_10

     C:\Users\<Username>\Documents\PSoC Creator\4.2\Downloads ( 4.2).cylib\Em_EEPROM_Dynamic_v2_10\API\cy_em_eeprom.c

     b. Em_EEPROM v2_20

     C:\Users\<Username>\Documents\PSoC Creator\4.2\Downloads ( 4.2).cylib\Em_EEPROM_Dynamic_v2_20\API\cy_em_eeprom.c

     PSoC Creator 4.2 and  PSoC 6 MCU:

     a. PDL 3.0.4

     C:\Program Files (x86)\Cypress\PDL\3.0.4\middleware\em_eeprom\cy_em_eeprom.c

     b. PDL 3.1.0

     C:\Program Files (x86)\Cypress\PDL\3.1.0\middleware\em_eeprom\cy_em_eeprom.c

     ModusToolbox and PSoC 6 MCU:

     a. ModusToolbox v1.0

     <user_home>\ModusToolbox_1.0\libraries\psoc6sw-1.0\components\psoc6mw\em_eeprom\cy_em_eeprom.c

     b. ModusToolbox v1.1

     <user_home>\ModusToolbox_1.1\libraries\psoc6sw-1.1\components\psoc6mw\em_eeprom\cy_em_eeprom.c

2. Update the CheckCrcAndCopy() function code in the cy_em_eeprom.c file.

Note To perform code update for PSoC Creator and PSoC 6 MCU, run your editor software with Administrator rights.

Find the following code:

if(CY_EM_EEPROM_SUCCESS == ret)

{

   (void)memcpy((void *)(dstAddr), (void *)(writeRamBuffer + rowOffset), numBytes);

}

...

Replace found above code with the following code containing the workaround:

if(CY_EM_EEPROM_SUCCESS == ret)

{

    (void)memcpy((void *)(dstAddr), (void *)((uint32_t)writeRamBuffer + rowOffset), numBytes);

}

...

0 Likes
895 Views
Contributors