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.

TMS570LC4357: Flash erase read and write problem

Part Number: TMS570LC4357
Other Parts Discussed in Thread: UNIFLASH

Hi Team,

There's an issue from the customer need your help:

I erase and write the on-chip Flash through F021 API

After I erased Bank1, I wrote 0xaa to the first 8 bytes of Sector0 of Bank1. Then read these 8 bytes directly in the C program through the address.

According to the printed information of the serial port, there are no software errors in erasing and writing. However, when the first byte of data is read, the serial port will stop and the red light on the board will light up.

At this time, the memory information is read through the Memory option in UniFlash, and it is found that the first 8 bytes of Sector0 of Bank1 have been written as 0xaa.

Then I tried to write the starting 16 bytes, 24 bytes, and 32 bytes of Sector0 of Bank1. I found that when writing the first 24 bytes and 32 bytes, the data I wrote can be read without errors.

I would like to ask what may be the cause of this situation? How to solve it?

According to the technical manual and API manual, it seems that writing only 8 bytes, and reading these 8 bytes is feasible

Thanks & Regards,

Ben

  • Hi Ben,

    Can you please share your project with the issue you are talking about?

    If you share it then i can quickly debug and see the issue you are mentioning.

    --
    Thanks & regards,
    Jagadish.

  • Hi Jagadish,

    Sorry, due to information security, the customer can't provide projects:

    First, here is the code for a test case I used

    VOID SimpleFlashTest (VOID)
    {
        UINT32 i;
        UINT32 ret = ;
        UINT32 bankId = ;
        UINT32 sectorBitMap = 0xFFFF ;
        UINT8 dataBuffer ] = { 0xAA 0xBB 0xCC 0xDD 0xEE 0xFF 0x00 0x55 };
        UINT8 val = ;
        UINT64 val64 = ;

        UINT32 hClkFreq = 150 ;

        if (( Fapi_initializeFlashBanks (hClkFreq) == OS_SUCCESS)){
            printf "[SimpleFlashTest]: Fapi_initializeFlashBanks OK \r\n );

            Fapi_setActiveFlashBank ((FapiFlashBankType)(bankId));
            printf "[SimpleFlashTest]: Fapi_setActiveFlashBank (Bank1) OK \r\n );
            printf "[SimpleFlashTest]: Check RWait: L2FMC->fRdCntl %#x \r\n L2FMC -> fRdCntl );
            printf "[SimpleFlashTest]: Check EWait: L2FMC->eepromConfig = %#x \r\n L2FMC -> eepromConfig );

            Fapi_enableMainBankSectors ((UINT16)sectorBitMap);
            printf "[SimpleFlashTest]: Fapi_enableMainBankSectors (sectorBitMap 0xFFFF) OK \r\n );
            while OsIsFsmReady () == FALSE );
            printf "[SimpleFlashTest]: FSM Ready \r\n );
            while OsIsOpSuccess () == FALSE );
            printf "[SimpleFlashTest]: Op Success \r\n );
        }

        ret = Fapi_issueAsyncCommandWithAddress (Fapi_EraseSector, (UINT32 *)( 0x00200000 ));
        if (ret != OS_SUCCESS) {
            printf "[SimpleFlashTest]: Fapi_issueAsyncCommandWithAddress Return Error( %d \r\n , ret);
        }
        printf "[SimpleFlashTest]: Fapi_issueAsyncCommandWithAddress OK" );

        while OsIsFsmReady () == FALSE );
        printf "[SimpleFlashTest]: FSM Ready \r\n );
        while OsIsOpSuccess () == FALSE );
        printf "[SimpleFlashTest]: Op Success \r\n );

        ret = Fapi_issueProgrammingCommand ((UINT32 *)( 0x00200000 ), dataBuffer, , Fapi_AutoEccGeneration);
        if (ret != OS_SUCCESS) {
            printf "[SimpleFlashTest]: Fapi_issueProgrammingCommand Return Error( %d \r\n , ret);
        }
        printf "[SimpleFlashTest]: Fapi_issueProgrammingCommand OK \r\n );
        while OsIsFsmReady () == FALSE );
        printf "[SimpleFlashTest]: FSM Ready \r\n );
        while OsIsOpSuccess () == FALSE );
        printf "[SimpleFlashTest]: Op Success \r\n );

        // Read
        val = *((UINT64 *)( 0x00200000 ));
        printf "[SimpleFlashTest]: ( %#x ) = %#llx \r\n 0x00200000 , val);

        // for (i = 0; i < 8; i++) {
        // val = *((UINT8 *)(0x00200000));
        // printf("[SimpleFlashTest]: (%#x) = %#x\r\n", 0x00200000 + i, val);
        // }
    }

    Then add some information:

    Using F021_API_CortexR4_BE_L2FMC_V3D16_NDS.lib

    Finally, describe the behavior of the use case code:

    When the code is executed to read and write content through pointer dereference, the red light on the board lights up and all actions stop.

    Then after reading the entire Memory through UniFlash, there is the following content

    Best Regards,

    Ben

  • Hi Jagadish,

    Is there any updates?

    Best Regards,

    Ben

  • Hi Ben,

    Can you please tell the customer to use "Fapi_doMarginReadByByte" Read function instead of direct pointer?

    And let me know whether the customer still facing issue or not?

    --
    Thanks & regards,
    Jagadish.

  • Hi Jagadish,

    Yes, they still facing the issue.

    Using API - Fapi_doMarginReadByByte to read 8 bytes written in Bank1 Sector0 is the same behavior. The serial port stops and the red light on the board turns on. For Bank7 Sector0, after writing 8 bytes, this problem will not occur whether it is accessed directly through the address or read using API.

    Best Regards,

    Ben

  • Hi Ben,

    I created one example project similar to the customer issue and i don't see any issue in reading.

    And the same data i am receiving on serial terminal as below:

    So, i am attaching my complete project here, can you please ask the customer to test it.

    7651.FAPI_TEST_LC43.zip

    --
    Thanks & regards,
    Jagadish.