6 years, 1 month ago.

FLASH_PageErase : how to fix the issue ?

Hi,

I try to write data in the ROM of a STM32F429-Disco using this code : https://os.mbed.com/users/olympux/code/eeprom_flash/

But I have two errors that I don't know how to fix :

Error: Identifier "FLASH_PageErase" is undefined in "eeprom_flash/eeprom_flash.cpp", Line: 25, Col: 6 Error: Identifier "FLASH_CR_PER" is undefined in "eeprom_flash/eeprom_flash.cpp", Line: 26, Col: 6

In fact, I don't where the two fonctions are I checked in mbed but I don't find the equivalent.

Thank you for your help

2 Answers

5 years, 11 months ago.

Hi, I've the same problem. Did you find solution?

5 years, 11 months ago.

Hello,

It seems that the FLASH_PageErase function is not available anymore for MBED users. We have to call the HAL_FLASHEx_Erase instead. So try to modify the eeprom_flash.cpp file as follows:

eeprom_flash.cpp

//...
FLASH_EraseInitTypeDef eraseInit = {
    FLASH_TYPEERASE_PAGES,  /*!< Pages erase only (Mass erase is disabled)*/
    0,                      /*!< Select banks to erase when Mass erase is enabled.*/
    EEPROM_START_ADDRESS,   /*!< 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)*/
    1                       /*!< 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)*/
};
 
uint32_t pageError;
 
/*
 * Must call this first to enable writing
 */
void enableEEPROMWriting() {
    HAL_StatusTypeDef status = HAL_FLASH_Unlock();
    //FLASH_PageErase(EEPROM_START_ADDRESS); // required to re-write
    //CLEAR_BIT(FLASH->CR, FLASH_CR_PER); // Bug fix: bit PER has been set in Flash_PageErase(), must clear it here
    HAL_FLASHEx_Erase(&eraseInit, &pageError);
}
//...