⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 onenand_test.c

📁 s3c6400 ADS下官方测试程序
💻 C
📖 第 1 页 / 共 5 页
字号:
		uPageAddr = (u8)UART_GetIntNum();

	//	ONENAND_EraseBlock(g_OneNandContNum, uBlkAddr, uBlkAddr);

		ONENAND_EnableInterrupt(g_OneNandContNum, eOND_INTACT);
	}
	else
	{
		uBlkAddr = oAutoVar.Test_Parameter[0];
		uPageAddr = oAutoVar.Test_Parameter[1];
	}
	
	//Load the Page to map 00 XIP buffer
	if(eTest == eTest_Manual)
		UART_Printf("1. Load to XIP Buffer\n");
	ONENAND_LoadToXIPBuffer(g_OneNandContNum, uBlkAddr, uPageAddr);

//rb1004...for dma test	
#if 0
	{
		u32 uSrcAddr;
		
		OneNand_DmaDone = 0;
		uSrcAddr = 0x20000000;
		DMACH_Setup(DMA_A, 0x0, uSrcAddr, 0, (u32)aReadData, 0, WORD, ONENAND_PAGESIZE/4, DEMAND, MEM, MEM, BURST16, &g_oONDDmac0);
		DMACH_Start(&g_oONDDmac0);

		while(!OneNand_DmaDone);	
	}
#endif

	//Modify data
	if(eTest == eTest_Manual)
		UART_Printf("2. Modify the XIP Buffer\n");
	uModifysize = 0x400/4;		// 1K Modify(0x0000 ~ 0x0400)
	for(i=0 ; i<uModifysize ; i++)
		ONENAND_WriteIntoDataram(g_OneNandContNum, 4*i, i+1);		

	for(i=0 ; i<ONENAND_PAGESIZE/4 ; i++)
		ONENAND_ReadOutDataram(g_OneNandContNum, 4*i, &aWriteData[i]);		//Read/Modify/Write command -> 0x00 Address:DataRam0
	
	//Wrtie the data in the map 00 XIP buffer
	if(eTest == eTest_Manual)
		UART_Printf("3. Write from XIP Buffer to Flash Memory\n");
	ONENAND_WriteFromXIPBuffer(g_OneNandContNum, uBlkAddr, uPageAddr);

	//Data Verify
#if 0
	ONENAND_WriteCmd(g_OneNandContNum, uBlkAddr, uPageAddr, 0x10);
	for(i=0 ; i<ONENAND_PAGESIZE/4 ; i++)
		ONENAND_ReadOutDataram(g_OneNandContNum, 4*i, &aReadData[i]);
	ONENAND_WriteCmd(g_OneNandContNum, uBlkAddr, uPageAddr, 0x11);
#else	
	if(eTest == eTest_Manual)
		UART_Printf("4. Verify the Flash Memory\n");
	ONENAND_ReadPage(g_OneNandContNum, uBlkAddr, uPageAddr, (u32*)aReadData);
#endif

	for(i=0 ; i<ONENAND_PAGESIZE/4 ; i++)
	{
		if(aReadData[i] != aWriteData[i])
		{
			UART_Printf("Write&Read Verify Error [%d Block : %d Page] :  \n", uBlkAddr, uPageAddr);
			UART_Printf("\t [Write data : Read data] = [0x%08x  : 0x%08x ] :  \n", aWriteData[i], aReadData[i]);
			uError = TRUE;
			break;
		}
	}

	if(uError == FALSE)
	{
		if(eTest == eTest_Manual)
			UART_Printf("Read/Modify/Write Operation OK \n");	
		else
			UART_Printf(".");
	}

	if(eTest == eTest_Manual)
		UART_Printf("\n");	

	free(aWriteData);
	free(aReadData);
}


