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/TMS320F28377D: Fapi_setActiveFlashBank() execution crashes

Part Number: TMS320F28377D

Tool/software: Code Composer Studio

Hello, 

I have a C2000 project where the Fapi_setActiveFlashBank() crashes one of the 2 cores of my TMS320F28377D.  When I am connected to the debugger, everything seems to be working fine, I can program my Flash via Can. Even if I load the program with code composer, I disconnect the probe and restart the supply, and then load the symbols with a reset/restart or just restart, everything works fine. 

However, when I disconnect the debugger and boot from Flash, the same software does not work. After some debug, I found the crash is during the call of the function Fapi_setActiveFlashBank().

I placed this function in RAM:

GROUP
{
ramfuncs
{ -l F021_API_F2837xD_FPU32.lib}
} LOAD = FLASHA,
RUN = RAMLS0123,
LOAD_START(_RamfuncsLoadStart),
LOAD_SIZE(_RamfuncsLoadSize),
LOAD_END(_RamfuncsLoadEnd),
RUN_START(_RamfuncsRunStart),
RUN_SIZE(_RamfuncsRunSize),
RUN_END(_RamfuncsRunEnd),
PAGE = 0 ALIGN(4) /* executable code with automatic link between flash load and RAM run*/
/* Allocate program areas: */


.cinit : > FLASHA PAGE = 0, ALIGN(4)
.pinit : > FLASHA, PAGE = 0, ALIGN(4)
.text : >> FLASHA | FLASHB | FLASHC PAGE = 0, ALIGN(4) /* executable code */
codestart : > BEGIN PAGE = 0, ALIGN(4)
appstart : > BEGINAPP PAGE = 0, ALIGN(4)

In my .map  the function is well placed in the ramfuncs section :

ramfuncs 0 00080004 000009d0 RUN ADDR = 00008000
00080004 00000259 F021_API_F2837xD_FPU32.lib : FlashStateMachine.obj (.text:__Fapi_setupFlashStateMachine)
0008025d 0000019d : Program.obj (.text:_Fapi_issueProgrammingCommand)
000803fa 00000088 : Read.obj (.text:__Fapi_loopRegionForValue)
00080482 0000007f : Read.obj (.text:__Fapi_checkRegionForValue)
00080501 0000007f : Read.obj (.text:__Fapi_checkRegionForValueByByte)
00080580 00000042 : BlankCheck.obj (.text:_Fapi_doBlankCheck)
000805c2 0000003a : Read.obj (.text:__Fapi_loopRegionForValueByByte)
000805fc 00000034 : Init.obj (.text:_Fapi_initializeAPI)
00080630 0000002e : Utilities.obj (.text:_Fapi_calculateFletcherChecksum)
0008065e 0000002d : FlashStateMachine.obj (.text:__Fapi_issueFsmCommand)
0008068b 0000002c : Utilities.obj (.text:__Fapi_divideUnsignedLong)
000806b7 00000025 : FlashStateMachine.obj (.text:_Fapi_setActiveFlashBank)
000806dc 00000022 : FlashStateMachine.obj (.text:_Fapi_isAddressEcc)
000806fe 00000022 : FlashStateMachine.obj (.text:__Fapi_setupSectorsForWrite)

Then I call the function during the initialization of CPU2:

void main(void)
{

InitSysCtrl();

IpcRegs.IPCBOOTSTS = C2_BOOTROM_BOOTSTS_SYSTEM_READY;

CAL2_InitFlash(F021_CPU0_BASE_ADDRESS)



...

}

#pragma CODE_SECTION(CAL2_InitFlash, "ramfuncs" );

U16 CAL2_InitFlash(Fapi_FmcRegistersType * F021BaseAddr)
{
    U16 RetStatus;
    RetStatus = Fapi_Status_Success;



    // Check the arguments
    ASSERT((F021BaseAddr == F021_CPU0_BASE_ADDRESS));

    // Gain pump semaphore
    SeizeFlashPump();

    EALLOW;

    // This function is required to initialize the Flash API based on System
    // frequency before any other Flash API operation can be performed
    // Currently RetStatus not checked since it is always Fapi_Status_Success
    RetStatus = Fapi_initializeAPI(F021BaseAddr, CAL2_kSYSCLK_FREQUENCY);

    EALLOW;

    RetStatus = Fapi_setActiveFlashBank(Fapi_FlashBank0);


    EDIS;

    // Leave control over flash pump
    ReleaseFlashPump();

    return RetStatus;
}

Any help would be appreciated. I already read the topics and 

but it didn't help enough to resolve my problem. 

Thank's, 

Clement

  • Clement,

    Can you try disabling ECC-check before calling API functions on CPU2? 

    See sample code below:

        EALLOW;

        //

        // At reset, ECC is enabled.  Disable ECC before calling

        // Fapi_setActiveFlashBank() function on F2837xD CPU2

        //

        Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0x0;

     

        //

        // Flush CPU pipeline

        //

         __asm(" RPT #7 || NOP");

     

        //

        // Fapi_setActiveFlashBank function sets the Flash bank and FMC

        // for further Flash operations to be performed on the bank

        //

        oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);

        if(oReturnCheck != Fapi_Status_Success)

        {

            //

            // Check Flash API documentation for possible errors

            //

            Example_Error(oReturnCheck);

        }

     

    Thanks and regards,

    Vamsi

  • Hello Vamsi, 

    Indeed with the ECC disable it is working. Thank you for the help I was struggling with this for a while. The odd part that I had the problem on the new board developped and not with the older one (made last year) with the same version of TMS320F28377D.

    Regards, 

    Clement

  • Clement,

    Glad that it helped. Earlier this year, TI provided the above workaround to customers via a SIEP letter for F2837xD devices that got shipped with incorrect ECC for the TI-OTP. Except for the above CPU2 flash programming issue, there is no impact to other device functionality or normal main flash array ECC checking while executing the application out of Flash.

    I can contact you offline via friend request on the E2E forum to provide more details to you, if needed. Please let me know.

    Thanks and regards,
    Vamsi

  • Vamsi,

    thank you for all the information, I have all that I needed.

    Regards,
    Clement