2023-11-05 06:44 AM
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!
Solved! Go to Solution.
2023-11-06 01:43 AM - edited 2023-11-06 01:44 AM
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.
2023-11-06 01:43 AM - edited 2023-11-06 01:44 AM
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.
2023-11-06 09:20 AM
Hello Florian,
Thank you for your quick response!
It is working fine after adding the above patch.
Regards,
Bhuvi-Naveen
2023-12-04 05:14 AM
I think that there is another bug in EEPROM_Emul 6.1.0.
Register FLASH->ECCR does not exist:
2023-12-04 06:03 AM
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
2023-12-05 12:50 AM
Thank you for explanation.
BR,
Maxi
2024-03-25 11:29 PM
Just install my pack and enjoy.