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

cross mob

Who rated this article

Who rated this article

Em_EEPROM Component Read Function Stuck in Infinite Loop - KBA227502

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

Author: OleksandrP_61           Version: **

Translation - Japanese: Em_EEPROM コンポーネントのリード関数が無限ループにとどまってしまう問題 - KBA227502- Community Translated (JA)

Context:
PSoC® Creator™ 4.2 project with 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 an unexpected reset or power loss happens during the Em_EEPROM Component write operation, the read operation with the Em_EEPROM_Read() or Cy_Em_EEPROM_Read() functions can stuck in an infinite loop in the next device power-up.

Cause:
This issue is caused by an error in the read function loop organization. An infinite loop occurs only when the sequence number field (seqNum variable) of the em_eeprom header section is set to 0xFFFFFFFF by an incomplete flash write operation.

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:

  1. 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   

  2. 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:

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

  2. 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:

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

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

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

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

Find the following code:

        if((CY_EM_EEPROM_SUCCESS == ret) && (0u != seqNum))

        {

numRowReads = (context->numberOfRows <= seqNum) ? (context->numberOfRows) : (seqNum);

numRowReads--;

            for(i = (seqNum - numRowReads); i <= seqNum; i++)

            {

startRowAddr = GetRowAddrBySeqNum(i, context);

                if (0u != startRowAddr)

                {

                    ...

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

        if((CY_EM_EEPROM_SUCCESS == ret) && (0u != seqNum))

        {

numRowReads = (context->numberOfRows <= seqNum) ? (context->numberOfRows) : (seqNum);

            for(i = 0; i < numRowReads; i++)

            {

startRowAddr = GetRowAddrBySeqNum(seqNum - ((numRowReads - 1) - i), context);

                if (0u != startRowAddr)

                {

                    ...

2114 Views
Who rated this article