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.

TMS320F28388D: Flash erase

Part Number: TMS320F28388D


hello, 

I am using F28388D controller, i am facing a peculiar issue . 

I have written a application to load the S2 record in sector 7,8,9 and the same will be copied to sector 4,5,6 later will delete the data copied to sector 7,8,9.

I also have a external watchdog timer of 10ms so i keep refreshing the external watch dog every 2ms scheduler where the functionality also works. 

if load the application only on CPU1 it works perfectly fine it erases the data at sector 7,8,9. 

But the problem is when i load in the CPU2, the data gets loaded in sector 7,8,9, i am able to copy the data to sector 4,5,6 but fails to erase the sector 7,8,9. where the same scheduler is running independently in CPU1 and CPU2. 

what could be going incorrect here in erasing the flash .

The same code works perfectly fine if the external watchdog is disabled. so i feel for some reason the external watchdog is not getting refreshed within 10ms during the erase operation when doing in CPU2.

thanks,

Nagesh

  • Nagesh,

    What error did you get when the erase failed?

    What is CPU2 doing when CPU1 is doing the erase?  

    Below are the scenarios where CPU2 can effect CPU1 erase:

    1. When CPU1 is doing erase, CPU2 caused reset to the device by it's code execution?

    2. External watchdog is causing/triggering a reset?

    3. CPU2 is changing the clock settings by gaining clock semaphore?

    4. CPU2 is executing its code and hence the power requirement increased - but maybe your power supply is not able to meet the demand?

    5. Is CPU2 passing any info to CPU1 via IPC or some shared RAM for CPU1 to decide whether it should proceed to erase or not?

    I would suggest to concentrate on any shared resources between the two cores in your application.  

    Thanks and regards,

    Vamsi

  • What error did you get when the erase failed?

    [N] This works fine when connected to CCS as external watchdog will be disabled so i do not get any error., not sure how can i capture the error during runtime with external watchdog enabled.

    What is CPU2 doing when CPU1 is doing the erase?  

    [N] CPU2 will wait for CPU1 to complete its erase

    Below are the scenarios where CPU2 can effect CPU1 erase:

    1. When CPU1 is doing erase, CPU2 caused reset to the device by it's code execution?

    No.

    2. External watchdog is causing/triggering a reset?

    External watchdog is connected to CPU1 only, so CPU2 cannot cause a reset . i feel for some reason during erase it stuck for a longer period than 10ms and not following the scheduler and causing a reset to the controller.

    3. CPU2 is changing the clock settings by gaining clock semaphore?

    how can i check these any sample will be helpful.

    4. CPU2 is executing its code and hence the power requirement increased - but maybe your power supply is not able to meet the demand?

    [Nagesh] how much should be the minimum power, it works fine when the external watchdog is disabled

    5. Is CPU2 passing any info to CPU1 via IPC or some shared RAM for CPU1 to decide whether it should proceed to erase or not?

    [Nagesh] Yes. 

  • Nagesh,

    Is your application designed to send any status or error info during the failure?  If not, please plan for that.

    You can check how long the erase is taking to complete and see whether your external watchdog time is set accordingly or not.

    Did you see a toggle on XRSn indicating that the device went through a reset?

    Please check in TRM about clock semaphore and see if your CPU2 application is using it to configure clock for any reason.

    Datasheet has power consumption summary in section 7.5 Power Consumption Summary - did you take a look at it?  

    You might want to check if CPU1 is waiting for any info from CPU2 before proceeding to erase in the failing case.  

    Thanks and regards,
    Vamsi

  • Hi Vamsi, 

    I am posting below code process i have followed as per the documentation and example program. I have a doubt on release semaphore can you please check if the process is correct.

    /* Since i have created on Software to run on both cores i have mapped the address to a union*/
    union gstrIpcRegs_Tag {
        struct CPU1TOCPU2_IPC_REGS_CPU1VIEW gstrCpu1IpcRegs;
        struct CPU1TOCPU2_IPC_REGS_CPU2VIEW gstrCpu2IpcRegs;
    };
    
    #pragma DATA_SECTION(guniIpcRegs,"IpcRegsCPUFile");
    volatile union gstrIpcRegs_Tag guniIpcRegs;
    
    /*created a kind of fucntions to be called every time i want to erase or write*/
    
    void FdSeizeFlashPump(void)
    {
    
        if( CPUID_1 == gu16CpuId )
        {
            Flash_claimPumpSemaphore(FLASH_CPU1_WRAPPER);
        }
        if( CPUID_2 == gu16CpuId )
        {
            Flash_claimPumpSemaphore(FLASH_CPU2_WRAPPER);
        }
    }
    
    void Flash_claimPumpSemaphore(Flash_PumpOwnership wrapper)
    {
        EALLOW;
    
        if( CPUID_1 == gu16CpuId )
        {
    
            while(guniIpcRegs.gstrCpu1IpcRegs.PUMPREQUEST.bit.SEM != (UINT32)wrapper)
            {
                guniIpcRegs.gstrCpu1IpcRegs.PUMPREQUEST.all = FLASH_PUMP_KEY |
                    (UINT32)wrapper;
    
            }
    
        }
        if( CPUID_2 == gu16CpuId )
        {
    
            while(guniIpcRegs.gstrCpu2IpcRegs.PUMPREQUEST.bit.SEM != (UINT32)wrapper)
            {
                guniIpcRegs.gstrCpu2IpcRegs.PUMPREQUEST.all = FLASH_PUMP_KEY |
                    (UINT32)wrapper;
    
            }
        }
    
        EDIS;
    }
    
    /* In the below function to release semaphore i am using same macro FLASH_PUMP_KEY
       for CPU1 and CPU2 is this correct */
    void Flash_releasePumpSemaphore(void)
    {
        EALLOW;
    
        if( CPUID_1 == gu16CpuId )
        {
            guniIpcRegs.gstrCpu1IpcRegs.PUMPREQUEST.all = FLASH_PUMP_KEY;
        }
        if( CPUID_2 == gu16CpuId )
        {
            guniIpcRegs.gstrCpu2IpcRegs.PUMPREQUEST.all = FLASH_PUMP_KEY;
        }
    
        EDIS;
    }
    /* for every erase of a sector the belowsequence is followed */
    #define  CPU_FREQUENCY_MHZ  200 
    #define F021_CPU0_REGISTER_ADDRESS 0x0005F800
    #define F021_CPU0_BASE_ADDRESS ((Fapi_FmcRegistersType *)F021_CPU0_REGISTER_ADDRESS)
    
    FdFlashErase()
    {
        FdSeizeFlashPump();
        Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS,CPU_FREQUENCY_MHZ);
        Fapi_setActiveFlashBank(Fapi_FlashBank0);
        
        Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector,sector_address);
        while (FdFlashOperationStatus() != Fapi_Status_FsmReady){}
        Fapi_doBlankCheck(u32FlashSector,Sector16k_u32length,&oFlashStatusWord);
        
        Flash_releasePumpSemaphore();
    }
    
    /*The same procedure is followed for Program also with corresponding program api called.*/

  • Nagesh,

    I don't see any issue with the pump semaphore release.

    However, as I mentioned earlier, I can see in your code that you are not checking for the return values from the flash API functions.  They provide useful error info.  

    Also, you are not checking for the FMSTAT after the erase operation.  Please check for it to know the reason for erase failure (in case if this issue is an erase failure).

    Thanks and regards,
    Vamsi

  • Hi Vamsi, 

    I calculated the time it took to erase the sector 7, 8, 9 it took 40ms, i have a task of 500ms first time erase of this sector works fine, but in the second time i understood that when i initiate the erase of these sector my timer interrupt of 500ms is not working it got stuck in erasing the flash sector 7,8,9.

    can you let me know what could cause the flash erase sector to get stuck there.

    Thanks,

    Nagesh

  • Nagesh,

    40ms seems reasonable as it is in sync with the datasheet spec.

    As I mentioned earlier, please update your code to check for the return values from the flash API functions.  They provide useful error info.  

    Also, you are not checking for the FMSTAT after the erase operation.  Please check for it to know the reason for erase failure (in case if this issue is an erase failure).

    It would be tough to debug without the error info.

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

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

    Thanks and regards,
    Vamsi

  • Hi Vamsi, 

    Thank you for the link.

    When i run my program and verified the FMSTAT it does not show any failure, its always zero.

    The same sector 7,8,9 i am erasing it in the beginning there is works fine but after copying the data to sector 4,5,6 i try to erase the sector 7,8,9 then it fails , its because watchdog of 10ms is enabled.

    I have a doubt since the flash api also is sitting in the same sector 7,8,9 could that be the reason its taking more time. 

    i have updated my linker cmd file to load the flash api as below, is it really running from RAM, the lib name is changed else its same flash api lib.

          GROUP
       {
           ramfuncs
           { -l rts_TMS320F28388D_FlashAPI.lib}
       } LOAD = FLASH0 | FLASH1 | FLASH2 | FLASH3,
                            RUN = RAMLS0123 ,
                            LOAD_START(RamfuncsLoadStart),
                            LOAD_SIZE(RamfuncsLoadSize),
                            LOAD_END(RamfuncsLoadEnd),
                            RUN_START(RamfuncsRunStart),
                            RUN_SIZE(RamfuncsRunSize),
                            RUN_END(RamfuncsRunEnd),
                            ALIGN(8)

  • Nagesh,

    How about the functions that call the flash API functions - are they executing from RAM or flash?  Please see below copied from flash API guide.

    Thanks and regards,

    Vamsi

  • Nagesh,

    I am closing this post since I did not hear back from you in the last two weeks.  If you have further questions, please open a new post if this thread gets locked.

    Please note:  I will not be available until July 28th.

    Thanks and regards,

    Vamsi