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.

ECC flash programming

Hi,

I try to program the ECC flash after flashing successfully sectors B to N  (Sector A holds my bootloader / flash programmer)

My code looks like this:

 

void ProgramECC (void)
{
    uint32 MainAddres;
    uint32 ECCAddres;
    uint16 EccValue;
    uint64* pData;

    Fapi_StatusType            oReturnCheck;
    Fapi_FlashStatusType       oFlashStatus;

    MainAddres = 0x100000;

    EALLOW;
    FlashEccRegs.ECC_ENABLE.bit.ENABLE = 0x0;
    EDIS;

    for (ECCAddres=0x200000; MainAddres < 0x13E000; ECCAddres++)
    {
        // Get addres of corresponcing MAIN flash
        MainAddres = (uint32)Fapi_remapEccAddress(ECCAddres);
        // Get pointer to main addres
        pData = (uint64*)MainAddres;
        // Calculate ECC value
        EccValue = Fapi_calculateEcc(MainAddres,*pData);
        // Program ECC Value
        Fapi_issueProgrammingCommandForEccAddresses(&ECCAddres,&EccValue,1);
        while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
        if(oReturnCheck != Fapi_Status_Success)
        {
            // Check Flash API documentation for possible errors
            Error(oReturnCheck);
        }
        // Read FMSTAT register contents to know the status of FSM after
        // program command for any debug
        oFlashStatus = Fapi_getFsmStatus();
} }


The problem is that the "oReturnCheck" value returns 0x004C, which is not documented.

One possible cause could be the flashbank? I activated FlashBank 0 ...

 

Thanks,

Werner

 

  • Hi Werner,

    You did not catch the return value of the ECC program function Fapi_issueProgrammingCommandForEccAddresses() in to the "oReturnCheck" variable.  You need to do like below:

    oReturnCheck = Fapi_issueProgrammingCommandForEccAddresses(bla, bla, bla);

    Also I noticed you did not do an EALLOW before calling the API functions.  Please do an EALLOW before using API functions.

    Thanks and regards,

    Vamsi

  • Hi Vamsi,

    Thanks for the uick reply!

    You had good points and i changed them, but still got NMI ECC error.

    I tried something else and this workes fine (sorry for the TAB/Space difference, code underneath).

    The whole bootloader workes fine now, reads an intel-hex file from USB on the M3 and sends line per line to C28. This one parses the code and programs it's flash. After programming, jumps to the flashed application. The bootloader stays in for the next update (even if the update was faulty or the new application doesn't start).

     

    I wonder if i can/may post the whole project, so people can benefit?

    Not shure about the TI licensing...

     

    // ******************************************************************************
    // Program ECC for flash section B to N
    // ******************************************************************************
    //#pragma CODE_SECTION(ProgramECC,"ramfuncs");
    void ProgramECC (void)
    {
    	uint32 MainAddres;
    	uint16 Data[16];
    
        Fapi_StatusType            oReturnCheck;
        Fapi_FlashStatusType       oFlashStatus;
    
    	MainAddres = 0x100000;
    
    	EALLOW;
    	FlashEccRegs.ECC_ENABLE.bit.ENABLE = 0x0;
    
    	for (MainAddres=0x100000; MainAddres < 0x13E000; MainAddres+=8)
    	{
    		// Read the data in flash for 8 words
    		memcpy((unsigned char *)Data,(unsigned char*)MainAddres,16);
    		// Program ECC Value
    		oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)MainAddres,(uint16 *)Data,
                           8,
                           0,
                           0,
                           Fapi_AutoEccGeneration);
    
            while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
    
            if(oReturnCheck != Fapi_Status_Success)
            {
            // Check Flash API documentation for possible errors
                Error(oReturnCheck);
            }
            // Read FMSTAT register contents to know the status of FSM after
            // program command for any debug
            oFlashStatus = Fapi_getFsmStatus();
    	}
    }