[code](void)
{
UINT8 pMID;
UINT8 pDID;
UINT32 nCnt;
UINT32 nRet;
UINT8 nBuff;
UINT8 n4thcycle;
int i;
bLARGEBLOCK = FALSE;
n4thcycle = nBuff = 0;
NF_nFCE_L();
NF_CLEAR_RB();
NF_CMD (0x90); // read id command
NF_ADDR (0x00);
for ( i = 0; i < 100; i++ );
/* tREA is necessary to Get a MID. */
for (nCnt = 0; nCnt < 5; nCnt++)
{
pMID = (BYTE) NF_RDDATA();
if (0xEC == pMID)
break;
}
pDID = (BYTE) NF_RDDATA();
nBuff = (BYTE) NF_RDDATA();
n4thcycle = (BYTE) NF_RDDATA();
NF_nFCE_H();
if (pMID != (UINT8)0xEC)
nRet = FALSE;
else
nRet = TRUE;
if (pDID >= 0xA0)
{
bLARGEBLOCK = TRUE;
}
return (nRet);
}
int NF_ReadPage (UINT32 block,UINT32 page,UINT8 *buffer)
{
//volatile int i;
register UINT8 * bufPt=buffer;//0x30038000
unsigned int blockPage;
ULONG MECC;
int NewDataAddr;
if ( bLARGEBLOCK == TRUE )
{
Uart_SendString("large block");
blockPage = (block<<6) + page/4;
NewDataAddr = 512*(page%4);
NF_RSTECC(); // Initialize ECC
NF_MECC_UnLock();
NF_nFCE_L();
NF_CMD(0x00); // Read command
NF_ADDR((NewDataAddr)&0xff);
NF_ADDR(((NewDataAddr)>>8)&0xff);
NF_ADDR(blockPage&0xff); //
NF_ADDR((blockPage>>8)&0xff); // Block & Page num.
if (LB_NEED_EXT_ADDR) {
NF_ADDR((blockPage>>16)&0xff); // Block & Page num.
}
}
else
{
Uart_SendString("small block");
Uart_SendDWORD(block,0);
blockPage = (block<<5) + page;
//blockPage = (block<<8) + page; NewDataAddr=0;
[del]如果每个block的页数不确定,这里是怎么执行的![/del]
NF_RSTECC(); // Initialize ECC
NF_MECC_UnLock();
NF_nFCE_L();
NF_CMD(0x00); // Read command
NF_ADDR((NewDataAddr)&0xff);
NF_ADDR(blockPage&0xff); //
NF_ADDR((blockPage>>8)&0xff); // Block & Page num.
if (SB_NEED_EXT_ADDR) {
NF_ADDR((blockPage>>16)&0xff); // Block & Page num.
}
}
NF_CLEAR_RB();
NF_CMD(0x30);
NF_DETECT_RB();
__RdPage512(bufPt);
NF_MECC_Lock();
// no ecc check
return 1;
MECC = NF_RDDATA32();
MECC = NF_RDDATA32();
MECC = NF_RDDATA32();
NF_WRMECCD0( ((MECC&0xff00 )<<8) | (MECC&0xff ) );
NF_WRMECCD1( ((MECC&0xff000000)>>8) | ((MECC&0xff0000)>>16) );
NF_nFCE_H();
if(rNFESTAT0 & 0x3)
{
Uart_SendString("ECC ERROR block");
Uart_SendDWORD(block,0);
Uart_SendString("page");
Uart_SendDWORD(page,1);
return 0;
}
else
return 1;
}
在ReadID的函数里面有判断是大页还是小页的功能! 我用的是64MB /1个block是64MB /一页时512B
这个判断是成功的!
-----------------------------------------
NF_ReadPage是什么作用??
是不是把EBOOT得内容copy到RAM里面去! 如果是的话,这个过程出错的话 ,是不是
((PFN_IMAGE_LAUNCH)(LOAD_ADDRESS_PHYSICAL))(); 就无法进行!