Testing ECC on IMX95LPD5EVK-19 Hi, I would like to introduce bit errors into memory to verify EDAC is working. I enabled ECC on the IMX95LPD5EVK-19 board by setting the following option in local.conf: UBOOT_CONFIG = "sd-ecc" The kernel log shows there is an EDAC memory controller: bash-5.3# dmesg | grep EDAC
[ 1.082799] EDAC MC: Ver: 3.0.0 However, the output of the edac-util programs says there is no EDAC memory controller: bash-5.3# edac-util -rfull
edac-util: Error: No memory controller data found. I tried to manually load the EDAC driver, but it didn't work because the memory controller is still missing: bash-5.3# modprobe layerscape_edac_mod
bash-5.3# edac-util --status
edac-util: EDAC drivers loaded. No memory controllers found
bash-5.3# ls /sys/devices/system/edac/mc/
power subsystem uevent Since there is no memory controller, I can't get information about bit errors corrected by ECC, so is there a way to verify that ECC is working? I found an article that gives an example on how to test ECC single-bit and multi-bit error injection, but I couldn't compile the example because the example .c code has undefined variables, such as DDRC, that get referenced in the code: AN14438: ECC on i.MX 93/91/95/943/952/937 and their SoC derivatives | NXP Semiconductors // startAddr: desired SoC start address for error injection (ex. 0x80000000)
// sbeOrMbe: 0 for single-bit error injection
// sbeOrMbe: 1 for multi-bit (2-bit) error injection
uint32_t run_data_err_inj_test(uint32_t startAddr, uint32_t sbeOrMbe)
{
// For ECC testing, ECC is applied on 64-bits
volatile uint32_t *memSrc;
volatile uint32_t addrOffset;
uint32_t TEST_BYTE_CNT = 0U;
uint32_t sbetOriginal; // variable for restoring SBE threshold as it gets
// changed during testing
uint32_t sbetForTest = 0x2U; // change SBET to low value for testing in
// order to trigger on SBE detection
uint32_t failCount = 0U;
// Prior to running SBE testing, first need to set SBE threshold
// By default it is 0 meaning an SBE will not trigger a status error
// Save sbet and restore at end of testing
sbetOriginal = ((DDRC->ERR_SBE) >> 16U) & 0xFFU;
// set SBET to a low value to allow trigger of SBE error
DDRC->ERR_SBE = (sbetForTest << 16);
// Set test size to 1MB as it is the min protected size and to speed up
// testing
TEST_BYTE_CNT = 1024U * 1024U;
// DDR memory map starting address
memsrc=(uint32_t *)startAddr;
// Clear (w1c) ERR_DETECT flags to keep test honest for next corrupted
// ECC test
DDRC->ERR_DETECT = 0xFFFFFFFFU;
// INJECT SBE ECC ERROR
// Write 1-bit to either DATA_ERR_INJECT_LO or DATA_ERR_INJECT_HI
// Writing 1 to a bit in this field causes the corresponding
// data-path bit to be inverted on memory bus writes
DDRC->DATA_ERR_INJECT_LO = 0x00000001U;
// for MBE, write 1-bit to the other DATA_ERR_INJECT register
if (sbeOrMbe==1U) // MBE error injection
{
printf("Perform MBE test\n\r");
DDRC->DATA_ERR_INJECT_HI = 0x80000000U;
}
else // SBE error injection
{
printf("Perform SBE test\n\r");
printf(" SBE threshold: %d\n", sbetForTest);
}
// Configure ERR_INJECT for determining the number of errors to
// inject and to enable error injection
// Configure Number Of ECC Errors Injected, NUM_ECC_INJ. A few
// options list below, uncomment to select:
// BSET32(ERR_INJECT, 0x00001000); // NUM_ECC_INJ=1 (4 errors injected)
// BSET32(ERR_INJECT, 0x00002000); // NUM_ECC_INJ=2 (8 errors injected)
DDRC->ERR_INJECT |= 0x00002000U; // NUM_ECC_INJ=2 (8 errors injected)
// Enable error injection, EIEN=1
DDRC->ERR_INJECT |= 0x00000100U; // set Error Injection Enable
printf(" Number of errors to inject: %d\n", ((DDRC->ERR_INJECT) >>
12)*4);
// Data Synchronization Barrier ensures the completion of memory accesses
__DSB();
// Fill (write) memory with known data for injection testing, errors are
// injected per above programming
for (addrOffset = 0U; addrOffset < TEST_BYTE_CNT/4U; addrOffset++)
{
*(memSrc + addrOffset) = (uint32_t)(memSrc + addrOffset);
}
// Data Synchronization Barrier ensures the completion of memory accesses
__DSB();
// Clear ERR_INJECT register (after writes are complete) to disable
// all error inject features
// Basically, write back the default value of this register
DDRC->ERR_INJECT = 0x00000000U;
// Data Synchronization Barrier ensures the completion of memory accesses
__DSB();
// Now read the addr to trigger an ECC injection error
if (sbeOrMbe == 1U) // MBE error injection
{
// Use the MTCR to trigger an MBE; this will not cause a data abort
// exception. However, an AXI read will cause a data abort. Write
// the MTCR register to use a read-only DRAM test
// set MT_TYP=0x2 (only reads)
DDRC->DDR_MTCR = 0x02000200U;
// now set MT_EN to trigger MTCR reads
DDRC->DDR_MTCR = 0x82000200U;
// wait till MT_EN clears indicating read-test is complete
while(((DDRC->DDR_MTCR) & 0x80000000U) == 0x80000000U);
printf("- MTCR read-only test complete \n\r");
// Read ERR_DETECT to see if status ECC error status flag is set
if (((DDRC->ERR_DETECT) & 0x8U) != 0x8U)
{
printf("**FAIL! Multi bit error test failed \n\r");
printf(" ERR_DETECT: 0x%08X\n\r", (DDRC->ERR_DETECT));
failCount++;
}
else
{
printf("- ERR_DETECT: 0x%08X \n\r", (DDRC->ERR_DETECT));
printf("Data error injection ECC MBE detect test passed! \n\r");
}
}
else
{
// Read memory to trigger an ECC error and verify data is corrected
for (addrOffset = 0U; addrOffset < TEST_BYTE_CNT/4U; addrOffset++)
{
if (*(memSrc + addrOffset) != (uint32_t)(memSrc + addrOffset))
{
printf("**FAIL! Memory read failed!\n\r");
printf(" data: 0x%x\n\r", *(memSrc + addrOffset));
failCount++;
break;
}
}
// Data Synchronization Barrier ensures the completion of memory
// accesses
__DSB();
if (failCount == 0U)
{
//printf(" Memory reads passed \n\r"); // uncomment for debug
}
// Read ERR_DETECT to see if status ECC error status flag is set
if (((DDRC->ERR_DETECT) & 0x4U) != 0x4U)
{
printf("**FAIL! Single bit error test failed \n\r");
printf(" ERR_DETECT: 0x%08X\n\r", (DDRC->ERR_DETECT));
printf(" ERR_SBE: 0x%08X \n\r", (DDRC->ERR_SBE));
failCount++;
}
else
{
printf("- ERR_DETECT: 0x%08X \n\r", (DDRC->ERR_DETECT));
printf("Data error injection ECC SBE detect test passed! \n\r");
}
}
// Clear (w1c) ERR_DETECT flags to keep test honest for next corrupted
// ECC
DDRC->ERR_DETECT = 0x8000000DU;
if ((DDRC->ERR_DETECT) != 0x0U)
{
printf("**FAIL! ERR_DETECT not properly cleared\n\r");
printf("ERR_DETECT=0x%08X\n\r", (DDRC->ERR_DETECT));
failCount++;
}
// Restore SBET to original value
DDRC->ERR_SBE = (sbetOriginal << 16U);
// Clear DATA_ERR_INJECT_LO and DATA_ERR_INJECT_HI
DDRC->DATA_ERR_INJECT_LO = 0x00000000U;
DDRC->DATA_ERR_INJECT_HI = 0x00000000U;
// Perform write-only MTCR to write back corrected data to prevent
// further MBEs
DDRC->DDR_MTCR = 0x01000200U; // set MT_TYP=0x1 (only writes)
DDRC->DDR_MTCR = 0x81000200U; // set MT_EN and MT_TYP=0x1 (only writes)
// wait till MT_EN clears indicating read-test is complete
while(((DDRC->DDR_MTCR) & 0x80000000U) == 0x80000000U);
printf("- MTCR write-only test complete \n\r");
return failCount;
} I would appreciate it if someone could help me define the missing variables so I can compile the program, or give me a different method for verifying ECC. Re: Testing ECC on IMX95LPD5EVK-19 Hi @luislicea
Regarding the test and verification functionality for ECC, the DDR Config tool has not yet been released.
You can refer to my article below on ECC verification for the i.MX 93, which includes a sample test program for ECC.
https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/How-to-test-the-ECC-feature-on-the-i-MX93-EVK-board/ta-p/2131352
However, I cannot provide you with the source code, as it has not yet been officially released.
B.R
View full article