Em_EEPROM Erase and lockup

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

cross mob
ErGo_3681856
Level 1
Level 1

I am using CY8C4248LQI-BL483. I have a bootable stack and application. I am bonding to the device. I'm using em_EEPROM V2.2

When I write to a secure BLE characteristic from my phone and then some time later in the main context call Em_EEPROM_1_Erase(), when the firmware next reaches CyBle_ProcessEvents(); it all hangs. I don't receive any error messages from CyBle_ProcessEvents(); nor from Em_EEPROM_1_Erase();

I can increase the amount of time after writing a secure BLE characteristic before calling Em_EEPROM_1_Erase() and the code will still hang when it reaches CyBle_ProcessEvents();

I can write and read and erase from the EEPROM as long as I do not write to a characteristic.

Is there a known bad interaction with Bonding or BLE and the Emulated EEPROM? Is there a workaround for this?

This does not appear related to KBA228069 as the device does not need to be powered down for this interaction to occur.

0 Likes
1 Solution
GeonaP_26
Moderator
Moderator
Moderator
250 solutions authored 100 solutions authored 50 solutions authored

Emulated EEPROM stores data in device flash. Flash operations are row wise and single flash row erase can take as much as 13 ms (refer to Flash AC Specifications in device datasheet for more details). Continuous flash operations during the BLE connected state may result in processing of BLE events to be pending and can cause disconnection. Also, the device should not be reset during flash operations. Please ensure that there is no fluctuations in the power supply and implement following steps;

  • Place Emulated EEPROM data storage in checksum exclude memory region const uint8_t Em_EEPROM_1_em_EepromStorage[Em_EEPROM_1_PHYSICAL_SIZE] __ALIGNED(CY_FLASH_SIZEOF_ROW)  CY_SECTION(".cy_checksum_exclude") = {0u};
  • Try calling the Em_EEPROM / flash operations only if the BLESS state is CYBLE_BLESS_STATE_EVENT_CLOSE
  • Call Em_EEPROM / flash operations when cyBle_pendingFlashWrite variable is zero.

View solution in original post

0 Likes
3 Replies
GeonaP_26
Moderator
Moderator
Moderator
250 solutions authored 100 solutions authored 50 solutions authored

Emulated EEPROM stores data in device flash. Flash operations are row wise and single flash row erase can take as much as 13 ms (refer to Flash AC Specifications in device datasheet for more details). Continuous flash operations during the BLE connected state may result in processing of BLE events to be pending and can cause disconnection. Also, the device should not be reset during flash operations. Please ensure that there is no fluctuations in the power supply and implement following steps;

  • Place Emulated EEPROM data storage in checksum exclude memory region const uint8_t Em_EEPROM_1_em_EepromStorage[Em_EEPROM_1_PHYSICAL_SIZE] __ALIGNED(CY_FLASH_SIZEOF_ROW)  CY_SECTION(".cy_checksum_exclude") = {0u};
  • Try calling the Em_EEPROM / flash operations only if the BLESS state is CYBLE_BLESS_STATE_EVENT_CLOSE
  • Call Em_EEPROM / flash operations when cyBle_pendingFlashWrite variable is zero.
0 Likes

Hello Geona,

I am still getting a hangup and device reset after several seconds when I call the erase function. 

I have modified the code to wait and retry later if the BLESS state is not CYBLE_BLESS_STATE_EVENT_CLOSE or if cyBle_pendingFlashWrite  is not zero.

    if( (cyBle_pendingFlashWrite != 0) ||

        (CyBle_GetBleSsState() != CYBLE_BLESS_STATE_EVENT_CLOSE) )

    {

        //try again later

        return;

    }

If this is due to the BLE needing to be called more frequently, is there a method of erasing part of the flash other than Em_EEPROM_1_Erase()?

0 Likes

You can write array of zeros using Em_EEPROM_Write API. cyBle_pendingFlashWrite is used by BLE stack to take care of pending flashwrites initiated via BLE component API. You can refer to BLE component datasheet for more details. Depending upon end applicaion requirements, user needs to judiciously take care of both flash operations.

0 Likes