Skip to main content
AShar.9
Associate II
Nov 19, 2020 10:42 AM UTC
Solved

HAL Flash Sector Erase Fails in STM32F767

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.
Piranha
PiranhaBest answer
Principal III
Nov 26, 2020 11:26 PM UTC

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!

4 replies

TDK
Nov 19, 2020 1:37 PM UTC

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
Nov 20, 2020 5:22 AM UTC

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

Piranha
PiranhaBest answer
Principal III
Nov 26, 2020 11:26 PM UTC

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
Dec 16, 2020 12:23 PM UTC

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