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.

CCS/TMS570LC4357: Issue in Flash programming using F021 Flash library.

Part Number: TMS570LC4357

Tool/software: Code Composer Studio

Hi team, 

We are presently working on F021 flash memory for the device “TMS570LC43X”.  We are using  “F021_API_CortexR4_BE_L2FMC_V3D16.lib” library file. 

Presently, we are facing an issue in programing. That is  , the data is wrongly written after programming. Please see below for further details.

We are writing the data using the array  “unsigned char Data[32] = {'A', 'B', 'C' , 'D', 'A', 'B' ,'C', 'D', 'A' ,'B', 'C', 'D' ,'A', 'B', 'C','A', 'B', 'C' ,'A', 'B', 'C' ,'A', 'B', 'C' ,'A', 'B', 'C', 'A', 'B', 'C','A','D'};”.

But after programming the data is writing as “41420344” instead of “41424344”.  We could able to read this erroneous date after system/software reset only. If there is no reset, the memory location is filled with “FFFFFFFF”.

Note: we are executing the code from Bank0 and programming Bank1 at address 0x0022 0000(Sector 1). I think as it is writing to a different Bank (Bank1), it is not mandatory to execute the code from RAM. 

The programming and initialize function are

 

#include “f021.h” 

unsigned char Data[32] = {'A', 'B', 'C' , 'D', 'A', 'B' ,'C', 'D', 'A' ,'B', 'C', 'D' ,'A', 'B', 'C','A', 'B', 'C' ,'A', 'B', 'C' ,'A', 'B', 'C' ,'A', 'B', 'C', 'A', 'B', 'C','A','D'};

 

void main()

{

long Address_2[1]={0x00220000};

                Fapi_initializeFlashBanks(150);  //HCLK clock is 150MHz.

                Fapi_StatusType return_chcek;
                 Fapi_setActiveFlashBank(1);
               Fapi_enableMainBankSectors(0xFFFF);

   

                 while( FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy );

   

                 while( FAPI_GET_FSM_STATUS!= Fapi_Status_Success );

 

                 if(FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmReady)

                  {

                 return_chcek = Fapi_issueProgrammingCommand((long *)0x00220000,Data,sizeof(Data),0,0,Fapi_DataOnly);

                 while( FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy );

                 while(FAPI_GET_FSM_STATUS!= Fapi_Status_Success);

                  }

 

While(1)

{

/*Do Nothing.*

}

 

}

 

 

Could you please help us to solve the issue.

 

Thanks in Advance

Pramith P

  • Hi Pramith,

    After calling Fapi_initializeFlashBanks(150) to initialize the flash banks, please perform the status check to make sure the initialization is successful.

     

    if ((Fapi_initializeFlashBanks((uint32_t)SYS_CLK_FREQ)) == Fapi_Status_Success){

    (void)Fapi_setActiveFlashBank((Fapi_FlashBankType)Bank);

    (void)Fapi_enableMainBankSectors(0xFFFF); /* used for API 2.01*/

    }else {

    return (1);

    }

    Regards,

    QJ

  • Hi Wang,

    Thank you for reply.,
    We had tried as per your suggestion. But still there is no improvement.

    Could you please provide more tips to solve this issue.

    Thanks in advance.
  • Hi Pramith,

    This sounds like that the ECC wasn't written to the Flash as only one bit reads different (one bit error correction). For the device you are using you have to generate and write correct ECC to the flash as the flash wrapper (I believe) always performs ECC checking and correction if needed.
    For L2FMC you have to enable ECC autogeneration with the command Fapi_enableAutoEccCalculation() as described in the Reference Guide (SPNU501G) on page 12. I'm also missing the Fapi_AutoEccGeneration Mode Switch in Fapi_issueProgrammingCommand (page 19).

    Best Regards,
    Christian
  • Dear christian,

    Thanks for the reply.

    We have tried with  Fapi_enableAutoEccCalculation(). But there is no noticeable change in the flash programming. Fapi_AutoEccGeneration mode in  Fapi_issueProgrammingCommand() is not working as expected, so we have used Fapi_DataOnly mode.

    We are attaching a sample project (.zip format.) created for programming and erasing of flash bank 1, sector 1 for the above mentioned device here.

    0116.flashprogramming.7z

    or

    /cfs-file/__key/communityserver-discussions-components-files/312/8585.flashprogramming.7z


    Note:

    The sample project is programmed in such a way that once the controller receive character 'a', it will start program and once it receive character 'b' the erase operation take place. We have also added code for displaying the current memory content while flashing and erasing.

    Could you please help us to move further.

    Thanks in advance,

    Pramith P.

  • Hi Pramith,

    I went through your code and made the following observations:

      • Auto ECC generation wasn’t enabled:

        • Fapi_enableAutoEccCalculation();

        • Fapi_issueProgrammingCommand((uint32_t *)Address,Data,16,0,0,Fapi_AutoEccGeneration);

      • Data buffer size for program is set to 16 bytes, but main bank width is 32bytes (256bit (+ 32bit ecc)). This might be an issue.

        • Fapi_issueProgrammingCommand((uint32_t *)Address,Data,16,0,0,Fapi_AutoEccGeneration);

      • ECC for Bank1 is generated in LCF, this means that bank 1 has to be erased first before trying to program anything to it, otherwise ECC will not match.

        • Erased, but ECC generated, shows all 1 (0xFF):

        • Eased, shows “random” data because of ECC correction:

      • Data Cache is enabled

        • “hiding“ the newly programmed data.

        • A simple _dCacheInvalidate_(); will make the right data to show up:

          But also “erase” all variables:


           To solve this configure SRAM to write trough

      • or better use my new cache maintenance function, included in the attached project

        • First clean (flush) and then invalidate the cache: coreCleanInvalidateDC();

    Best Regards,
    Christian


    0844.LC43 Flash Example.zip

  • Hi Pramith,

    If your question above has been addressed, can you please verify the answer?

    Thanks,
    Christian