Skip to main content
Associate
October 24, 2024
Solved

STM32F746 Flash Sector Erase Problem

  • October 24, 2024
  • 2 replies
  • 934 views

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 ?

This topic has been closed for replies.
Best answer by BahadirA

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

2 replies

ST Employee
October 24, 2024

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.
BahadirAAuthorBest answer
Associate
October 25, 2024

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