nimaltd/ee

STM32F103 ee_format clears 0'th page

remrol opened this issue · 5 comments

On STM32F1 architecture _EE_PAGE_OR_SECTOR is PAGE, then ee_format instruction:
flashErase.PageAddress = _EE_USE_FLASH_PAGE_OR_SECTOR;
wrongly assigns page number instead of page address and leads to clearing 0'th bank. Corrected line should be:
flashErase.PageAddress = _EE_ADDR_INUSE;

do you check it? I think I checked before and it works fine.... I can not remember now

Yes this is the problem which I found just now on STM32F103CBT6 using STM32CubeIDE Version: 1.10.1 HAL 1.8.4
Original code overwrites first FLASH page and the MCU stops working, need to re-program MCU.
After modification everything works fine.
Of course it will be great if someone check this issue.

EDIT:
from stm32f1xx_hal_flash_ex.h, see PageAddress desription, it clearly says it should be FLASH address

/**

  • @brief FLASH Erase structure definition
    /
    typedef struct
    {
    uint32_t TypeErase; /
    !< TypeErase: Mass erase or page erase.
    This parameter can be a value of @ref FLASHEx_Type_Erase */

uint32_t Banks; /*!< Select banks to erase when Mass erase is enabled.
This parameter must be a value of @ref FLASHEx_Banks */

uint32_t PageAddress; /!< PageAdress: Initial FLASH page address to erase when mass erase is disabled
This parameter must be a number between Min_Data = 0x08000000 and Max_Data = FLASH_BANKx_END
(x = 1 or 2 depending on devices)
/

uint32_t NbPages; /!< NbPages: Number of pagess to be erased.
This parameter must be a value between Min_Data = 1 and Max_Data = (max number of pages - value of initial page)
/

} FLASH_EraseInitTypeDef;

thanks for reporting..

please check again. I fixed it

Works fine thank you, can be closed