ECC

From SEGGER Wiki
Jump to: navigation, search

ECC stands for Error-Correcting Code. Memory chips use ECC to detect and correct bit errors which can be caused i.e. by production faults or aging. It is used with non-volatile flash-memory as well as volatile RAM memory. ECC works by generating and storing an ECC code on memory writes, and verify such code on reads. Due to this process, ECC memory can only be read after it is written.

ECC Handling with Flash

With ECC flash, the J-Link software must be set up to prevent any read before write of the memory. This can be done by executing multiple J-Link Command Strings. The following J-Link script code snippet will set up necessary options for ECC protected flash memory:

void ConfigTargetSettings(void) {
  JLINK_ExecCommand("SetCompareMode=0");                // Make sure that J-Link SW does not try to compare before programming
  JLINK_ExecCommand("SetFlashDLNoRMWThreshold=0");      // Make sure that the J-Link SW does not perform a read-modify-write
  JLINK_ExecCommand("SetDisableSkipBlankDataOnProg=1"); // Make sure that areas filled with blank data are also programmed by J-Link SW
  JLINK_ExecCommand("DisableFlashBPs");                 // Because of enabled interrupts and RAM is used for flash programming, we cannot allow flash breakpoints
  return 0;
}

For detailed information about J-Link Command Strings refer to the J-Link Command Strings article

ECC Handling with RAM

ECC RAM will not be readable after reset due to the missing ECC code. The J-Link software offers a convenient method to initialize the work RAM of the device on connect to allow initial read access. While the work RAM area is specified with the device information within the J-Link software, it is adjustable via the J-Link Command String 'SetWorkRAM'. Following J-Link script code snippet will initialize the work RAM:

void ConfigTargetSettings(void) {
  JLINK_ExecCommand("SetInitWorkRAMOnConnect = 1"); // Work RAM will be initialized on connect
  return 0;

For detailed information regarding SetInitWorkRAMOnConnect refer to the J-Link Command Strings article.