yaffs2移植只要实现下面的接口就可以
#define YAFFS_OK 1
#define YAFFS_FAIL 0
//初始化
INT32U HAL_NandInit(void* p)
{
NF_InitCfg();//底层的nand初始化驱动
return 0;
}
//读flash
void HAL_NandReadId(INT32U *pulNandID1, INT32U *pulNandID2)
{
*pulNandID1 = NF_ReadID();
*pulNandID2 = *pulNandID1;
}
//写flash
INT32U HAL_NandPageRead(INT32U ulBlock, INT32U ulPage, INT32U ulOffset, INT32U ulLength, void *pvBuffer)
{
int nRowAddr = (ulBlock << 6) + ulPage;
int nColAddr = ulOffset;
return NF_ReadPage(nRowAddr, nColAddr, pvBuffer, ulLength);//nandflash驱动
}
//擦除块
INT32U HAL_NandBlockErase(INT32U ulBlock)
{
if(NF_EraseBlock(ulBlock) == 0)
{
return YAFFS_OK;
}
return YAFFS_FAIL;
}
//写flash
INT32U HAL_NandPageWrite(INT32U ulBlock, INT32U ulPage, INT32U ulOffset, INT32U ulLength, const void *pvBuffer)
{
int nRowAddr = (ulBlock << 6) + ulPage;
int nColAddr = ulOffset;
return NF_WritePage(nRowAddr, nColAddr, pvBuffer, ulLength);//nandflash驱动
}
nandflash的种类很多,yaffs2要适用不同的flash需要一些配置。配置是在yaffs2的入口函数yaffs_startup(int nStartBlock)。nStartBlock表示的是yaffs2管理的开始块。