Skip to main content
Visitor II
November 5, 2023
Solved

EEPROM emulation problem on STM32H563

  • November 5, 2023
  • 3 replies
  • 4170 views

Hi,

I'm facing problem in reading data from EEPROM, which was written before power cycle.
EE_Init() always causes formatting of EEPROM irrespective of EE_CONDITIONAL_ERASE or EE_FORCED_ERASE parameter passed, resulting in erasing the previous data
Configuration: "STM32H5 series using high-cycle data area" with EDATA_ENABLED & START_PAGE_ADDRESS 0x0900C000U

I'm using the latest version of EEPROM emulation driver "X-CUBE-EEPROM version-6.0.0" on dev kit "NUCLEO-H563ZI"

The example code works fine, it is able to write and read the data from the flash every time on power up by formatting the page, but when I wanted to read the data which was written in previous cycle, It always reads data zero.

The reason I found was, it always give current page status as "ERASING".

I made the following change in function FindPage(), having a switch case operation for "FIND_READ_PAGE" by adding a check currentpagestatus == STATE_PAGE_VALID as shown below.

I added STATE_PAGE_VALID check instead of STATE_PAGE_ERASING, because, the debugger shows the current page status as valid in function FindPage()

case FIND_READ_PAGE: /* ---- Read operation ---- /
if (currentpagestatus == STATE_PAGE_ACTIVE || currentpagestatus == STATE_PAGE_VALID)
{
     return currentpage;
}
else
{
    if (currentpagestatus == STATE_PAGE_RECEIVE)
    {
         return previouspage;
    }
    else
    {
         return EE_NO_PAGE_FOUND; / No active Page */
    }
}

In main.c I added the following code just before initializing the EE_Init
ConfigureCrc();
for (Index = 1; Index < NB_OF_VARIABLES+1; Index++)
{
    EE_ReadVariable32bits(Index, &a_VarDataTab[Index-1]);
}
with the above change I'm now able to read data which was written in previously.

Am I missing some settings? please help!

    This topic has been closed for replies.
    Best answer by Florian LR

    Hi @Bhuvi-Naveen, and welcome to the STCommunity !

    Thank you for reporting us the issue, we already identified it on our side, and the patched version of the firmware will be released in the next days.

    This is happening because NMIs are triggered during the step 1 of EE_Init().

    You can already patch it on your side, before the firmware update.

    In the file stm32h5xx_it.c in function NMI_Handler, add the following lines after
     if (__HAL_FLASH_GET_FLAG(FLASH_FLAG_ECCD)) {

     

    #ifdef EDATA_ENABLED
     if (READ_REG(FLASH->ECCDR) == 0xFFFF)
     {
     __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ECCD);
     return;
     }
    #endif

     


    If you have any issue, please don't hesitate to come back. 
    Best Regards,

    Florian LR

     

    To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

    3 replies

    ST Employee
    November 6, 2023

    Hi @Bhuvi-Naveen, and welcome to the STCommunity !

    Thank you for reporting us the issue, we already identified it on our side, and the patched version of the firmware will be released in the next days.

    This is happening because NMIs are triggered during the step 1 of EE_Init().

    You can already patch it on your side, before the firmware update.

    In the file stm32h5xx_it.c in function NMI_Handler, add the following lines after
     if (__HAL_FLASH_GET_FLAG(FLASH_FLAG_ECCD)) {

     

    #ifdef EDATA_ENABLED
     if (READ_REG(FLASH->ECCDR) == 0xFFFF)
     {
     __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ECCD);
     return;
     }
    #endif

     


    If you have any issue, please don't hesitate to come back. 
    Best Regards,

    Florian LR

     

    To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

    Visitor II
    November 6, 2023

    Hello Florian,

    Thank you for your quick response!

    It is working fine after adding the above patch.

    Regards,

    Bhuvi-Naveen

    Explorer
    December 5, 2023

    Thank you for explanation.

     

    BR,

    Maxi

    Graduate
    March 26, 2024

    Just  install my pack and enjoy.

    https://github.com/nimaltd/ee