cancel
Showing results for 
Search instead for 
Did you mean: 

HAL Flash Sector Erase Fails in STM32F767

AShar.9
Associate II

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);

1 ACCEPTED SOLUTION

Accepted Solutions
Piranha
Chief II

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!

View solution in original post

4 REPLIES 4
TDK
Guru

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".

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

Piranha
Chief II

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!

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