Skip to main content
AShar.9
Associate II
November 19, 2020
Solved

HAL Flash Sector Erase Fails in STM32F767

  • November 19, 2020
  • 2 replies
  • 1390 views

I am implementing a custom bootloader for STM32F767 controller. Bootloader and application are in different sectors and on an update bootloader erases the application's sector and writes a new one. This works well, but sometimes the bootloader fails to clear the application's sector properly. Further attempts to clear it keep on failing. I can manually clear that sector with STVP and bootloader is then able to flash a new update there just fine.

Any help is appreciated.

Thanks

if(HAL_FLASH_Unlock() != HAL_OK)
 return FALSE;
FLASH_EraseInitTypeDef flashErase = 
{
 .TypeErase = FLASH_TYPEERASE_SECTORS,
 .Sector = FLASH_SECTOR_5,
 .NbSectors = 1,
 .VoltageRange = FLASH_VOLTAGE_RANGE_4
};
HAL_FLASHEx_Erase_IT(&flashErase);

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

Voltage range 4 and double word programming/erase is not for a normal usage. RM0410 section 3.3.5 tells it clearly. Flash program/erase operations blocks code execution from flash anyway, therefore there is almost no use of interrupts for those operations. Again - read the reference manual section 3.3.3!

2 replies

TDK
November 19, 2020

Any reason you're using HAL_FLASHEx_Erase_IT instead of HAL_FLASHEx_Erase?

"If you feel a post has answered your question, please click ""Accept as Solution""."
AShar.9
AShar.9Author
Associate II
November 20, 2020

The device has internal watchdog running that was resetting the device when I used HAL_FLASHEx_Erase.

Piranha
PiranhaBest answer
Principal III
November 26, 2020

Voltage range 4 and double word programming/erase is not for a normal usage. RM0410 section 3.3.5 tells it clearly. Flash program/erase operations blocks code execution from flash anyway, therefore there is almost no use of interrupts for those operations. Again - read the reference manual section 3.3.3!

AShar.9
AShar.9Author
Associate II
December 16, 2020

Thanks for your comment. This was an overlook from my side. It works fine with reduced voltage range. Thanks again.