Hi,
I have written a short code which attempts to check the ECC mechanism for the SRAM by creating an error in the data bits. But it does not give the expected output. Please refer below. All the functions used are from the Halcogen generated code for TMS570LS31x HDK development kit. The Corresponding ECC memory location is : 0x084000C0. I am using code composer studio.
//The comments are the output expected and observed when doing a line by line debug.
void main(void)
{
volatile uint32 read = 0;
volatile uint32 read2 = 0;
volatile uint32 read3 = 0;
volatile uint32 read4 = 0;
volatile uint64 ecc0 = 0;
volatile uint64 ecc1 = 0;
volatile uint64 ecc2 = 0;
volatile uint64 ecc3 = 0;
volatile uint64 ecc4 = 0;
volatile uint64 ecc5 = 0;
volatile uint64 ecc6 = 0;
volatile uint64 ecc8 = 0;
_esmCcmErrorsClear_();
_coreEnableRamEcc_();
_coreEnableEventBusExport_();
memoryInit(0x1U);
_coreEnableRamEcc_();
(*(volatile uint32 *)(0x080000D8U)) = 0x1U;
ecc8 = (*(volatile uint64 *)0x084000D8U); /* ecc8 = 0xEFEFEFEEEFEFEFEF but in the memory window finally this value is 0xBAD0BAD0EFEFEFEF */
ecc0 = (*(volatile uint64 *)0x084000C0U); /* ecc0 = 0x0C0C0C0C0C0C0C0C */
(*(volatile uint32 *)(0x080000C0U)) = 0x2U;
ecc1 = (*(volatile uint64 *)0x084000C0U); /* ecc1 = 0x0C0C0C0C0C0C0C0C */
read = (*(volatile uint32 *)(0x080000C0U)); /* should be 2 */
ecc2 = (*(volatile uint64 *)0x084000C0U); /* ecc2 = 0xE9E9E9EBE9E9E9E9 */
_coreDisableRamEcc_();
(*(volatile uint32 *)(0x080000C0U)) = 0x0U;
ecc3 = (*(volatile uint64 *)0x084000C0U); /* ecc3 = 0xE9E9E9EBE9E9E9E9 */
read2 = (*(volatile uint32 *)(0x080000C0U)); /*should be 0 */
ecc7 = (*(volatile uint64 *)0x084000C0U);
_coreEnableRamEcc_();
read3 = (*(volatile uint32 *)(0x080000C0U)); /*should be 2 */
ecc4 = (*(volatile uint64 *)0x084000C0U); /* ecc4 = 0xE9E9E9EBE9E9E9E9 */
(*(volatile uint32 *)(0x080000C0U)) = 0x1U;
ecc5 = (*(volatile uint64 *)0x084000C0U); /* ecc5 = 0xE9E9E9EBE9E9E9E9 */
read4 = (*(volatile uint32 *)(0x080000C0U)); /* should be 1 */
ecc6 = (*(volatile uint64 *)0x084000C0U); /* ecc6 = 0xE9E9E9EBE9E9E9E9 when it should have been 0xEFEFEFEEEFEFEFEF according to ecc8 */
while(1);
/* USER CODE END */
}
In the memory window the ECC value for the variable in 0x08000C0 from the location 0x08004C0 is 0xBAD0BAD0EFEFEFEF */
Once the ECC is disabled. It does not enable again. The actual ECC value for 0x1 i.e. ecc5 and ecc6 should have been 0xEFEFEFEEEFEFEFEF. What must be done to bypass this behaviour?
_coreDisableRamEcc_
stmfd sp!, {r0}
mrc p15, #0x00, r0, c1, c0, #0x01
bic r0, r0, #0x0C000000
mcr p15, #0x00, r0, c1, c0, #0x01
ldmfd sp!, {r0}
bx lr
_coreEnableRamEcc_
stmfd sp!, {r0}
mrc p15, #0x00, r0, c1, c0, #0x01
orr r0, r0, #0x0C000000
mcr p15, #0x00, r0, c1, c0, #0x01
ldmfd sp!, {r0}
bx lr
What is the step I am doing wrong? What should I use to test the program if not the debugger as it is giving different outputs?
Regards,
Pritesh