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.

F021 Flash API can't erase on F28075

Other Parts Discussed in Thread: CONTROLSUITE

I'm unable to erase a flash sector using the F021 API from controlSuite (January 22, 2015).

From C:\ti\controlSUITE\device_support\F2807x\v140\F2807x_common\lib I have linked F021_API_F2837xD_FPU32.lib and using headers from

C:\ti\controlSUITE\device_support\F2807x\v140\F2807x_common\include\FlashAPI

Hear's my flow:

InitFlash_Bank0(); (located in C:\ti\controlSUITE\device_support\F2807x\v140\F2807x_common\source\F2807xSysCtrl.c)

returnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, 120);

returnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);

returnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (uint32_t *) startAddress); (startAddress is 0x80000)

// Wait for Flash to go non-busy
while (Fapi_checkFsmForReady() == Fapi_Status_FsmBusy)
{
}

// Check for a clean FMSTAT register from the erase
flashStatus = Fapi_getFsmStatus();
if (flashStatus != 0)
{
}

flashStatus is: 0xC10

bits CSTAT, PCV and EV set

Fapi_getLibraryInfo() reports ApiMajorVersion 1 and ApiMinorVersion 54, Version 1.54

The API functions are running from RAM.

Any ideas on my failure. 

  • Hi John,

    Did you also try using the CCS Flash plug-in GUI interface to check if that works fine ?

    Regards,

    Vivek Singh

  • Vivek,

    I can create a FLASH build, program and run from FLASH using CCS v6. Does that answer your question?

    John
  • John,

    Thanks. Yes provides the info I was looking. Basically wanted to make sure there is no issue with device (e.g. security enable) which is preventing this.

    I'll check with Flash/SW expert to look into this issue.

    Regards,

    Vivek Singh

  • John,

    1) Make sure you have EALLOW before Flash API functions.

    2) Make sure to include "Fapi_UserDefinedFunctions.c" file in your project.  This file will be provided with the Flash API example in the next controlsuite version.  Fapi_setupBankSectorEnable() function in this file enables erase operation for the sectors (enable/disable is configurable per sector).  I am attaching this file here.

    Let me know if it works.

    Thanks and regards,

    Vamsi

    /*--------------------------------------------------------*/
    /* Fapi_UserDefinedFunctions.c                            */
    /*                                                        */
    /* Copyright (c) 2009-2011 Texas Instruments Incorporated */
    /*                                                        */
    /* F021 Flash API v1.53                                   */
    /*--------------------------------------------------------*/
    
    /*!
        \file Fapi_UserDefinedFunctions.c
        \brief Contains all user defined functions that the Fapi functions use.
    */
    
    /* Uncomment the appropriate include file for your device */
    
    
    
    /*#include "F021_FMC_BE.h"*/
    /*#include "F021_FMC_LE.h"*/
    /*#include "F021_Concerto_C28x.h"*/
    /*#include "F021_Concerto_Cortex.h"*/
    #include "F021_F2837xD_C28x.h"
    
    Fapi_StatusType Fapi_serviceWatchdogTimer(void)
    {
       /* User to add their own watchdog servicing code here */
    
       return(Fapi_Status_Success);
    }
    
    Fapi_StatusType Fapi_setupEepromSectorEnable(void)
    {
       Fapi_GlobalInit.m_poFlashControlRegisters->Fbse.u32Register = 0xFFFF;   /* Value must be 0xFFFF to enable erase and programming of the EEPROM bank, 0 to disable */
       FAPI_WRITE_LOCKED_FSM_REGISTER(Fapi_GlobalInit.m_poFlashControlRegisters->FsmSector.u32Register, 0x0U); /* Enables sectors 32-63 for bank and sector erase */
       FAPI_WRITE_LOCKED_FSM_REGISTER(Fapi_GlobalInit.m_poFlashControlRegisters->FsmSector1.u32Register, 0x0U); /* Enables sectors 0-31 for bank and sector erase */
       FAPI_WRITE_LOCKED_FSM_REGISTER(Fapi_GlobalInit.m_poFlashControlRegisters->FsmSector2.u32Register, 0x0U); /* Enables sectors 32-63 for bank and sector erase */
    
       return(Fapi_Status_Success);
    }
    
    Fapi_StatusType Fapi_setupBankSectorEnable(void)
    {
       Fapi_GlobalInit.m_poFlashControlRegisters->Fbse.u32Register = 0xFFFF;                  /* Enable sectors 0-15 for erase and programming */
       FAPI_WRITE_LOCKED_FSM_REGISTER(Fapi_GlobalInit.m_poFlashControlRegisters->FsmSector.u32Register, 0x0U);
    
       return(Fapi_Status_Success);
    }
    
    /* End of File */
    
    
     

     

  • Vamsi,

    1) I have EALLOW before flash functions

    2) I had a definition of Fapi_setupBankSectorEnable() in my build. It's called during the erase. My definition looks identical to yours since it came from a ControlSuite example. However, just to be sure I replaced mine with yours and get the same fail behavior.

    John
  • John,

    Share your project and coff file. I will take a look at it and let you know.

    Thanks and regards,
    Vamsi
  • Vamsi,

    I don't notice a way to upload files to you.

    John
  • John,

    Once you click on the reply button, notice that you will have an option for "Use rich formatting" on the bottom right side. Click on it and you will find the way to attach.

    Thanks and regards,
    Vamsi

  • Vamsi,

    I'm attaching my project and .out file.

    This program just goes into a loop to receive binary data over the CAN bus. Once all the data has been received Flash is erased and programming with the data just received. It is a code update sequence. Both files have an extension of "txt" to allow the upload. Project file: project.txt. COFF file: DeviceControlBoot.txt.

    John

    DeviceControlBoot.txt

    <?xml version="1.0" encoding="UTF-8"?>
    <projectDescription>
    	<name>DeviceControl</name>
    	<comment></comment>
    	<projects>
    	</projects>
    	<buildSpec>
    		<buildCommand>
    			<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
    			<arguments>
    			</arguments>
    		</buildCommand>
    		<buildCommand>
    			<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
    			<triggers>full,incremental,</triggers>
    			<arguments>
    			</arguments>
    		</buildCommand>
    	</buildSpec>
    	<natures>
    		<nature>com.ti.ccstudio.core.ccsNature</nature>
    		<nature>org.eclipse.cdt.core.cnature</nature>
    		<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
    		<nature>org.eclipse.cdt.core.ccnature</nature>
    		<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
    	</natures>
    	<variableList>
    		<variable>
    			<name>INSTALLROOT_F2807X</name>
    			<value>$%7BPARENT-1-CCS_INSTALL_ROOT%7D/controlSUITE/device_support/F2807x/v130</value>
    		</variable>
    	</variableList>
    </projectDescription>
    

  • John,

    I meant project folder and not the ".project" CCS file.
    Can you send me your code that does Flash erase/program along with any code you have in between the API function calls?

    Thanks and regards,
    Vamsi
  • Vamsi,

    Are you looking to run the code? If so it might be better if I can put together a project that just boots up and attempts an erase. To run the code as is would require my host s/w as well as a specific CAN dongle, CAN wiring, etc. Although you might be able to use SCI you would still need the host s/w. Let me know if the pared down project makes sense.

    John

  • Vamsi,

    Attached is my pared down project. It is a zip file with an extension of txt in order to upload it. It will initialize flash, the api and immediately try to erase sector A. I het the same failure with this as my full application.

    John

    FlashApiTest.zip.txt

  • Edited as it is not needed and might confuse others..

  • Edited...as it might confuse others...

  • Edited...as it not needed and it might confuse others...

  • John,

    I don't see EALLOW before Fapi_initializeAPI() and Fapi_setActiveFlashBank() functions in your code.  Hence initialization did not happen resulting in an erase failure.  Also, I noticed that EALLOW is not there before Fapi_issueProgrammingCommand() and Fapi_doVerify() functions.

    You don't need to make any other changes apart from what I mentioned.

    Thanks and regards,
    Vamsi

     

        

  • Vamsi,

    You are correct. I added EALLOW in main prior to Fapi_initializeAPI() and Fapi_setActiveFlashBank(). I had to remove the code snippet I added previously. The erase worked! I'm sorry I didn't have the EALLOW prior to initialization calls but thanks for your help and patience.

    John