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.

TMS570LS3137: F021 Flash API - flashErrorReal when accessing Flash Bank 1

Part Number: TMS570LS3137
Other Parts Discussed in Thread: HALCOGEN

Hi team,

For a project, I am using a TMS570LS31x dev.kit equipped with a 3137. On a later phase, transition will be made to a custom PCB equipped with a 3134.

In this context, I am supposed to access the device's Flash to store data. Because of project requirements, I need to use both Bank1 and 7 (while program is stored in Bank0).

However, When I try to run Fapi functions on Bank1, the CPU falls in dabort, flashErrorReal.

Following code produces the error. Do you have any inputs on this?

Note that I use HALCoGen, and the device seems properly initialized.

Best regards,

Christophe


Fapi_FlashBankType bank = FlashBankX; // x can be either 1 or 7 in my case
uint32_t *startAdd = (uint32_t*)0xXXXXXXXX; // 0x00180000 for Bank1, 0xF0200000 for Bank7
Fapi_FlashStatusWordType statusWord;

Fapi_StatusType ret = Fapi_initializeFlashBanks((uint32_t)PLL1_FREQ);


if (Fapi_Error_Fail > ret)
{
    ret = Fapi_setActiveFlashBank(bank);
}

if (Fapi_Error_Fail > ret)
{
    if (Fapi_FlashBank7 == bank)
    {
        ret = Fapi_enableEepromBankSectors(0xFFFFFFFF, 0U);
    }
    else
    {
        ret = Fapi_enableMainBankSectors(0xFFFF);
    }

    if (Fapi_Status_Success == ret)
    {
        FAPI_CLEAR_FSM_DONE_EVENT;
    }
}

while(Fapi_Status_FsmBusy == FAPI_CHECK_FSM_READY_BUSY);

if (Fapi_Status_Success == ret)
{
    ret = Fapi_doBlankCheck(startAdd, 1U, &statusWord); // Falls to flashErrorReal here when using Bank1, does not with Bank7
}

  • Hello,

    Before performing this blank check, has the sector been erased already? If the return value is not Success, statusWord should be the content of non-blank location. 

    The startAdd should be a 32-bit aligned address.

  • Hello and thank you for the prompt reply,

    I don't get the chance to read the return value, as the process immediately falls in dabort, flashErrorReal at this point.

    I do not explicitly erase the bank/sector, but I selected the option to erase all flash when flashing code to target (in the aim of working with a clean, blank flash when learning to use the API).

    The startAdd is 32-bit aligned, I believe, as it is the start address of bank 1 (0x0018_0000).

    Regards,

    Christophe

  • Hello Christophe,

    When the flash is erased, the ECC space is also erased. As the erase state of the flash is not a valid ECC condition, the flash ECC check should be disabled before doing flash blank check. 

    As you mentioned, you got flashErrorReal error which means the diagnostic mode is enabled. Did you check the flash content at 0x180000 using CCS memory browser, or using Flash API: Fapi_doMarginRead()?

  • Hello,

    I tried reading the flash content at 0x00180000, simply replacing the Fapi_doBlankCheck call with a Fapi_doMarginRead call. The result was the same, i.e. I got the flashErrorReal error. I haven't tried reading with CCS memory browser, I will try as soon as I get the chance.

    Regards

    Christophe

  • Hello Christophe,

    I think you have erased the flash already before performing the blank check.

    Can you please disable the flash diag test before do flash operation (erase, program, blankcheck, etc)? Write 0xA to FDIACTRL[19:16].

  • Hello Christophe,

    Have you solved the issue?

  • Hello,

    I am sorry for the late reply, There were things to organize with regard to the covid situation.

    FDIAGCTRL already has 0xA in its DIAG_EN_KEY field, bits [19:16], i.e. Diagnostic mode disabled. Its full value is 0x000A0007, and so DIAG_MODE = ECC Malfunction test mode 1.

    When I try to read from 0x00180000 using CCS Memory Broweser, I see a bunch of '?', and the few addresses that show a value show things like like '0xFFFFFFBF' or '0xFFFFFFFE' i.e. non blank values.

    Do you see what I am missing here?

    Regards,

    Christophe

  • Or rather, it reads 0xBAD0BAD0 for every address in bank 1 while the program is running, and these incomplete values when the program is in break mode.

  • If the flash ECC is enabled, the content of the erased flash sector in CCS window browser is not 0xFFFFFFFF. The read value is modified by the invalid ECC.

    Please disable the flash ECC before reading and blank checking.

    _coreDisableFlashEcc_() in sys_core.asm

  • Hi, and sorry for the late answer.

    I added a call to _coreDisableFlashEcc_() and it seems to do the trick, thank you very much for your help!

    Regards,

    Christophe