cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F746 Flash Sector Erase Problem

BahadirA
Associate

Hi Guys,

I have a problem with erasing Flash sector. I am using STM32F746ZG Nucleo Board. When  I run this code, mcu works perfect it works but I can't install new firmware to mcu. I've also tried example code, same problem. I take (DEV_TARGET_NOT_HALTED) when I run the program.

I am getting the same error in debug mode as described in the link below.

https://community.st.com/t5/stm32cubeide-mcus/how-to-solve-error-finishing-flash-operation-in-stm32cubeide/td-p/53113/page/2

Code Here they are

 

FLASH_EraseInitTypeDef FLASH_Erase_Init;
uint32_t SectorError;

HAL_FLASH_Unlock();

FLASH_Erase_Init.TypeErase = FLASH_TYPEERASE_SECTORS;
FLASH_Erase_Init.VoltageRange = FLASH_VOLTAGE_RANGE_3;
FLASH_Erase_Init.Sector. FLASH_SECTOR_3;
FLASH_Erase_Init.NbSectors = 1;

if(HAL_FLASHEx_Erase(&FLASH_Erase_Init, &SectorError) == HAL_OK)
HAL_Flash_Lock();

 

 

How can i solve it ?

1 ACCEPTED SOLUTION

Accepted Solutions
BahadirA
Associate

I've solved this issue with changing Reset Behaviour from Connect under reset to None.

View solution in original post

2 REPLIES 2
STea
ST Employee

Hello @BahadirA ,

Please refer to the reference manual RM0385 / Table 3. STM32F756xx and STM32F74xxx Flash memory organization of how the sectors are organized.

For erase_init.Sector and erase_init.NbSectors parameters, I propose to follow this example. These two parameters are provided by GetSector().

  FirstSector = GetSector(FLASH_USER_START_ADDR);
  /* Get the number of sector to erase from 1st sector*/
  NbOfSectors = GetSector(FLASH_USER_END_ADDR) - FirstSector + 1;
  /* Fill EraseInit structure*/
  EraseInitStruct.TypeErase     = FLASH_TYPEERASE_SECTORS;
  EraseInitStruct.VoltageRange  = FLASH_VOLTAGE_RANGE_3;
  EraseInitStruct.Sector        = FirstSector;
  EraseInitStruct.NbSectors     = NbOfSectors;

PS: you can also to refer to AN4657 "STM32 in-application programming (IAP) using the USART" for a customized bootloader via UART.

Regards.

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
BahadirA
Associate

I've solved this issue with changing Reset Behaviour from Connect under reset to None.