2021-01-24 12:52 PM
We are having issues with corrupted flash on the STM32 H7 series. The problem manifests where a read to the offending address in flash will cause a bus fault. We think it is down to bad CRC and the way to resolve is usually to wipe the flash and reprogram. What I would like to do is do this on the fly, so detect the offending address and erase the page. I was hoping to do this roughly though the following:
// enable the busfault handler
SCB->SHCSR|= SCB_SHCSR_BUSFAULTENA_Msk;
// disable all faults
__disable_fault_irq();
__DSB();
// read the offending data here
read()
// check the outcome
if (SCB->SHCSR & SCB_SHCSR_BUSFAULTPENDED_Msk) {
// erase the sector here
}
// reset
__enable_fault_irq();
__DSB();
SCB->SHCSR &= ~SCB_SHCSR_BUSFAULTENA_Msk;
However this does not work - the fault is prevented correctly but the pending bit is never set and I don't seem to have anyway to detect that a bus fault would have occurred
What am I missing? Or am I totally barking up the wrong tree?
2022-11-15 06:59 AM
Hello @APipe.2,
not CRC but ECC.
The bus fault is a result of 2-bit error in the program memory, the ECC can handle 1-bit errors. Most of the time one error exists in the flash word before a second bit goes bad. So here I'd recommend to enable the 1-bit error interrupt (ECCC) and try fixing the problem before it escalates to ECCD - two bit error detection.
BR,
J
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.