//////////
// Function Name : OneNandT_SinglePipelineRead
// Function Description : Single pipelined reads followed by data read out
// Input : 	None
// Version : v0.1
void OneNandT_SinglePipelineRead(eFunction_Test eTest, oFunctionT_AutoVar oAutoVar)
{
	u32 i, j, uStartBlkAddr, uReadPageCnt, uBlkAddr;
	u8 uStartPageAddr, uPageAddr, uPageSize; 
	//u32 aReadData[ONENAND_PAGESIZE/4] = {0, };
	u32 *pReadData, *pReadDataBase;

	if(eTest == eTest_Manual)
	{
		UART_Printf("[OneNandT_SinglePipelineRead]\n");

		UART_Printf("Input the Start block number to read[0~%d] : \n", OneNand_Inform[g_OneNandContNum].uNumOfBlock-1);
		uStartBlkAddr = UART_GetIntNum(); 
		UART_Printf("Input the Start page number to read[0~%d] : \n", OneNand_Inform[g_OneNandContNum].uNumOfPage-1);
		uStartPageAddr = (u8)UART_GetIntNum();
		UART_Printf("Input the page size to read : \n");
		uPageSize = (u8)UART_GetIntNum();
	}
	else
	{
		uStartBlkAddr = oAutoVar.Test_Parameter[0];
		uStartPageAddr = oAutoVar.Test_Parameter[1];
		uPageSize = oAutoVar.Test_Parameter[2];
	}
	
	pReadDataBase = (u32 *)malloc(ONENAND_PAGESIZE*uPageSize);
	if(pReadDataBase == 0)
	{
		UART_Printf("Memory allocation Error...\n");
		return;
	}
	else
	{
		pReadData = pReadDataBase;

		for(i=0 ; i<(ONENAND_PAGESIZE*uPageSize)/4 ; i++)
			*pReadData++ = 0;
	}
	pReadData = pReadDataBase;
	
	ONENAND_PipelineReadAhead(g_OneNandContNum, uStartBlkAddr, uStartPageAddr, uPageSize);

	uReadPageCnt = 0;
	uBlkAddr = uStartBlkAddr;
	uPageAddr = uStartPageAddr;	
	OneNandT_oIntFlag.IntActInt_Count = 0;
	
	while(uReadPageCnt < uPageSize)
	{
		ONENAND_ReadPageForCacheRead(g_OneNandContNum, uBlkAddr, uPageAddr, (u32*)pReadData, uPageSize);
		pReadData += ONENAND_PAGESIZE/4;

		//Page Address刘啊 犬牢 鞘夸???
		uPageAddr++;
		if(uPageAddr == OneNand_Inform[g_OneNandContNum].uNumOfPage)
		{
			uPageAddr = 0;
			uBlkAddr++;
		}
		uReadPageCnt++;

		//for(i=0; i<ONENAND_PAGESIZE/4; i++)
		//	aReadData[i] = 0;
	}	

#if 0
	pReadData = pReadDataBase;
	for(j=0 ; j<uPageSize ; j++)
	{
		uPageAddr = (uStartPageAddr+i)%64;
		uBlkAddr = uStartBlkAddr + (uStartPageAddr+i)/64;
		UART_Printf("\n");
		UART_Printf("[%d block, %d page]", uBlkAddr, uPageAddr);
		for(i=0 ; i<ONENAND_PAGESIZE/4 ; i++)
		{
			if(!(i%4))
			{
				UART_Printf("\n");
				UART_Printf("0x%04x : ",i*4);
			}
			UART_Printf("0x%08x  ", *pReadData++);
		}
		UART_Printf("\n");
	}
#else
	{
		u32 aWriteData[ONENAND_PAGESIZE/4] = {0, };
		u32 uError = FALSE;
		u32 k;

		uBlkAddr = uStartBlkAddr;
		uPageAddr = uStartPageAddr;
		pReadData = pReadDataBase;
	
		for(i=0 ; i<uPageSize ; i++)
		{
			for(k=0; k<ONENAND_PAGESIZE/4; k++)
				aWriteData[k] = k +  (uPageAddr<<12) + (uBlkAddr<<20);
				
			for(j=0 ; j<ONENAND_PAGESIZE/4 ; j++)
			{
				if(aWriteData[j] != *(pReadData+j))
				{
					UART_Printf("[Write data : Read data] = [0x%08x :  0x%08x] \n", aWriteData[j], *(pReadData+j));
					UART_Getc();
					uError = TRUE;
					break;
				}
			}
			uPageAddr++;
			pReadData += ONENAND_PAGESIZE/4;
		}

		if(uError == FALSE)
		{
			if(eTest == eTest_Manual)
				UART_Printf("Cache Read Verify OK\n");
			else
				UART_Printf(".");
		}
	}
	if(eTest == eTest_Manual)
		UART_Printf("\n");
#endif

	free(pReadDataBase);
}


