cancel
Showing results for 
Search instead for 
Did you mean: 

I can't erase flash memory of STM32F767 Nucleo-144 board . How could i...

Mje m
Associate

hello you guies.

i am tring to erase my flash memory of STM32F767 Nucleo-144 board but i couldn't do that.

That's because my STM32F767 Nucleo-144 board could not be operation right. As soon as i set STRT bit of Flash control register (FLASH_CR) but STM32F767 Nucleo-144 board try to reset. (i confirmed that NRST pin is 3.3V --> 0V and than 3.3V.)

if you guies have any great ideas, please let me know.

thank you so much your effort,

My source code is below:

1. single memory bank: 2Mbyte.

2. I am using the HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *SectorError)).

3. Memory addresss configure:

// Base address of the Flash sectors

#define ADDR_FLASH_SECTOR_0   ((uint32_t)0x08000000) //Sector 0, 32 Kbytes

#define ADDR_FLASH_SECTOR_1   ((uint32_t)0x08008000) //Sector 1, 32 Kbytes

#define ADDR_FLASH_SECTOR_2   ((uint32_t)0x08010000) //Sector 2, 32 Kbytes

#define ADDR_FLASH_SECTOR_3   ((uint32_t)0x08018000) //Sector 3, 32 Kbytes

#define ADDR_FLASH_SECTOR_4   ((uint32_t)0x08020000) //Sector 4, 128 Kbytes

#define ADDR_FLASH_SECTOR_5   ((uint32_t)0x08040000) //Sector 5, 256 Kbytes

#define ADDR_FLASH_SECTOR_6   ((uint32_t)0x08080000) //Sector 6, 256 Kbytes

#define ADDR_FLASH_SECTOR_7   ((uint32_t)0x080C0000) //Sector 7, 256 Kbytes

#define ADDR_FLASH_SECTOR_8   ((uint32_t)0x08100000) //Sector 8, 256 Kbytes

#define ADDR_FLASH_SECTOR_9   ((uint32_t)0x08140000) //Sector 9, 256 Kbytes

#define ADDR_FLASH_SECTOR_10  ((uint32_t)0x08180000) //Sector 10, 256 Kbytes

#define ADDR_FLASH_SECTOR_11  ((uint32_t)0x081C0000) //Sector 11, 256 Kbytes

 #define FLASH_SECTOR_0  ((uint32_t)0U) /*!< Sector Number 0  */

#define FLASH_SECTOR_1   ((uint32_t)1U) /*!< Sector Number 1  */

#define FLASH_SECTOR_2   ((uint32_t)2U) /*!< Sector Number 2  */

#define FLASH_SECTOR_3   ((uint32_t)3U) /*!< Sector Number 3  */

#define FLASH_SECTOR_4   ((uint32_t)4U) /*!< Sector Number 4  */

#define FLASH_SECTOR_5   ((uint32_t)5U) /*!< Sector Number 5  */

#define FLASH_SECTOR_6   ((uint32_t)6U) /*!< Sector Number 6  */

#define FLASH_SECTOR_7   ((uint32_t)7U) /*!< Sector Number 7  */

#define FLASH_SECTOR_8   ((uint32_t)8U) /*!< Sector Number 8  */

#define FLASH_SECTOR_9   ((uint32_t)9U) /*!< Sector Number 9  */

#define FLASH_SECTOR_10  ((uint32_t)10U) /*!< Sector Number 10 */

#define FLASH_SECTOR_11  ((uint32_t)11U) /*!< Sector Number 11 */

uint16_t Flash_Erase_Init(void) {

 FLASH_EraseInitTypeDef pErase;

 static uint32_t SectorError = 0;

 HAL_FLASH_Unlock();

 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR 

 | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_ERSERR);

  

 RCC_APB1PeriphClockCmd(RCC_APB1Periph_WWDG, DISABLE);

 pErase.TypeErase = FLASH_TYPEERASE_SECTORS;

 pErase.Sector = FLASH_SECTOR_8;

 pErase.NbSectors = FLASH_SECTOR_10;

 pErase.VoltageRange = FLASH_VOLTAGE_RANGE_3;

 uint16_t res = HAL_FLASHEx_Erase(&pErase,&SectorError);

 if (res != HAL_OK) {

    return res;

 }

 RCC_APB1PeriphClockCmd(RCC_APB1Periph_WWDG, ENABLE);

 return HAL_OK;

}

1 REPLY 1

pErase.NbSectors = FLASH_SECTOR_10; // This looks bogus, try = 1

RCC_APB1PeriphClockCmd(RCC_APB1Periph_WWDG, DISABLE); // Can you turn off the watchdog?

Try building/testing the example

STM32Cube_FW_F7_V1.12.0\Projects\STM32F767ZI-Nucleo\Examples\FLASH\FLASH_EraseProgram\Src\main.c

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..