A write to flash goes ok, but a subsequent read triggers a machine exception and my program gets stuck in the IVOR1 exception handler.
The content of some exception handling control registers:
The content of C55FMC.MCR:
The write and reads are both 8 bytes to address 0x00f9_0000.
I'm a bit lost in the weeds here: What kind of actions would trigger a EEC error? Since it's happening consistently I assume that I must do something wrong when reading or writing to flash.
I'm still working on reduce the program down into something smaller, but I thought I might start of a question thread in case you have any immediate suggestions about what to investigate?
I'm attaching my flash-driver. Here is the write-function that calls into the driver.
bool FlashInfo::WriteSerialNumber(uint8_t const *number)
{
if (m_State != IDLE) // busy
return false;// Start writing
if (m_Flash.StartWriting(FlashInfo::SERIAL_NUMBER, Flash::dataFlash) == false) // command rejected
return false;
else
{
uint8_t SerialNumber[10]; // including checksum
memcpy(SerialNumber, number, 8);
uint16_t Checksum = CalculateChecksum(number, 8);
SerialNumber[8] = Checksum>>8;
SerialNumber[9] = Checksum;
if (m_Flash.AddData(SerialNumber, 10) == false)
{
m_Flash.StopWriting();
return false;
}
else
m_Flash.Write();
}m_State = WRITING_SERIAL_NUMBER;
return true;
}
Here is the read-function:
bool FlashInfo::ReadSerialNumber(uint8_t* buffer)
{
// Read serial number from flash
memcpy(buffer, SERIAL_NUMBER, 8);// Read checksum from flash
uint16_t Checksum = ((*SERIAL_CHECKSUM)<<8) // high byte
+ *(SERIAL_CHECKSUM+1); // low byteif (Checksum == CalculateChecksum(buffer, 8))
return true;
else
return false;
}
Hi, It may be several reasons, in the flash memory typically one of following reason:
- Unexpected reset during flash erase or flash program operation
- Wear out of particular flash sector = number of program/erase cycles that device’s flash is capable to withstand is exceded (in practice, real endurance is greater than specified minimum).
- Over-programming of particular flash area that is programming without erasing. It is basically software fault.
- Soft error (radiation, electro-magnetic interference, or electrical noise) during reading or executing from flash memory
- Generally it may be caused by HW fault due to damage caused by running the device out of spec whatever way.
- Finally ECC error may be intentionally generated by ECC error injection.
In your case I would guess, it could be caused by over-programming. I would try to check (debug) whether programmed area in really erased before attempt to program.