Other Parts Discussed in Thread: C2000WARE, UNIFLASH
Tool/software: TI C/C++ Compiler
I'm stuck.
I'm trying to build a boot loader for the F28075. The majority of my boot loader is pulled from the example program.
On initial load from the debugger, the API can erase and write flash without problem. It can load and run the application after a reset. But after any reset the Erase function (oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, SectorAddress);) returns "Fapi_Status_Success" but then fails the blank check (and no flash was actually changed). Since it can't get past this part, I can't tell if any writes would work after the reset.
Going through the forums here, I've checked that the API is running out RAM, which it seems to be (in this case RAMD0, if it makes a difference, though I've tried other sections). And other sections of code that run out of RAM seem to be just fine according to the disassembly address.
CMD file:
GROUP
{
.TI.ramfunc
{ -l F021_API_F2837xD_FPU32.lib}
}
LOAD = BOOTLOADER,
RUN = RAMD0,
LOAD_START(_RamfuncLoadStart),
LOAD_SIZE(_RamfuncLoadSize),
LOAD_END(_RamfuncLoadEnd),
RUN_START(_RamfuncRunStart),
RUN_SIZE(_RamfuncRunSize),
RUN_END(_RamfuncRunEnd),
PAGE = 0, ALIGN(4)
******
First line of Main:
MemCopy(&RamfuncLoadStart, &RamfuncLoadEnd, &RamfuncRunStart);
******
Mem Copy function:
void MemCopy(volatile Uint16 *SourceAddr, volatile Uint16* SourceEndAddr,volatile Uint16* DestAddr)
{
while(SourceAddr < SourceEndAddr)
{
*DestAddr++ = *SourceAddr++;
}
return;
}
*******
Actual Erase Section Called function:
#pragma CODE_SECTION(Flash_Erase_Sector,"ramfuncs");
Fapi_StatusType Flash_Erase_Sector(Uint32 *SectorAddress, Uint16 SectorLength)
{
volatile Fapi_StatusType oReturnCheck;
Fapi_FlashStatusWordType oFlashStatusWord;
//
// Erase Sector:
//
EALLOW;
//oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, SectorAddress);
oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, SectorAddress);
//
// Wait until FSM is done with erase sector operation
//
while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
EDIS;
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
// If Erase command fails, use Fapi_getFsmStatus() function to get the
// FMSTAT register contents to see if any of the EV bit, ESUSP bit,
// CSTAT bit or VOLTSTAT bit is set (Refer to API documentation for
// more details)
//
Error((Uint16)oReturnCheck);
}
//
// Verify that Sector is erased. The Erase step itself does a
// verify as it goes. This verify is a 2nd verification that can be done.
//
EALLOW;
oReturnCheck = Fapi_doBlankCheck(SectorAddress, SectorLength, &oFlashStatusWord);
EDIS;
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
// If Erase command fails, use Fapi_getFsmStatus() function to get the
// FMSTAT register contents to see if any of the EV bit, ESUSP bit,
// CSTAT bit or VOLTSTAT bit is set (Refer to API documentation for
// more details)
//
Error((Uint16)oReturnCheck);
}
return oReturnCheck;
}
******************
Init function:
#pragma CODE_SECTION(Flash_Init_Flash_API,"ramfuncs");
void Flash_Init_Flash_API(void)
{
volatile Fapi_StatusType oReturnCheck;
EALLOW;
//Disable ECC
Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0x0;
//Initialize the Flash so that it can be written:
oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, 120);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
Error((Uint16)oReturnCheck);
}
EDIS;
Flash_Initialized = TRUE;
}
****
Note, before the erase sector functions are called, I turn off ECC, and turn off the watchdog. The API init function is called when the boot loader starts up and before and communication can start. The user functions are copied directly from the example without any edits.
Any idea what I might be doing wrong. This API is way more finicky than on the F28035 which is pretty simple to use. I don't get how it only works on first load with the debugger then never again.
Thanks,
Kyle