Example for Error Management (Custom Handler) - 2020.2 English

Zynq UltraScale+ MPSoC Software Developer Guide (UG1137)

Document ID
Release Date
2020.2 English

For this example, OCM uncorrectable error (EM_ERR_ID_OCM_ECC) is considered. The default error action for this error is set to PS Error Out. In the following example, a custom handler is registered for this error in PMU firmware and the handler in this case just prints out the error message. In a more realistic case, the corrupted memory may be reloaded, but this example is just limited to clearing the error and printing a message.

Adding the Error Handler for OCM Uncorrectable ECC in PMU firmware:

+++ b/lib/sw_apps/zynqmp_pmufw/src/xpfw_mod_em.c
@@ -140,6 +140,14 @@ void FpdSwdtHandler(u8 ErrorId)
+/* OCM Uncorrectable Error Handler */
+static void OcmErrHandler(u8 ErrorId)
+ XPfw_Printf(DEBUG_DETAILED, "EM: OCM ECC error detected\n");
+ /* Clear the Error Status in OCM registers */
+ XPfw_Write32(0xFF960004, 0x80);
+ /* CfgInit Handler */
 static void EmCfgInit(const XPfw_Module_t *ModPtr, const u32 *CfgData,
 u32 Len)
@@ -162,6 +170,8 @@ static void EmCfgInit(const XPfw_Module_t *ModPtr, const u32
+ XPfw_EmSetAction(EM_ERR_ID_OCM_ECC, EM_ACTION_CUSTOM, OcmErrHandler);
 if (XPfw_RecoveryInit() == XST_SUCCESS) {
 /* This is to enable FPD WDT and enable recovery mechanism when

To inject OCM Uncorrectable ECC error using debugger (xsdb):

;# Enable ECC UE interrupt in OCM_IEN
mwr -force 0xFF96000C [expr 1<<7]

;# Write to Fault Injection Data 0 Register OCM_FI_D0
;# Errors will be injected in the bits which are set, here its bit0, bit1
mwr -force 0xFF96004C 3

;# Enable ECC and Fault Injection
mwr -force 0xFF960014 1
# Clear the Count Register : OCM_FI_CNTR
mwr -force 0xFF960074 0
;# Now write data to OCM for the fault to be injected
# Since OCM does a RMW for 32-bit transactions, it should trigger error here
mwr -force 0xFFFE0000 0x1234

;# Read back to trigger error again
mrd -force 0xFFFE0000