2024-10-24 05:14 AM
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.
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 ?
Solved! Go to Solution.
2024-10-25 06:20 AM
I've solved this issue with changing Reset Behaviour from Connect under reset to None.
2024-10-24 06:35 AM
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.
2024-10-25 06:20 AM
I've solved this issue with changing Reset Behaviour from Connect under reset to None.