Question
Implementing a sector erase using the HAL layer for flash manipulation--Updated
I have been attempting to implement the HAL layer for flash erasing, and decided the most effective erase is sequential sector erases for my application (creating a custom bootloader).
I have found that calling a single sector erase does not cause any issues for my MCU. However, if I do multiple sector erases sequentially, the MCU crashes. Am I missing something fundamental? Is this not possible?
// Erase current flash
uint8_t Bootloader_Erase(void)
{
HAL_FLASH_Unlock();
FLASH_Erase_Sector(FLASH_SECTOR_3);
FLASH_Erase_Sector(FLASH_SECTOR_4);
FLASH_Erase_Sector(FLASH_SECTOR_5);
HAL_FLASH_Lock();
}