This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F280039C: How to understand Flash ECC and How it effect the program run

Part Number: TMS320F280039C
Other Parts Discussed in Thread: TEST2

Hi Expert

Customer want to change one bit of MCU flash from 1 to 0, but meet some interesting test result, below are the background and issues:

Background: they want to change the GPIO0 set high configuration to GPIO0 set low in their customer boot code, so they change the code then build the firmware. The result is they find there is only one bit changes from 0x0201 to 0x0200, so they want to try whether they can use flash API in their APP code to change the flash directly to realize this modification.

So I do the below test with customer:

Test1: Change 0x0201 to 0x0200:

the flash API I call is:    
Fapi_issueProgrammingCommand((uint32 *)0x825e3,&BufferIO,1, 0, 0, Fapi_DataOnly);

Step1: test the GPIO toggle without the Flash API modify the flash -- GPIO toggle normally

Step2: add the flash API Fapi_issueProgrammingCommand before GPIO toggle, rebuild the project.

Step3: the Flash data change can be observed, but when the assembly runs to the GPIO code, the GPIO still toggle as Step1 without any change.

Step4: Power cycle the board, connect the board to PC with XDS, load symbol through CCS, the GPIO code is confirmed to be changed to 0x0200, but the GPIO still toggle as Step1 without any change.

Test 2: Change 0x0201 to 0x0000:

Go through Step1-4, the device will report ECC issue and jump into illegal handler.

Test 3: Change 0x0201 to 0x0200 with ECC disable (tested by customer):

The test result is the same as test1. From my side, even I change ECC_Enable byteto 0xB it will return to 0xA when program run.

Test 4: Change 0x0201 to 0x0000 with ECC disable (tested by customer):

The test result is the same as test2. From my side, even I change ECC_Enable byte to 0xB it will return to 0xA when program run.

So base on the tests above, the questions are:

  1. is the ECC auto correction function makes the GPIO still toggle even the flash data is changed?
  2. why the ECC function and ECC error still be genrated by MCU while ECC is disabled manually?

Thanks

Joe

  • Hi Joe,

    The ECC module is able to correct single-bit errors on its own. This is why the GPIO is not changing - the single bit change is treated as a single bit error and is corrected. When reprogramming flash, you must erase the region before reprogramming it so that both the flash data and the corresponding ECC code are updated.

    When are you setting the ECC_ENABLE bit? It is possible that it is getting set back to 0xA in the device initialization routine. Any modification to the flash registers should be done after calling Flash_initModule().

    Best,

    Alex

  • Hi Alex

    it is getting set back to 0xA in the device initialization routine. Any modification to the flash registers should be done after calling Flash_initModule().

    it make sense that I change the ECC_ENABLE bit manually before click resume, so the register state should be corrected by Flash_initModule(), I will try it after the Flash_initModule().

    This is why the GPIO is not changing - the single bit change is treated as a single bit error and is corrected.

    Does it mean that the program executed according to ECC bytes but not the data in flash when the single bit error occurs?
    But when I disable the ECC, will ECC effect the program execution?

    Thanks

    Joe

     

  • Hi Joe,

    The ECC module contains SECDED (single error correction, double error detection) logic. Since you are only inducing a single bit error, the value read from flash is automatically corrected/changed back to its initial state. Disabling the ECC module will stop this behavior, and the new value 0x0200 will be read.

    Again though, we don't recommend disabling ECC as a solution to this, ideally the customer erases and reprograms the entire flash sector.

    Best,

    Alex

  • Hi Alex

    Thanks for your support, I see some interesting things for ECC disable,

    I use the demo: flashapi_ex1_programming, and use Flash_disableECC(FLASH0ECC_BASE); to disable ECC, use Fapi_issueProgrammingCommand((uint32 *)0x825ab,&BufferIO, 1, 0, 0, Fapi_DataOnly); to change one bit flash.

    if I place the Flash_disableECC behind Flash_initModule and before Example_CallFlashAPI, the ECC will still be enabled:

    but if I place the Flash_disableECC behind Example_CallFlashAPI();, the ECC can be disabled:

    Are there any differences between those 2 operations?

    Customer feedback change the Flash_enableECC  to Flash_disableECC directly in Flash_initModule, will also not disable ECC properly.

    Thanks

    Joe

  • Hi Joe,

    Apologies for the delay in response. In the Example_ProgramUsingDataAndECC and Example_ProgramUsingDataOnlyECCOnly functions, Flash_enableECC is called again, which is why the value resets. You can remove this call to keep ECC disabled.

    Best,

    Alex