cancel
Showing results for 
Search instead for 
Did you mean: 

EEPROM emulation problem on STM32H563

Bhuvi-Naveen
Associate II

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Florian LR
ST Employee

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.

View solution in original post

6 REPLIES 6
Florian LR
ST Employee

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.

Hello Florian,

Thank you for your quick response!

It is working fine after adding the above patch.

Regards,

Bhuvi-Naveen

I think that there is another bug in EEPROM_Emul 6.1.0.

Register FLASH->ECCR does not exist:

 
eeprom_emul.c line 262:
 
#ifdef STM32H563xx
     Address=(0x8000000|(FLASH->ECCDR & 0x000FFFFF)); //Recovery of address where ECC error occured
#else
     Address=(0x8000000|(FLASH->ECCR & 0x000FFFFF)); //Recovery of address where ECC error occured
#endif
 
I believe that complete H5 family has FLASH->ECCDR.
 
BR
 

 

Hi @Maxi

FLASH->ECCR does not exist on STM32H5 series, we agree on that, that's why on eeprom_emul.c line 262 you have : 

 

#ifdef STM32H563xx
     Address=(0x8000000|(FLASH->ECCDR & 0x000FFFFF)); //Recovery of address where ECC error occured
#else
     Address=(0x8000000|(FLASH->ECCR & 0x000FFFFF)); //Recovery of address where ECC error occured
#endif

 

The file eeprom_emul.c is a core file common to all supported devices within the X-Cube EEPROM, and other products have the FLASH->ECCR.
So here we have a define concerning the STM32H563xx, because it's the product chosen within the H5 family to be in the X-Cube, but it can be easily tailored to any other STM32H5 and in this case you must update this define (but if you port the code you simply delete the line that does not concern your product instead of keeping all the defines).

I hope this will answer your question.

Best Regards, 
Florian LR

Maxi
Associate

Thank you for explanation.

 

BR,

Maxi

nimaltd
Senior

Just  install my pack and enjoy.

https://github.com/nimaltd/ee