"Hello, when performing UDS (Unified Diagnostic Services) flashing on a vehicle, we encountered an issue where the erase function reported an error, resulting in an unsuccessful flash write. Upon powering down the ECU (Electronic Control Unit) and then re-energizing it, and attempting to trigger the flash again, the error persisted, preventing the ECU from completing the flash write process. What could be the potential reasons leading to this problem?"
START_FUNCTION_DEFINITION_RAMSECTION
static status_t FLASH_DRV_CommandSequence(const flash_ssd_config_t * pSSDConfig)
{
status_t ret = STATUS_SUCCESS; /* Return code variable */
/* Clear CCIF to launch command */
FTFx_FSTAT |= FTFx_FSTAT_CCIF_MASK;
while (0U == (FTFx_FSTAT & FTFx_FSTAT_CCIF_MASK))
{
/* Wait till CCIF bit is set
* Serve callback function as often as possible
*/
if (NULL_CALLBACK != pSSDConfig->CallBack)
{
/* Temporarily disable compiler's check for ROM access call from within a ram function.
* The use of a function pointer type makes this check irrelevant.
* Nevertheless, it is imperative that the user-provided callback be defined in RAMSECTION */
DISABLE_CHECK_RAMSECTION_FUNCTION_CALL
(pSSDConfig->CallBack)();
ENABLE_CHECK_RAMSECTION_FUNCTION_CALL
}
}
/* Check if an error is occurred */
if ((FTFx_FSTAT & (FTFx_FSTAT_MGSTAT0_MASK | FTFx_FSTAT_FPVIOL_MASK | FTFx_FSTAT_ACCERR_MASK | FTFx_FSTAT_RDCOLERR_MASK)) != 0U)
{
ret = STATUS_ERROR;
}
return ret;
}
END_FUNCTION_DEFINITION_RAMSECTION
"During the debugging process, we discovered that the value of the FSTAT register is 0x81, with the MGSTAT0 bit set to 1. We are interested in understanding what circumstances could lead to this bit being set to 1. What steps can we take to resolve this issue? Should we consider re-flashing the unit using a programmer?"