Other Parts Discussed in Thread: UNIFLASH, TMS570LS3137
Hi Team,
There's an issue from the customer need your help:
First, I used uniflash to program the .out file into the flash of the chip. Uniflash has its own auto ecc generation function, which can automatically program the ecc area.
Then, I added to the startup code of my project
/* Enable CPU Event Export */
/* This allows the CPU to signal any single-bit or double-bit errors
detected
* by its ECC logic for accesses to program flash or data RAM.
*/
_coreEnableEventBusExport_();
/* USER CODE BEGIN (9) */
/* USER CODE END */
/* Enable response to ECC errors indicated by CPU for accesses to flash */
flashWREG->FEDACCTRL1 = 0x000A060AU;
/* USER CODE BEGIN (10) */
/* USER CODE END */
/* Enable CPU ECC checking for ATCM (flash accesses) */
_coreEnableFlashEcc_();
This should enable the chip's flash ecc verification.
I want to verify the flash ecc check of the chip. I found that the flash of the chip comes with 7 diagnostic modes. I found the void checkFlashECC(void) function in the sys_selftest.c file. This function uses diagnostic mode 7 to automatically modify the ecc value read by the CPU to set single-bit and double-bit errors to verify the correctness of the flash ecc.
But I found that in this function, after turning on diagnostic mode 7, the address accessed was not flash, but the mirrored image of flash was selected.
#define flashBadECC1 (*(volatile uint32 *)(0x20000000U))
#define flashBadECC2 (*(volatile uint32 *)(0x20000000U))
volatile uint32 flashread = 0U;
/* USER CODE BEGIN (40) */
/* USER CODE END */
/* Flash Module ECC Response enabled */
flashWREG->FEDACCTRL1 = 0x010A060AU;
/* Enable diagnostic mode and select diag mode 7 */
flashWREG->FDIAGCTRL = 0x00050007U;
/* Select ECC diagnostic mode, single-bit to be corrupted */
flashWREG->FPAROVR = 0x00005A01U;
/* Set the trigger for the diagnostic mode */
flashWREG->FDIAGCTRL |= 0x01000000U;
/* read a flash location from the mirrored memory map */
flashread = flashBadECC1;
/* disable diagnostic mode */
flashWREG->FDIAGCTRL = 0x000A0007U;
In this way, adding some debugging code to this function can reveal that single-bit errors and double-bit errors can change the value of the register flashWREG->FEDACSTATUS, that is, the CPU has detected an error.
However, when I changed the above flashBadECC1 flashBadECC2 to the flash area, I found that the value of the register flashWREG->FEDACSTATUS was still 0, that is, the CPU could not detect the error.
What's going on? Or is there any other way to check the function of flash ecc.
Thanks & Regards,
Ben