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.

F28M35H52C: Flash access API fails

Part Number: F28M35H52C
Other Parts Discussed in Thread: CONTROLSUITE, SYSBIOS

Hello,

We are trying to use Flash APIs to write to the flash of the F28M35H52C processor. 

We encounter a random failure where the function gets stuck with the Fapi_setActiveFlashBank function. We use Flash Bank 0.

The function never comes out of it and the device crashes after the issue occurs. 

I have attached the code for your reference:

We have placed the Flash APIs in the RAM using the linker file. It is not placed in Flash (then copied to RAM) during execution.

The functions calling the Flash APIs are also placed in the RAM.

Can you please review the code snippet and let us know if we have missed anything. We could more details if required.

uint32_t Fapi_BlockProgram( uint32 u32address, uint8 *u8Data, uint32 SizeInBytes, uint8 u8Writelength)
{
    Fapi_StatusType            oReturnCheck;
    volatile Fapi_FlashStatusType       oFlashStatus;
    uint8_t bytes = 0;

    // To acces the Flash_api
    FlashGainPump();


    if (SizeInBytes < u8Writelength)
        bytes = SizeInBytes;
    else
        bytes = u8Writelength;


    oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, 75);
    if(oReturnCheck != Fapi_Status_Success)
    {
        //Check Flash API documentation for possible errors
        //Example_Error(oReturnCheck);
#if SYSTEM_TEST_GEN2_2_ERROR
        printk("Flash_api Initialize issue : %d \n",oReturnCheck);
        // Send error code to error handler task for processing
        ProcessSystemError(ERROR_PPS_FLASH_ACCESS_FAILURE, PPS_TASK_CAN); // 1008
#endif

    }
    // 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);
#if SYSTEM_TEST_GEN2_2_ERROR
        printk("Flash_api Flash_Bank issue : %d \n",oReturnCheck);
        // Send error code to error handler task for processing
        ProcessSystemError(ERROR_PPS_FLASH_ACCESS_FAILURE, PPS_TASK_CAN); // 1008
#endif

    }
    while(Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}


    // Disable ECC so that error is not generated when reading Flash
    // contents without ECC
    HWREG(FLASH_ERROR_BASE + FLASHERR_O_ECC_ENABLE) = 0x0;

    while( SizeInBytes > 0)
    {
        oReturnCheck = Fapi_issueProgrammingCommand( (uint32 *)u32address,(uint8 *)u8Data, bytes, 0, 0, Fapi_AutoEccGeneration);
        while( Fapi_checkFsmForReady() == Fapi_Status_FsmBusy );
        //while( Fapi_getFsmStatus() != Fapi_Status_Success);
        printk("Flash_api write Done :[ %x ], Length : %d \n",u32address, SizeInBytes);

        if(oReturnCheck != Fapi_Status_Success)
        {
            // Check Flash API documentation for possible errors
            //Example_Error(oReturnCheck);
#if SYSTEM_TEST_GEN2_2_ERROR
        printk("Flash_api write issue : %d \n",oReturnCheck);
        // Send error code to error handler task for processing
        ProcessSystemError(ERROR_PPS_FLASH_WRITE_FAILURE, PPS_TASK_CAN); // 1008
#endif

        }

        u32address += bytes;
        u8Data += bytes;

        SizeInBytes -= bytes;
        if ( SizeInBytes < u8Writelength)
        {
           bytes = SizeInBytes;
        }

    }

    // Enable ECC
    HWREG(FLASH_ERROR_BASE + FLASHERR_O_ECC_ENABLE) = 0xA;

    // Leave control over pump
    FlashLeavePump();


    return (0);
}

Regards,

Lakshmi

  • Hi Lakshmi,

    What do you mean by it crashed after the issue?  Please provide more details.  Did it generate a reset, or ECC error etc?

    Are you successfully able to execute the flash API usage example from Controlsuite?  

    Regarding your code:  I checked the code up to that function call.

    1.  EALLOW (C28x) or MWRALLOW (ARM) should be executed before calling Flash API functions to allow writes to protected registers. Please check whether this is done or not.

    2.  Did you configure the PLL correctly to generate 75MHz?  Please check.

    3.  Did you configure the flash wait-states correctly before calling the flash API function?

    Please search for below questions in this FAQ: e2e.ti.com/.../faq-faq-on-flash-api-usage-for-c2000-devices

    1. Can you give a brief overview of how to use the prominent Flash API functions?

    2. What are the common debug tips that we can consider when Flash API fails to erase or program?

    Please see if the FAQ helps.

    Thanks and regards,

    Vamsi

  • Hello Vamsi,

    Thanks for the response. It helped resolve the issue.

    We had already done step 1 and then we did step 2 and step 3 as you had suggested. When we did not do the above steps, we ended up with _ti_sysbios_family_arm_m3_Hwi_excHandlerAsm__I failure.

    Apart from this we also made sure the setFlashActiveBank function is called only once. Previously we called it for every 

    This information was available in the document spnu630.pdf.

    This step in addition to the 3 steps you had mentioned, helped to resolve the issue. 

    Regards,

    Lakshmi

  • Lakshmi,

    Glad it helped.  I gave that info in both guide and FAQ.

    FAQ has a question that says:  Why and when should Fapi_setActiveFlashBank() be called?

    I am closing this post.

    Thanks and regards,

    Vamsi