2025-04-26 2:49 AM
Hi,
I'd like to have some feedback about the use of XCUBE-EEPROM library on STM32H563.
Is it functionnal and reliable ?
After digging into the code, i have few questions:
In the MPU_init() function there's a configuration with no explanation ?
/********************************************************************************/
** Initializes and configures the Region and the memory to be protected
*/
MPU_InitStruct.Number = MPU_REGION_NUMBER1;
MPU_InitStruct.BaseAddress = 0x08FFF800;
MPU_InitStruct.LimitAddress = 0x08FFF80F;
MPU_InitStruct.AccessPermission = MPU_REGION_ALL_RO;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
/********************************************************************************/
With the default settings, in the OB_init() function according to me there's a problem with the computation of num_of_edata_page.
Indeed in the code below, after each reset the HAL_FLASHEx_OBProgram() is always called.
/********************************************************************************/
num_of_edata_page = ((FLASH_EDATA_BASE + (FLASH_EDATA_SIZE>>1)) - START_PAGE_ADDRESS) / FLASH_PAGE_SIZE;
register_value = FLASH->EDATA2R_CUR;
edata_enable = FLASH_EDATAR_EDATA_EN;
/* If current EDATA configration is different from new configration, Reprogram Option Byte EDATA settings */
if(register_value != (edata_enable | (num_of_edata_page - 1)))
{
/* Variable used for OB Program procedure */
FLASH_OBProgramInitTypeDef FLASH_OBInitStruct;
/* Current EDATA configuration doesn't match with new configuration. */
/* Unlock the Flash option bytes to enable the flash option control register access */
HAL_FLASH_OB_Unlock();
/* Configure 8 sectors for FLASH high-cycle data */
FLASH_OBInitStruct.Banks = bank;
FLASH_OBInitStruct.OptionType = OPTIONBYTE_EDATA;
num_of_edata_page = 1;
FLASH_OBInitStruct.EDATASize = edata_enable | num_of_edata_page;
if(HAL_FLASHEx_OBProgram(&FLASH_OBInitStruct) != HAL_OK)
{
Error_Handler();
}
/* Start option byte load operation after successful programming operation */
HAL_FLASH_OB_Launch();
/********************************************************************************/
When EDATA2_STRT=0 it means that the last sector of Bank2 that is to say
from 0x9016800 to 0x9017FFF is enabled.
Thanks in advance for your feedback.
Greg