TMS320C6657: DSP Rom Bootloader (RBL) NAND Bootloader support ECC?

Part Number: TMS320C6657
Other Parts Discussed in Thread: TMS320C6652, TMDSEVM6657, TMS320C6655

We are currently seeing some issues where there is "bit rot" of the intermediate bootloader (IBL) programmed into a NAND flash device attached to the DSP.   From the KeyStone Architecture DSP Bootloader User Guide  section 3.11 it seems to imply that the RBL should be doing some ECC but we are not seeing that.

In our investigation (pulling the data from the NAND device) we see that one bit has been flipped (corrupted) in the intermediate bootloder image residing in teh NAND device.  This one bit corruption prevents the IBL from running and our sytem from booting.

So the question is, "does the RBL strapped to NAND boot actually run ECC?"   

  • Hello,
    Thank you for your inquiry. **x1125363@ti.com** is currently on leave and will be available on **2026-08-28**.
    Your query will be addressed upon their return. We appreciate your patience and understanding.
    Best regards,
    TI E2E Support Team
    ---
    *This is an automated notification.*

  • does the RBL strapped to NAND boot actually run ECC?

    Hi Tom,
    From my understanding RBL should run ECC. Could you please refer the thread "TMS320C6678: NAND Error Management (ECC - EMIF interface) - Processors forum - Processors - TI E2E support forums" regarding timing issue to perform ECC in nand configuration.

    Regards,

    Ben

  • Hello,

    The issue is more focused on the ROM bootloader that is strapped for direct NAND boot.  The ECC in teh RBL does not appear to be able to correct a single bit error when booting from the the NAND.

    We were looking through the ROM Bootloader source code found at the following location: https://software-dl.ti.com/sdoemb/sdoemb_public_sw/rbl/1_0_C6657/index_FDS.html. Could you confirm whether this is indeed the code that the RBL is running during NAND boot? If so, then we have a question around lines 296-316 of BootROM_c6657_PG1.0\C665x_bootROM_src\hw\nand\device_nand.c. (see image below).

    Specifically, if an error is detected on line 296, then bit [13] of the NANDFCR register is written (line 304) so that the addresses and values can be computed. Then there is a do-while loop (lines 308-313) that waits until NANDFSR[11:10] are non-zero or there is a timeout. Assuming there isn’t a timeout, then these two bits of NANDFSR (which are the two MSBs of CORR_STATE[3:0]) will become non-zero almost immediately, because these states correspond to when the hardware is performing the actual error search, calculating the addresses and values, etc. Then, what is assumed to be the final correction state is read from NANDFSR (line 316) and if it’s either equal to 1 (errors cannot be corrected) or greater than 3 (searching/calculating), then the function returns a fault. We have seen it take up to seven reads of the NANDFSR register before a final CORR_STATE (such as 0x1, 0x2 or 0x3) is actually achieved.

     Based on the code comment (“Loop until timeout or the ECC calculations are complete (bit 11:10 == 00b”), it seems like the condition on line 313 should read “while ( (i > 0) && (temp == 0) )”, not “while ( (i > 0) && (temp != 0) )”. Could you confirm whether the released RBL code has a different do-while loop condition.

     SNIP FROM "device_nand.c" (lines 271 to 330):

    --------------------------------------------------------------------------------------------------------------------------------

    UINT32 DEVICE_NAND_ECC_correct(UINT8 *data, UINT8 *readECC)
    {
    VUINT32 temp, corrState, numE;
    UINT32 i, j;
    UINT16 addOffset, corrValue;
    UINT16 syndrome10[8];

    /* Convert the byte array to a 16 bit array. The data arrived in little
    * endian order */
    for (i = j = 0; i < 8; i++, j += 2)
    syndrome10[i] = (readECC[j+1] << 8) | readECC[j];

    // Clear bit13 of NANDFCR
    temp = AEMIF->NANDERRADD1;

    // Load the syndrome10 (from 7 to 0) values
    for(i=8;i>0;i--)
    {
    AEMIF->NAND4BITECCLOAD = (syndrome10[i-1] & 0x000003FF);
    }

    // Read the EMIF status and version (dummy call)
    temp = AEMIF->ERCSR;

    // Check if error is detected
    temp = (AEMIF->NAND4BITECC1 & 0x03FF03FF) | (AEMIF->NAND4BITECC2 & 0x03FF03FF) |   <--- line 296
    (AEMIF->NAND4BITECC3 & 0x03FF03FF) | (AEMIF->NAND4BITECC4 & 0x03FF03FF);
    if(temp == 0)
    {
    return NAND_RET_OK;
    }

    // Start calcuating the correction addresses and values
    AEMIF->NANDFCR |= (0x1U << DEVICE_EMIF_NANDFCR_4BITECC_ADD_CALC_START_SHIFT);   <--- line 304

    // Loop until timeout or the ECC calculations are complete (bit 11:10 == 00b)
    i = NAND_TIMEOUT;
    do
    {
    temp = (AEMIF->NANDFSR & DEVICE_EMIF_NANDFSR_ECC_STATE_MASK)>>10;
    i--;
    }
    while((i>0) && (temp != 0x0));  <--- line 313

    // Read final correction state (should be 0x0, 0x1, 0x2, or 0x3)
    corrState = (AEMIF->NANDFSR & DEVICE_EMIF_NANDFSR_ECC_STATE_MASK) >> DEVICE_EMIF_NANDFSR_ECC_STATE_SHIFT; <--- line 316

    if ((corrState == 1) || (corrState > 3))
    {
    temp = AEMIF->NANDERRVAL1;
    return NAND_BOOT_ERROR_ECC_CORRECT_STATE;
    }
    else if (corrState == 0)
    {
    return NAND_RET_OK;
    }
    else
    {
    // Error detected and address calculated
    // Number of errors corrected 17:16

    --------------------------------------------------------------------------------------

  • Hi Tom, 

    I have to check this with the team and will provide you a response within a day.

    Regards,

    Ben

  • Hi Ben,

     

    Great, thank you. In the interim, we have one clarification, plus some additional information that should be useful. The actual issue with the do-while loop (lines 308-313) is that there isn’t enough time after writing to the NANDFCR register before entering into the loop, such that the first read of the NANDFSR occurs before the calculation of the correction addresses and values has even begun. So, the CORR_STATE[11:10] bits have not yet become non-zero when entering into the loop, which causes the loop to break out immediately. This is where the additional seven reads of the NANDFSR register come into play before a final state of 0x1, 0x2 or 0x3 are reached. This appears to be the very issue that you originally linked us to (https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1087529/tms320c6678-nand-error-management-ecc---emif-interface/4030371?tisearch=e2e-sitesearch&keymatch=EMIF25_FLASH_CTL_REG), but we’re encountering it in the RBL code instead of the IBL code.

     

    This race condition leads to bit errors going uncorrected. For example, we have a NAND flash with two known bit errors, one at block/page/segment 0/7/2 and the other at 0/12/1. Knowing what spare bytes will be read for these two segments allows us to connect a debugger and set a hardware watchpoint while the RBL is running. We placed watchpoints in order to halt the processor on the write of the spare (OOB) bytes into the NANDF4BECCLR register (line 289), then repeatedly (about 38 times) click the “Assembly Step Into” button through Code Composer until we see the NANDFCR register written (line 304). Then we step through the assembly code another ~10 times in order to get on the other side of the do-while loop. We repeat this process for the second known NAND bit error, then simply hit “Resume” and the RBL successfully hands over control to the IBL that has been corrected/copied into RAM.

     

    It appears that we need to implement the same sort of delay mentioned for the IBL, but somehow in the RBL. Is this truly ROM code, or is there some way that it can be updated? Or perhaps there’s something that we could change in our boot table parameters that would introduce a delay during this interaction with the ECC hardware?

     

    Thanks

  • Hi Tom,

    The source code you referenced is published by TI as developer reference code used for the reference for customers to implement on custom boards and would not be the exact code of the boot rom loader. The updated version of the reference is provided in this link Keystone Device Architecture - Texas Instruments Wiki.
    On the boot parameter table: the NAND Mode Boot Parameter Table is documented in the C6655/C6657 data manual, Section 6.28.3.4 (Table 6-89): https://www.ti.com/lit/ds/symlink/tms320c6657.pdf

    Looking at the full table, there's no field that reaches the ECC timing it's limited to I2C bus parameters, chip-select region, and first block number. So this table can't be used to introduce the delay you're looking for.

    Regards,
    Ben

  • So then why is the RBL not running properly and correcting a single bit error detected in the NAND flash?  We have proven that if you pause the the RBL when it detects the error and allow for the ECC calculations to complete then resume the RBL running it can correct the error.

    Is there a timing bug in the RBL running on the DSP?   (the RBL continues without waiting on the ECC calc to finish) 

    Is there anyway we can update the RBL in the DSP?

  • Is there a timing bug in the RBL running on the DSP?   (the RBL continues without waiting on the ECC calc to finish) 

    I have reviewed the errata document and found no reported issues related to RBL timing.

  • We did not see any errata against this issue either ...  but we are still seeing the RBL during direct NAND boot still fails to correct a single bit error when it copies the IBL to RAM and thus the DSP fails to boot.

    ????

  • Hi Tom,

    Is there anyway we can update the RBL in the DSP?

    We cannot modify the RBL source code, as the ROM Boot Loader (RBL) is programmed into ROM during device manufacturing and is not modifiable, as noted in document provided here:  Slide 1.

    Regards,

    Ben

  • So is there any specific strapping or other configurations settings or file formatting that we should check/verify that might influence the ability of RBL's EMIF interface to run the ECC during a direct NAND boot?  If the NAND image is error free the RBL and our IBL run flawlessly.

  • Hi Tom,

    As the issue appears to be with the IBL boot image, have you tried rebuilding the boot image and checking whether the issue still persists.

    Additionally, could you confirm whether the boot image was generated by following the steps outlined in the FAQ below.

     [FAQ] PROCESSOR-SDK-C665X: IBL Build Steps on Linux (Ubuntu) (Processor family: C665x /C667x) - Pro…. 

    Regards,
    Ben

  • Our image is fine.

    When there is not bit error (from bit rot) in the NAND the RBL successfully copies the image in the NAND (RBL=Direct NAND boot) to RAM and the image starts running successfully on the DSP. No issues.

    The problem is when there is a "bit rot" bit error in the image data located in the NAND, in this case the RBL "fails" to successfully copy the image from NAND to RAM (the RBL does not do ECC), thus the DSP is not running.

    Is there a known bug in the RBL boot code for "Direct NAND boot" that doesn't allow the RBL code to run ECC?  

  • Hi Tom,

    I couldn't find any reported bugs related to this.


    Regards,
    Ben

  • So is it TI's recommended solution to NOT use "Direct NAND boot"  hardware strapping option for the RBL to load the DSP image?  Since the DSP's RBL code is not capable of correcting (ECC) a single bit error from bit rot effects to the image stored in the NAND? 

  • Hi Tom,

    Let me check this internally and provide you with an update within one day.

    Regards,
    Ben

  • Hi Tom,

    The expert has suggested reprogramming the flash at run time to prevent data bit errors.

    This could help avoid bit errors during the boot process.

    Regards,
    Ben

  • I dont think you or the expert are getting what the issue is.   

    There is no sw running other than the rom bootloader (rbl) embedded in the device.

    The rbl is the only sw running and it cannot correct a bit error in the nand image as it reads it during direct NAND boot.

  • Hi Tom,
    Could you please let us know on how many boards this issue has been reproduced.
    Regards,
    Ben

  • We have verified that we can reproduce this issue on any of our boards.  All we have to do is inject a "single" bit error in the NAND image and the RBL will fail to pull the image and boot the processor.  If you then correct the bit error the RBL functions properly pulling the image from NAND and booting the processor successfully.

  • Hi Tom,

    Could you please try booting using SPI NOR and let us know if you observe the same issue?

    You may refer to the following FAQ:

    e2e.ti.com/.../faq-tms320c6657-how-to-run-the-direct-spi-boot-example-on-ti-c6657-evm-without-ibl [e2e.ti.com]

    Regards,
    Ben

  • Our custom board does not have the ability to use SPI NOR as a boot source.  Our custom board is using direct NAND boot.

  • Hi Tom,


    Thank you for the update. I will discuss this with the expert and get back to you with an update on this thread.

    Regards,
    Ben

  • Hi Ben, Tom,

    We are seeing the same issue on a custom C6652 board. Our observations are consistent with Tom’s report. Adding our data in case it helps.

    Setup

    • Device: TMS320C6652 (C665x boot ROM), direct NAND boot
    • NAND: Micron MT29F1G08ABBEAH4-AITX:E (1Gb SLC, 1.8V, x8, 2048+64 B/page, ID 2C A1 80 15 04)
    • IBL in block 0, written with spare-area ECC generated by the EMIF16 4-bit ECC engine (6 bytes 0xFF + 10 bytes ECC per 512-byte segment)

    Symptom

    • At low temperature, direct NAND boot fails. A raw dump of block 0 (ECC disabled) shows [2] bit flips compared to the room-temperature dump, all 1→0, at most one per 512-byte segment. This is well within the 4-bit correction capability.
    • Fault injection: we deliberately flipped a single bit inside the IBL region and rewrote the page with the original (correct) ECC. Boot fails every time. Restoring the bit restores boot.
    • Our own IBL NAND driver, reading the same page with the same EMIF16 ECC engine, detects and corrects the error correctly (numErrors = 1, correct byte offset and value). So the stored ECC is valid and the hardware engine works.

    Reproduction (any board, room temperature)

    1. Program the IBL to block 0 with valid spare ECC.
    2. Read one IBL page raw (data + spare), flip one data bit, erase and reprogram the page with the original spare ECC.
    3. Boot in NAND mode. The RBL fails to load a working IBL, while our IBL driver reading the same page corrects the bit.

    Questions

    1. Can TI confirm whether the RBL NAND boot path corrects single-bit ECC errors, and whether the timing issue Tom described is a known erratum?
    2. Is there any boot configuration or setting (EMIF16 clock or timing set by the RBL, PLL setting, boot parameter table field) that affects RBL ECC correction?
    3. Was this fixed in any silicon revision of C665x/C667x?
    4. If not, what is TI’s recommended mitigation for products that must use direct NAND boot? We are currently planning an IBL “self-scrub”: on every boot the IBL re-reads its own image with ECC, and if any correction occurs, it rewrites block 0 from the corrected copy. We would appreciate TI’s view on this approach.

    Thanks,
    [Lee / ITSCIENCE]

    • Can TI confirm whether the RBL NAND boot path corrects single-bit ECC errors, and whether the timing issue Tom described is a known erratum?
     No, its not a known erratum.All know documented SI and RBL issues for PG 1.0 are documented here: https://www.ti.com/lit/er/sprz381c/sprz381c.pdf?ts=1793727574344&ref_url=https%253A%252F%252Fwww.google.com%252F. Note: The errata document has not been updated over the last decade. 
  • Hi Tom, Lee,


    One possible workaround that may be worth trying is using I2C boot before proceeding with NAND boot.It was suggested as an alternative approach by the experts.

    Regards,
    Ben

  • Hi Tom, Lee,

    Thank you for the detailed analysis and test results. The answers below cover Lee's four questions and Tom's question, with references at the end. These devices are in maintenance mode and TI has not validated these suggestions on hardware, so please confirm them with the test at the end first.

    Can TI confirm whether the RBL NAND boot path corrects single-bit ECC errors, and whether the timing issue Tom described is a known erratum?

    No. The RBL detects the error but, in the published source, reads the result before the ECC engine has calculated it, so a single-bit error is not corrected. It is not a documented erratum: SPRZ381C has no NAND or boot ROM entry. The errata document has not been updated over the last decade as the device are in maintaince mode.

    In DEVICE_NAND_ECC_correct() [1, hw/nand/device_nand.c]:

        304  AEMIF->NANDFCR |= (0x1U << DEVICE_EMIF_NANDFCR_4BITECC_ADD_CALC_START_SHIFT);
        ...
        308  do
        309  {
        310    temp = (AEMIF->NANDFSR & DEVICE_EMIF_NANDFSR_ECC_STATE_MASK)>>10;
        311    i--;
        312  }
        313  while((i>0) && (temp != 0x0));
        ...
        316  corrState = (AEMIF->NANDFSR & DEVICE_EMIF_NANDFSR_ECC_STATE_MASK) >> DEVICE_EMIF_NANDFSR_ECC_STATE_SHIFT;

    CORR_STATE (ECC_STATE in this source) is NANDFSR[11:8] [1, hw/nand/nand_emif.h lines 127-128; 4, ti/csl/cslr_emif16.h]. The loop ends as soon as bits 11:10 are 0, which is true for any state from 0 to 3. TI's Linux driver for the same EMIF 4-bit ECC engine documents that the state is still in that range right after the start bit is set:  "ECC_STATE field reads 0x3 (Error correction complete) immediately after setting the 4BITECC_ADD_CALC_START bit." "The recommendation from the hardware team is to initially delay as long as ECC_STATE reads less than 4."

    So the RBL loop exits on its first read, as Tom observed, and line 316 reads the state before the result exists. The engine is most likely busy at that point. In that case the function returns an error (lines 318-322) and the page read fails (hw/nand/nand.c lines 310-313). The RBL then moves on to page 0 of the next block without restarting the boot-image parsing (main/nandmain.c lines 221-231). With a single copy of the image, the boot fails.

    An error in the stored ECC bytes also stops the boot. Even with correct timing, the RBL returns an error for any error located in the ECC bytes, that is beyond byte 511 (device_nand.c lines 336-355). The Linux driver and the PDK IBL ignore errors at those positions (512-519).

    Is there any boot configuration or setting (EMIF16 clock or timing set by the RBL, PLL setting, boot parameter table field) that affects RBL ECC correction?

    I don't think so.

    Was this fixed in any silicon revision of C665x/C667x?

    SPRZ381C covers C6652/54/55/57 silicon revision 1.0 only and has no entry for this. The published RBL source is PG1.0. The RBL is in mask ROM and cannot be updated.

    If not, what is TI’s recommended mitigation for products that must use direct NAND boot? We are currently planning an IBL “self-scrub”: on every boot the IBL re-reads its own image with ECC, and if any correction occurs, it rewrites block 0 from the corrected copy. We would appreciate TI’s view on this approach.

    The ROM handles one case correctly: if a page fails before anything has been loaded, it restarts from the next block. The suggested fix builds on this:

    a) Make the image the RBL loads a small loader that fits in one NAND page, including the boot-table header (2 KB on a 2048-byte-page NAND). Store copies in page 0 of several good blocks, starting at the first boot block (for example blocks 0-7). This uses the one case the RBL handles cleanly. When page 0 of a block fails, nothing has been parsed yet, so the RBL starts again cleanly at page 0 of the next block (main/nandmain.c lines 212 and 221-231).
    Write the whole page with ECC, padding included. The RBL checks every 512-byte segment of the page (hw/nand/nand.c lines 302-313) and has no exception for erased segments. The first boot block is block 0 unless the boot pins select another one, from 0 to 31 (devices/gauss/gauss.h lines 206-207 and 973).

    b) In the loader and the IBL, wait for the ECC engine as the Linux driver does. The PDK IBL polls straight after setting the start bit (ti/boot/ibl/src/hw/nands/emif25/nandemif25.c lines 166-186). It already skips erased pages and ignores errors at 512-519 (lines 120-125 and 206-209), so it needs only the wait:

        v = DEVICE_REG32_R (DEVICE_EMIF25_BASE + EMIF25_FLASH_CTL_REG);
        DEVICE_REG32_W (DEVICE_EMIF25_BASE + EMIF25_FLASH_CTL_REG, v | (1<<13));

        /* Wait for the ECC engine to start: CORR_STATE reads 0-3 until it does */
        for (i = 0; i < NAND_ECC_START_POLLS; i++) {
            v = DEVICE_REG32_R (DEVICE_EMIF25_BASE + EMIF25_FLASH_STATUS_REG);
            if (((v >> 8) & 0x0f) >= 4)
                break;
        }

    NAND_ECC_START_POLLS is a new constant. Size it for at least 100 us, as the Linux driver does. Add a timeout to the existing loop that follows, which waits for the final state.

    c) Keep two copies of the IBL or application, each with a CRC.

    d) Scrub, but move the image rather than rewriting it. When a copy shows a corrected bit, write and verify a new copy in a spare block, then mark the old block bad. The RBL treats a block as bad if any of spare bytes 0-5 of page 0, page 1 or the last page is not 0xFF. It checks this before reading any data from the block (hw/nand/nand.c lines 199-250; hw/nand/device_nand.c lines 366-380). The PDK C6657 IBL configuration checks only spare byte 5 of page 0 (ti/boot/ibl/src/util/iblConfig/src/device.c lines 1308-1309). Make your IBL and loader check the same places as the RBL.

    Our view of your self-scrub: it is a good mitigation for errors that build up over time, with three limits:
    Bits that read correctly at room temperature and flip only when cold will not trigger it, and on a cold boot the RBL fails before the IBL runs. That is why (a) is needed as well. Rewriting block 0 in place keeps any weak cells, and a power loss between erase and program leaves no bootable image. Moving the image as in (d) avoids both. A backup copy in block 1 is used cleanly only if the failure is in page 0 or block 0 is marked bad, because the RBL does not restart its parsing when it moves to the next block.

    e) On the next board revision, boot the first stage from an I2C EEPROM or SPI NOR, and let it read the NAND with the fixed driver. This is the default flow on the TMDSEVM6657: the IBL is in the EEPROM at I2C address 0x51 and the application is in NAND (ti/boot/ibl/doc/evmc6657-instructions.txt; example in ti/boot/examples/i2c/nand) [4]. The prebuilt C6657 IBL is 47,888 bytes.

    On a custom board, build the PDK IBL with IBL_ENTER_ROM set to 0 (ti/boot/ibl/src/device/c665x/target.h line 354). When it is set, iblEnterRom() reads the EVM's FPGA boot-switch registers over SPI and can jump back into the ROM boot (c665xinit.c lines 293-386). A custom board does not have that FPGA.

    Existing units can be updated in software or reflashed. Units that already fail can be recovered over JTAG, where it is accessible.

    To confirm on your boards

    Please try a quick test with your bit-injection setup: put the same small image in blocks 0 and 1, flip one bit in page 0 of block 0, and boot. The board should boot from block 1. Please also check whether it still boots with block 0 fully erased. It would also help to know:
     - whether the IBL NAND driver in use waits after starting the calculation
     - whether the low-temperature bit flips persist at room temperature
     - the NAND part number and page size (Tom)
     - whether an I2C EEPROM could be added in a later board revision

    References :

    [1] TMS320C6655/57 ROM bootloader source, PG1.0, paths under C665x_bootROM_src/:
    RBL 1_0_C6657 - TI.com
    [2] SPRZ381C, TMS320C6652/54/55/57 Silicon Errata, Silicon Revision 1.0 (Rev. C, May 2016):
    https://www.ti.com/lit/er/sprz381c/sprz381c.pdf
    [3] SPRS814A, TMS320C6655/57 data manual (August 2012): Main PLL SYSCLK list and EMIF16 timing notes
    [4] Processor SDK RTOS C665x 06.03.00.106, PDK c665x 2.0.16, paths under packages/ti/
    [5] Linux mainline drivers/mtd/nand/raw/davinci_nand.c, nand_davinci_correct_4bit().

    Regards,

    Betsy Varughese

  • Hi Betsy,

    Thank you for the detailed analysis. It matches what we see on our boards. Answers to your questions:

    IBL NAND driver wait
    Yes. Our IBL NAND driver sets ADD_CALC_START and then polls until CORR_STATE ≥ 4 before it waits for the final state, as in your suggestion (b). It also ignores errors at positions 512–519. For bad blocks, it checks spare bytes 0–5 of page 0, page 1 and the last page, the same places as the RBL. This explains why our IBL corrects the same page that the RBL fails on. We will also change the start-wait limit to a time-based one (≥ 100 µs) and add a timeout to the final-state loop.

    Temperature
    We see the same behaviour at room temperature, so the failure is not specific to low temperature.

    I2C EEPROM
    Not possible for us. The boards have already been delivered, so any fix has to be done in software (NAND contents only).

    NAND
    MT29F1G08ABBEAH4-AITX:E, 2048 + 64 bytes per page, 64 pages per block (128 KB block).

    We will run the test you suggested, with the same small image in page 0 of blocks 0 and 1 and also with block 0 fully erased, and post the results here.

    Thanks again for the help.

    Regards,
    Lee

  • Hi Lee,

    Sure, meanwhile, I'll keep the thread in the "Waiting for Customer" state.

    Regards,
    Adwaid Pola