//////////
// Function Name : OneNandT_MultiPipelineRead
// Function Description : Sequencial pipelined reads followed by all data read at one time
// Input : 	None
// Version : v0.1
void OneNandT_MultiPipelineRead(eFunction_Test eTest, oFunctionT_AutoVar oAutoVar)
{
	u32 i, j, uStartBlkAddr1, uStartBlkAddr2, uStartBlkAddr3, uReadPageCnt, uBlkAddr;
	u8 uStartPageAddr1, uStartPageAddr2, uStartPageAddr3;
	u8 uPageSize1, uPageSize2, uPageSize3, uPageSizeSum;
	u32 *pReadData1, *pReadDataBase1, *pReadData2, *pReadDataBase2, *pReadData3, *pReadDataBase3;
	u8 uPageAddr; 

	if(eTest == eTest_Manual)
	{
		UART_Printf("[OneNandT_MultiPipelineRead]\n");

		UART_Printf("Input the first block number to read[0~%d] : \n", OneNand_Inform[g_OneNandContNum].uNumOfBlock-1);
		uStartBlkAddr1 = UART_GetIntNum(); 
		UART_Printf("Input the first page number to read[0~%d] : \n", OneNand_Inform[g_OneNandContNum].uNumOfPage-1);
		uStartPageAddr1 = (u8)UART_GetIntNum();
		UART_Printf("Input the page size to read : \n");
		uPageSize1 = (u8)UART_GetIntNum();

		UART_Printf("Input the second block number to read[0~%d] : \n", OneNand_Inform[g_OneNandContNum].uNumOfBlock-1);
		uStartBlkAddr2 = UART_GetIntNum(); 
		UART_Printf("Input the second page number to read[0~%d] : \n", OneNand_Inform[g_OneNandContNum].uNumOfPage-1);
		uStartPageAddr2 = (u8)UART_GetIntNum();
		UART_Printf("Input the page size to read : \n");
		uPageSize2 = (u8)UART_GetIntNum();

		UART_Printf("Input the third block number to read[0~%d] : \n", OneNand_Inform[g_OneNandContNum].uNumOfBlock-1);
		uStartBlkAddr3 = UART_GetIntNum(); 
		UART_Printf("Input the third page number to read[0~%d] : \n", OneNand_Inform[g_OneNandContNum].uNumOfPage-1);
		uStartPageAddr3 = (u8)UART_GetIntNum();
		UART_Printf("Input the page size to read : \n");
		uPageSize3 = (u8)UART_GetIntNum();
	}
	else
	{
		uStartBlkAddr1 = oAutoVar.Test_Parameter[0];
		uStartPageAddr1 = oAutoVar.Test_Parameter[1];
		uPageSize1 = oAutoVar.Test_Parameter[2];
		uStartBlkAddr2 = oAutoVar.Test_Parameter[3];
		uStartPageAddr2 = oAutoVar.Test_Parameter[4];
		uPageSize2 = oAutoVar.Test_Parameter[5];
		uStartBlkAddr3 = oAutoVar.Test_Parameter[6];
		uStartPageAddr3 = oAutoVar.Test_Parameter[7];
		uPageSize3 = oAutoVar.Test_Parameter[8];
	}
	
	pReadDataBase1 = (u32 *)malloc(ONENAND_PAGESIZE*uPageSize1);
	if(pReadDataBase1 == 0)
	{
		UART_Printf("Memory allocation Error...\n");
		return;
	}
	else
	{
		pReadData1 = pReadDataBase1;

		for(i=0 ; i<(ONENAND_PAGESIZE*uPageSize1)/4 ; i++)
			*pReadData1++ = 0;
	}
	pReadData1 = pReadDataBase1;

	pReadDataBase2 = (u32 *)malloc(ONENAND_PAGESIZE*uPageSize2);
	if(pReadDataBase2 == 0)
	{
		UART_Printf("Memory allocation Error...\n");
		free(pReadDataBase1);
		return;
	}
	else
	{
		pReadData2 = pReadDataBase2;

		for(i=0 ; i<(ONENAND_PAGESIZE*uPageSize2)/4 ; i++)
			*pReadData2++ = 0;
	}
	pReadData2 = pReadDataBase2;

	pReadDataBase3 = (u32 *)malloc(ONENAND_PAGESIZE*uPageSize3);
	if(pReadDataBase3 == 0)
	{
		UART_Printf("Memory allocation Error...\n");
		free(pReadDataBase1);
		free(pReadDataBase2);
		return;
	}
	else
	{
		pReadData3 = pReadDataBase3;

		for(i=0 ; i<(ONENAND_PAGESIZE*uPageSize3)/4 ; i++)
			*pReadData3++ = 0;
	}
	pReadData3 = pReadDataBase3;
	
	ONENAND_PipelineReadAhead(g_OneNandContNum, uStartBlkAddr1, uStartPageAddr1, uPageSize1);
	ONENAND_PipelineReadAhead(g_OneNandContNum, uStartBlkAddr2, uStartPageAddr2, uPageSize2);
	ONENAND_PipelineReadAhead(g_OneNandContNum, uStartBlkAddr3, uStartPageAddr3, uPageSize3);

	uReadPageCnt = 0;
	uBlkAddr = uStartBlkAddr1;
	uPageAddr = uStartPageAddr1;	
	OneNandT_oIntFlag.IntActInt_Count = 0;
	uPageSizeSum = uPageSize1 + uPageSize2 + uPageSize3;
	
	while(uReadPageCnt < uPageSize1)
	{
		ONENAND_ReadPageForCacheRead(g_OneNandContNum, uBlkAddr, uPageAddr, (u32*)pReadData1, uPageSizeSum);
		pReadData1 += ONENAND_PAGESIZE/4;

		//Page Address刘啊 犬牢 鞘夸???
		uPageAddr++;
		if(uPageAddr == OneNand_Inform[g_OneNandContNum].uNumOfPage)
		{
			uPageAddr = 0;
			uBlkAddr++;
		}
		uReadPageCnt++;

		//for(i=0; i<ONENAND_PAGESIZE/4; i++)
		//	aReadData[i] = 0;
	}	

	uReadPageCnt = 0;
	uBlkAddr = uStartBlkAddr2;
	uPageAddr = uStartPageAddr2;	
	while(uReadPageCnt < uPageSize2)
	{
		ONENAND_ReadPageForCacheRead(g_OneNandContNum, uBlkAddr, uPageAddr, (u32*)pReadData2, uPageSizeSum);
		pReadData2 += ONENAND_PAGESIZE/4;

		uPageAddr++;
		if(uPageAddr == OneNand_Inform[g_OneNandContNum].uNumOfPage)
		{
			uPageAddr = 0;
			uBlkAddr++;
		}
		uReadPageCnt++;
	}

	uReadPageCnt = 0;
	uBlkAddr = uStartBlkAddr3;
	uPageAddr = uStartPageAddr3;	
	while(uReadPageCnt < uPageSize3)
	{
		ONENAND_ReadPageForCacheRead(g_OneNandContNum, uBlkAddr, uPageAddr, (u32*)pReadData3, uPageSizeSum);
		pReadData3 += ONENAND_PAGESIZE/4;

		uPageAddr++;
		if(uPageAddr == OneNand_Inform[g_OneNandContNum].uNumOfPage)
		{
			uPageAddr = 0;
			uBlkAddr++;
		}		
		uReadPageCnt++;
	}	
	
#if 0
	pReadData1 = pReadDataBase1;
	for(i=0 ; i<uPageSize1 ; i++)
	{
		uPageAddr = (uStartPageAddr1+i)%64;
		uBlkAddr = uStartBlkAddr1 + (uStartPageAddr1+i)/64;
		UART_Printf("\n");
		UART_Printf("[%d block, %d page]", uBlkAddr, uPageAddr);
		for(j=0 ; j<ONENAND_PAGESIZE/4 ; j++)
		{
			if(!(j%4))
			{
				UART_Printf("\n");
				UART_Printf("0x%04x : ",i*4);
			}
			UART_Printf("0x%08x  ", *pReadData1++);
		}
		UART_Printf("\n");
	}

	pReadData2 = pReadDataBase2;
	for(i=0 ; i<uPageSize2 ; i++)
	{
		uPageAddr = (uStartPageAddr2+i)%64;
		uBlkAddr = uStartBlkAddr2 + (uStartPageAddr2+i)/64;
		UART_Printf("\n");
		UART_Printf("[%d block, %d page]", uBlkAddr, uPageAddr);
		for(j=0 ; j<ONENAND_PAGESIZE/4 ; j++)
		{
			if(!(j%4))
			{
				UART_Printf("\n");
				UART_Printf("0x%04x : ",i*4);
			}
			UART_Printf("0x%08x  ", *pReadData2++);
		}
		UART_Printf("\n");
	}

	pReadData3 = pReadDataBase3;
	for(i=0 ; i<uPageSize3 ; i++)
	{
		uPageAddr = (uStartPageAddr3+i)%64;
		uBlkAddr = uStartBlkAddr3 + (uStartPageAddr3+i)/64;
		UART_Printf("\n");
		UART_Printf("[%d block, %d page]", uBlkAddr, uPageAddr);
		for(j=0 ; j<ONENAND_PAGESIZE/4 ; j++)
		{
			if(!(j%4))
			{
				UART_Printf("\n");
				UART_Printf("0x%04x : ",i*4);
			}
			UART_Printf("0x%08x  ", *pReadData3++);
		}
		UART_Printf("\n");
	}	
#else
	{
		u32 k, uError = FALSE;
		u32 aWriteData[ONENAND_PAGESIZE/4] = {0, };
		
		pReadData1 = pReadDataBase1;
		for(i=0 ; i<uPageSize1 ; i++)
		{
			uPageAddr = (uStartPageAddr1+i)%64;
			uBlkAddr = uStartBlkAddr1 + (uStartPageAddr1+i)/64;

			for(k=0; k<ONENAND_PAGESIZE/4; k++)
				aWriteData[k] = k +  (uPageAddr<<12) + (uBlkAddr<<20);
				
			for(j=0 ; j<ONENAND_PAGESIZE/4 ; j++)
				if(aWriteData[j] != *pReadData1++)
				{
					UART_Printf("[Write data : Read data] = [0x%08x :  0x%08x] \n", aWriteData[j], *pReadData1++);
					UART_Getc();
					uError = TRUE;
					break;
				}
			uPageAddr++;
		}
		if(uError == FALSE)
		{
			if(eTest == eTest_Manual)
				UART_Printf("1st Cache Read Verify OK\n");
		}
		uError = FALSE;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -