[STM32H7] Flash write returns OK, yet hard fault during read-back
I have an STM32H7, and despite a HAL_OK for every write,
HAL_FLASH_Unlock();
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_FLASHWORD, 0x081E0000+ (32*fw), (uint32_t)(pBuffer)) != HAL_OK)
{
Error_Handler();
}
HAL_FLASH_Lock();
OCCASIONALLY, the write appears to cause an alignment/ECC error. Simply READING from the sector after writing, will cause a Hard-Fault/IRQ0. The only way to recover, is to use the bootloader to erase.
For testing, I'm writing an incrementing pattern, and the fault seems to happen randomly at a different address/data each time.
The source buffer is in it a section of memory that has dma buffers, not sure if that could be causing a problem. Is there a way to find what exactly is the cause and/or a way to disable the ECC (if it's due to an alignment issue) and/or CACHE?
