Hi,
I am using flash api v2.1.1 with the TMS570ls1224. If I step through my code I can flash data OK, but if I just let it run I get a prefetch entry. Any idea what could cause this?
In my Halcogen configuration I have pipeline mode and 3 data wait states. These were the default values so I haven't changed them.
What is the difference between pipeline and normal mode? I tried to change to normal mode to see if it makes a difference, but Halcogen changes it back to pipeline.
[EDIT] This was consistently working when I stepped through, but not when I ran. Now I see the prefetch error all the time. I think I am doing all the initialization needed, and the values being passed into the functions (I've tried writing and erasing) are valid. What would cause a prefetch entry when making a call to either
Fapi_issueProgrammingCommand or Fapi_issueAsyncCommandWithAddress
Thanks,
David
static void handleFlashWrite(CmdFmt_Obj *pCmd, RspFmt_Obj *pRsp)
{
uint32_t startAddr;
uint32_t startProgAddr;
uint32_t sizeInBytes;
uint32_t bytesRemain;
uint8_t *pData;
uint8_t *checkData;
uint32_t bytes = 0;
uint8_t sectorIndex = 0;
uint8_t bank = 0;
Fapi_StatusType fapiStatus = Fapi_Error_InvalidBank; //Init to an error
// visually indicate progress for diag output
diagPrintf("%s", BOOT_INDICATION_SYMBOL);
// misc init
startAddr = pCmd->params[0];
startProgAddr = startAddr;
sizeInBytes = pCmd->params[1];
pData = (uint8_t *)&pCmd->params[2];
checkData = pData;
bytesRemain = sizeInBytes;
//Set the status to an error. if we get all the way through, then we will set it OK
pRsp->status = ERR_BURNING_FLASH;
//Check the size to be flashed
if (sizeInBytes < 16)
{
bytes = sizeInBytes;
}
else
{
bytes = 16;
}
//Find the bank to flash. Note, this should always be bank 0, but was put in for portability.
for (sectorIndex = 0; sectorIndex < NUMBEROFSECTORS - 1; sectorIndex++)
{
if (startAddr < (uint32_t)(flash_sector[sectorIndex+1].start))
{
bank = flash_sector[sectorIndex].bankNumber;
//We have the bank, so get out of the for loop
sectorIndex = NUMBEROFSECTORS;
}
}
//Initialize the flash banks
fapiStatus = Fapi_initializeFlashBanks(HCLK_FREQ);
if(fapiStatus == Fapi_Status_Success)
{
//Set the bank we are flashing as active
fapiStatus = Fapi_setActiveFlashBank((Fapi_FlashBankType)bank);
if(fapiStatus == Fapi_Status_Success)
{
//Enable the sectors to be flashed
fapiStatus = Fapi_enableMainBankSectors(ENABLE_ALL_SECTORS);
if(fapiStatus == Fapi_Status_Success)
{
while(FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy){};
//TODO bytes needs to be a multiple of 8 because ECC generation is done on 64 bits
while((bytesRemain > 0) && (fapiStatus == Fapi_Status_Success))
{
fapiStatus = Fapi_issueProgrammingCommand((uint32_t *)startProgAddr,
(uint8_t *)pData,
(uint8_t)bytes,
0,
0,
Fapi_DataOnly); //TODO change to Fapi_AutoEccGeneration
while( FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy );
startProgAddr += bytes;
pData += bytes;
bytesRemain -= bytes;
if(bytesRemain < 16)
{
bytes = bytesRemain;
}
}
if(fapiStatus == Fapi_Status_Success)
{
pRsp->status = checkFlashProgram(startAddr, (uint32_t)&checkData, sizeInBytes);
}
}
}
}
}