最近在修改eboot,(ep9315的cpu)现在发现有个擦flash的问题,运行到
Continue to Erase the rest of Flash.
*pFlash = EA0003FF .
ERROR: Error while erasing flash
就发生错误
不是硬件的问题,因为用自带的就可以,不过没源码
这个是源码
BOOL FinishEraseFlashJ3_2x16 (void)
{
BOOL bSuccess;
//
// Check to see if the flash has been completely erased. If so just
// return.
//
if(gbFlashEraseComplete)
{
return TRUE;
}
//
// Wait for the Flash block command to succed.
//
bSuccess = WaitForReady(gpulCurAddr, 10000, EXT_STATUS_WBUFFER_READY);
if(bSuccess == FALSE)
{
return FALSE;
}
*gpulCurAddr = FLASH_CLEAR_STATUS;
//
// Erase the block before unlocking the next block.
//
if(gbUnlocked)
{
//
// Erase the flash block
//
*gpulCurAddr = FLASH_BLOCK_ERASE;
*gpulCurAddr = FLASH_BLOCK_ERASE_RESUME;
//
// Read erase status.
//
*gpulCurAddr = FLASH_READ_STATUS;
//
// Wait for the Flash block command to succed.
//
bSuccess = WaitForReady(gpulCurAddr, 10000, EXT_STATUS_WBUFFER_READY);
if(bSuccess == FALSE)
{
return FALSE;
}
*gpulCurAddr = FLASH_CLEAR_STATUS;
gbUnlocked = FALSE;
//
// Increment to the next block.
//
gpulCurAddr += FLASH_BLOCK_SIZE>>2;
}
//
// Erase the Flash
//
while((DWORD)gpulCurAddr < (gdwStartAddr + gdwLength))
{
//
// Clear the lock bits if the flash block was locked.
//
*gpulCurAddr = FLASH_LOCK_BIT;
*gpulCurAddr = FLASH_LOCK_CLEAR;
*gpulCurAddr = FLASH_READ_STATUS;
//
// Wait for the Flash block command to succed.
//
bSuccess = WaitForReady(gpulCurAddr, 10000, EXT_STATUS_WBUFFER_READY);
*gpulCurAddr = FLASH_CLEAR_STATUS;
if(!bSuccess)
{
break;
}
//
// Erase the flash block
//
*gpulCurAddr = FLASH_BLOCK_ERASE;
*gpulCurAddr = FLASH_BLOCK_ERASE_RESUME;
*gpulCurAddr = FLASH_READ_STATUS;
//
// Wait for the Flash block command to succed.
//
bSuccess = WaitForReady(gpulCurAddr, 10000, EXT_STATUS_WBUFFER_READY);
*gpulCurAddr = FLASH_CLEAR_STATUS;
if(!bSuccess)
{
break;
}
//
// Occasionally write out a dot so they don't think
// the system is dead.
//
EdbgOutputDebugString(".");
//
// Increment to the next block.
//
gpulCurAddr += FLASH_BLOCK_SIZE>>2;
}
return bSuccess;
}
主要是WaitForReady()函数卡住
static int WaitForReady
(
volatile ULONG *pFlash,
ULONG ulTimeoutInMsec,
ULONG ulBitField
)
{
ULONG ulStart;
ULONG ulCurrent;
BOOL bSuccess = FALSE;
ulStart = GetSystemTimeInMsec();
do
{
//
// See if there are errors.
//
if((*pFlash & ulBitField)== ulBitField)
{
bSuccess = TRUE;
break;
}
//
// Get the current time.
//
ulCurrent = GetSystemTimeInMsec();
} while(ulCurrent
if(!bSuccess)
{
EdbgOutputDebugString("*pFlash = %x .\n",(ULONG)*pFlash);
}
return bSuccess;
}
;
我也问了下别人,说是可能ep9315对flash的读写时间有问题,不知道怎么解决..