EEPROM Emulation utility fails during "PageTransfer" function (XCUBE-EEPROM V3.0.0 and 4.0.0) on STM32G474 MCU
Hi,
I have incorporated the EEPROM emulation utility in a project based on STM32G474CE MCU. So far the read/write functionality works fine. The problem comes when a page is full and the page transfer function is called. At the end of this function no variables were copied from the "valid" page to the "receive" page. All my variables were lost after page swap.
Upon debugging, i found out that the transfer "for" loop, is trying to read all virtual addresses from 1 to "NO_OF_VARIABLES", and transfer them to the "receive" page. In my case however, there are only 200 variables so NO_OF_VARIABLES = 200, but the virtual addresses are scattered along ranges 0xA000, 0xB000 0xC000 and so on. Therefore, the FOR loop never looks for these variable at all and hence also does not copy them. This looks like a bug to me unless there is something that i am missing or doing wrong. The example application provided with the utility works fine becaue in that aplication, variables are assigned virtual adresses sequentially from 0x0001 onwards so this does not cause a problem for "PageTransfer" function. Logically, according to the refrence manual, there is no limitation or requirement to assign virtual addresses to variables except the values of 0xFFFF and 0x0000. Please provide a solution to this. We are stuck in the middle of a project becaue of this problem.
Here is the code snippet for the FOR loop for transferring variables.
/* Transfer process: transfer variables from old to the new active page */
/* First element in receive page can be any one, the following elements are */
/* ordered from the beginning. */
/* In case of recovery, Pre-Last element in receive page could be */
/* corrupted if reset occured during write of this element, */
/* and last element is dummy value that we have just written. */
/* Transfer shall then resume from (uhNbWrittenElements-3) variable index */
for (varidx = (uhNbWrittenElements >= 3U?(uhNbWrittenElements-3U+1U):1U); varidx < NB_OF_VARIABLES+1; varidx++)
{
/* Check each variable except the one passed as parameter */
if (varidx != VirtAddress)
{
/* Read the last variable updates */
status = ReadVariable(varidx, &DataValue);
if (status == EE_OK)
{
/* In case variable corresponding to the virtual address was found */
/* Transfer the variable to the new active page */
/* If program operation was failed, a Flash error code is returned */
#ifdef DUALCORE_FLASH_SHARING
status = VerifyPagesFullWriteVariable(varidx, DataValue, EE_TRANSFER);
#else
status = VerifyPagesFullWriteVariable(varidx, DataValue);
#endif
if (status != EE_OK)
{
return status;
}
}
else
{
if (status != EE_NO_DATA)
{
/* In case variable is not found , do nothing */
/* Any other status is error code occurs during variable read */
return status;
}
}
}
}
