From eb25d9c385b96e88aa38762b82eb22ad4fd6f30a Mon Sep 17 00:00:00 2001 From: Shakti Bhatnagar Date: Fri, 19 Dec 2014 14:30:52 +0530 Subject: [PATCH] nandps8_v2_0: Added 2 test cases and 1 Code Coverage test Added 1. BBT Scan/Create test 2. Mark Block Bad Test 3. Code Coverage Test Signed-off-by: Shakti Bhatnagar --- .../drivers/nandps8_v2_0/intgTest/intg.c | 63 ++++- .../drivers/nandps8_v2_0/intgTest/intg.h | 15 ++ .../nandps8_v2_0/intgTest/intg_bbt_test.c | 151 ++++++++++++ .../intgTest/intg_codecoverage_test.c | 186 +++++++++++++++ .../intgTest/intg_markblockbad_test.c | 222 ++++++++++++++++++ 5 files changed, 635 insertions(+), 2 deletions(-) create mode 100755 XilinxProcessorIPLib/drivers/nandps8_v2_0/intgTest/intg_bbt_test.c create mode 100755 XilinxProcessorIPLib/drivers/nandps8_v2_0/intgTest/intg_codecoverage_test.c create mode 100755 XilinxProcessorIPLib/drivers/nandps8_v2_0/intgTest/intg_markblockbad_test.c diff --git a/XilinxProcessorIPLib/drivers/nandps8_v2_0/intgTest/intg.c b/XilinxProcessorIPLib/drivers/nandps8_v2_0/intgTest/intg.c index a1928067..51034373 100644 --- a/XilinxProcessorIPLib/drivers/nandps8_v2_0/intgTest/intg.c +++ b/XilinxProcessorIPLib/drivers/nandps8_v2_0/intgTest/intg.c @@ -87,6 +87,8 @@ #define MENU_TEST_SPAREBYTES_RW 4 #define MENU_TEST_PARTIAL_RW 5 #define MENU_TEST_ECC 6 +#define MENU_TEST_BBT 7 +#define MENU_TEST_MARK_BLOCK_BAD 8 #define MENU_TEST_EXIT 99 /*@}*/ @@ -101,6 +103,8 @@ #define INTG_TEST_SPAREBYTES_RW (1 << MENU_TEST_SPAREBYTES_RW) #define INTG_TEST_PARTIAL_RW (1 << MENU_TEST_PARTIAL_RW) #define INTG_TEST_ECC (1 << MENU_TEST_ECC) +#define INTG_TEST_BBT (1 << MENU_TEST_BBT) +#define INTG_TEST_MARK_BLOCK_BAD (1 << MENU_TEST_MARK_BLOCK_BAD) /*@}*/ /** @@ -177,6 +181,7 @@ extern char inbyte (); /**< Inbyte returns the byte received by device. */ s32 FlashInit(u16 NandDeviceId); #ifdef AUTOMATIC_TEST_MODE int Automode_Tests(int TestLoops); +int CodeCoverage_Tests(int TestLoops); #endif /*****************************************************************************/ @@ -355,6 +360,11 @@ void Intg_Entry(void) TestFailures += Automode_Tests(TestLoops); } + /* + * Run Code Coverage Tests + */ + TestFailures += CodeCoverage_Tests(TestLoops); + if (TestFailures) { XIL_FAIL(TestFailures); } else { @@ -394,6 +404,36 @@ int Automode_Tests(int TestLoops) return failures; } + +/*****************************************************************************/ +/** +* +* Code Coverage Tests +* +* Executes all code coverage tests for the device +* +* param TestLoops: Number of times a test should run. +* +* @return Total Test failures +* +* @note None +* +******************************************************************************/ +int CodeCoverage_Tests(int TestLoops) +{ + volatile int failures = 0; + + xil_printf("\tRunning Code Coverage Tests Now\r\n"); + + XNandPs8_DisableDmaMode(NandInstPtr); + failures += Automode_Tests(TestLoops); + XNandPs8_EnableDmaMode(NandInstPtr); + failures += Intg_BbtTest(NandInstPtr, TestLoops); + failures += Intg_MarkBlockBadTest(NandInstPtr, TestLoops); + failures += Intg_CodeCoverageTest(NandInstPtr, TestLoops); + + return failures; +} #endif /*****************************************************************************/ @@ -469,8 +509,9 @@ static void RunTestMenu(char* CmdLine) MENU_TEST_SPAREBYTES_RW); printf("%d - Partial Page Read Write Test\r\n", MENU_TEST_PARTIAL_RW); - printf("%d - ECC Test.\r\n", - MENU_TEST_ECC); + printf("%d - ECC Test.\r\n", MENU_TEST_ECC); + printf("%d - BBT Scan Test.\r\n", MENU_TEST_BBT); + printf("%d - Mark Block Bad Test.\r\n", MENU_TEST_MARK_BLOCK_BAD); printf("%d - Exit to main menu\r\n\r\n", MENU_TEST_EXIT); printf("More than one test can be specified\r\n"); printf("Adding l sets the number of test loops\n\n"); @@ -521,6 +562,16 @@ static void RunTestMenu(char* CmdLine) INTG_TEST_ECC; break; + case MENU_TEST_BBT: + RunTestMask |= + INTG_TEST_BBT; + break; + + case MENU_TEST_MARK_BLOCK_BAD: + RunTestMask |= + INTG_TEST_MARK_BLOCK_BAD; + break; + case MENU_TEST_EXIT: QuitToMain = 1; break; @@ -564,6 +615,14 @@ static void RunTestMenu(char* CmdLine) TestFailures += Intg_EccTest(NandInstPtr, TestLoops); } + if (RunTestMask & INTG_TEST_BBT) { + TestFailures += Intg_BbtTest(NandInstPtr, TestLoops); + } + + if (RunTestMask & INTG_TEST_MARK_BLOCK_BAD) { + TestFailures += Intg_MarkBlockBadTest(NandInstPtr, TestLoops); + } + printf("************************************************\r\n"); if (TestFailures) { printf("* %d test FAILURE(s) recorded\r\n", \ diff --git a/XilinxProcessorIPLib/drivers/nandps8_v2_0/intgTest/intg.h b/XilinxProcessorIPLib/drivers/nandps8_v2_0/intgTest/intg.h index 2e5e3169..4232619d 100644 --- a/XilinxProcessorIPLib/drivers/nandps8_v2_0/intgTest/intg.h +++ b/XilinxProcessorIPLib/drivers/nandps8_v2_0/intgTest/intg.h @@ -159,4 +159,19 @@ int Intg_PartialRWTest(XNandPs8 * NandInstPtr,int TestLoops); */ int Intg_EccTest(XNandPs8 * NandInstPtr,int TestLoops); +/* + * BBT Scan test implemented in intg_bbt_test.c + */ +int Intg_BbtTest(XNandPs8 * NandInstPtr, int TestLoops); + +/* + * Mark Block Bad test implemented in intg_markblockbad_test.c + */ +int Intg_MarkBlockBadTest(XNandPs8 * NandInstPtr, int TestLoops); + +/* + * Code Coverage test implemented in intg_codecoverage_test.c + */ +int Intg_CodeCoverageTest(XNandPs8 * NandInstPtr, int TestLoops); + #endif /**< End of protection macro */ diff --git a/XilinxProcessorIPLib/drivers/nandps8_v2_0/intgTest/intg_bbt_test.c b/XilinxProcessorIPLib/drivers/nandps8_v2_0/intgTest/intg_bbt_test.c new file mode 100755 index 00000000..1be2d186 --- /dev/null +++ b/XilinxProcessorIPLib/drivers/nandps8_v2_0/intgTest/intg_bbt_test.c @@ -0,0 +1,151 @@ +/****************************************************************************** +* +* (c) Copyright 2010-14 Xilinx, Inc. All rights reserved. +* +* This file contains confidential and proprietary information of Xilinx, Inc. +* and is protected under U.S. and international copyright and other +* intellectual property laws. +* +* DISCLAIMER +* This disclaimer is not a license and does not grant any rights to the +* materials distributed herewith. Except as otherwise provided in a valid +* license issued to you by Xilinx, and to the maximum extent permitted by +* applicable law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND WITH ALL +* FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS, +* IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF +* MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE +* and (2) Xilinx shall not be liable (whether in contract or tort, including +* negligence, or under any other theory of liability) for any loss or damage +* of any kind or nature related to, arising under or in connection with these +* materials, including for any direct, or any indirect, special, incidental, +* or consequential loss or damage (including loss of data, profits, goodwill, +* or any type of loss or damage suffered as a result of any action brought by +* a third party) even if such damage or loss was reasonably foreseeable or +* Xilinx had been advised of the possibility of the same. +* +* CRITICAL APPLICATIONS +* Xilinx products are not designed or intended to be fail-safe, or for use in +* any application requiring fail-safe performance, such as life-support or +* safety devices or systems, Class III medical devices, nuclear facilities, +* applications related to the deployment of airbags, or any other applications +* that could lead to death, personal injury, or severe property or +* environmental damage (individually and collectively, "Critical +* Applications"). Customer assumes the sole risk and liability of any use of +* Xilinx products in Critical Applications, subject only to applicable laws +* and regulations governing limitations on product liability. +* +* THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS PART OF THIS FILE +* AT ALL TIMES. +* +******************************************************************************/ +/*****************************************************************************/ +/** +* +* @file intg_bbt_test.c +* +* This file contains the design example for using NAND driver (XNandPs8). +* This example scans the Bbt on the flash. If found returns success else +* Creates a new BBT and writes it on the flash. +* +* @note None. +* +* +*
+*
+* MODIFICATION HISTORY:
+*
+* Ver   Who    Date	 Changes
+* ----- -----  -------- -----------------------------------------------
+* 1.0   sb    11/28/2014 First release
+*
+*
+* 
+* +******************************************************************************/ + +/***************************** Include Files ********************************/ + +#include "intg.h" + +/************************** Constant Definitions ****************************/ + +/**************************** Type Definitions ******************************/ + +/***************** Macros (Inline Functions) Definitions ********************/ + +/************************** Variable Definitions ****************************/ + +/************************** Function Prototypes *****************************/ +s32 Bbt_Test(XNandPs8 * NandInstPtr); +/************************** Function Definitions ****************************/ + +/****************************************************************************/ +/** +* +* Entry point to call the Bbt Scan test. +* +* @param NandInstPtr - Instance to the nand driver. +* @param TestLoops - Number of tests to execute. +* +* @return Number of test failures. +* +* @note None. +* +*****************************************************************************/ +int Intg_BbtTest(XNandPs8 * NandInstPtr, int TestLoops) +{ + + s32 Status = XST_FAILURE; + CT_TestReset("Module Bbt Scan test"); + + while(TestLoops--) { + Status = Bbt_Test(NandInstPtr); + if (Status != XST_SUCCESS) { + CT_LOG_FAILURE("Bbt Scan Test Failed\r\n"); + break; + } + CT_NotifyNextPass(); + } + + return(CT_GetTestFailures()); +} + +/****************************************************************************/ +/** +* +* This function runs a test on the NAND flash device using the basic driver +* functions in polled mode. +* The function does the following tasks: +* Scan for Bad Block table. +* If not found Create new and write it onto flash. +* +* @param NandInstPtr - Instance to the nand driver. +* @param NandDeviceId is is the XPAR__DEVICE_ID value +* from xparameters.h. +* +* @return +* +* @note +* None +* +****************************************************************************/ +s32 Bbt_Test(XNandPs8 * NandInstPtr) +{ + s32 Status = XST_FAILURE; + + /* + * Enabling Ecc Mode + */ + XNandPs8_EnableEccMode(NandInstPtr); + + /* + * Scanning for Bbt + */ + Status = XNandPs8_ScanBbt(NandInstPtr); + if(Status != XST_SUCCESS) { + xil_printf("Bad Block table not found " + "New Bbt created\r\n"); + } + + return XST_SUCCESS; +} diff --git a/XilinxProcessorIPLib/drivers/nandps8_v2_0/intgTest/intg_codecoverage_test.c b/XilinxProcessorIPLib/drivers/nandps8_v2_0/intgTest/intg_codecoverage_test.c new file mode 100755 index 00000000..c7947e9b --- /dev/null +++ b/XilinxProcessorIPLib/drivers/nandps8_v2_0/intgTest/intg_codecoverage_test.c @@ -0,0 +1,186 @@ +/****************************************************************************** +* +* (c) Copyright 2010-14 Xilinx, Inc. All rights reserved. +* +* This file contains confidential and proprietary information of Xilinx, Inc. +* and is protected under U.S. and international copyright and other +* intellectual property laws. +* +* DISCLAIMER +* This disclaimer is not a license and does not grant any rights to the +* materials distributed herewith. Except as otherwise provided in a valid +* license issued to you by Xilinx, and to the maximum extent permitted by +* applicable law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND WITH ALL +* FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS, +* IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF +* MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE +* and (2) Xilinx shall not be liable (whether in contract or tort, including +* negligence, or under any other theory of liability) for any loss or damage +* of any kind or nature related to, arising under or in connection with these +* materials, including for any direct, or any indirect, special, incidental, +* or consequential loss or damage (including loss of data, profits, goodwill, +* or any type of loss or damage suffered as a result of any action brought by +* a third party) even if such damage or loss was reasonably foreseeable or +* Xilinx had been advised of the possibility of the same. +* +* CRITICAL APPLICATIONS +* Xilinx products are not designed or intended to be fail-safe, or for use in +* any application requiring fail-safe performance, such as life-support or +* safety devices or systems, Class III medical devices, nuclear facilities, +* applications related to the deployment of airbags, or any other applications +* that could lead to death, personal injury, or severe property or +* environmental damage (individually and collectively, "Critical +* Applications"). Customer assumes the sole risk and liability of any use of +* Xilinx products in Critical Applications, subject only to applicable laws +* and regulations governing limitations on product liability. +* +* THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS PART OF THIS FILE +* AT ALL TIMES. +* +******************************************************************************/ +/*****************************************************************************/ +/** +* +* @file intg_codecoverage_test.c +* +* This file contains the design example for using NAND driver (XNandPs8). +* This example scans the Bbt on the flash. If found returns success else +* Creates a new BBT and writes it on the flash. +* +* @note None. +* +* +*
+*
+* MODIFICATION HISTORY:
+*
+* Ver   Who    Date	 Changes
+* ----- -----  -------- -----------------------------------------------
+* 1.0   sb    12/18/2014 First release
+*
+*
+* 
+* +******************************************************************************/ + +/***************************** Include Files ********************************/ + +#include "intg.h" + +/************************** Constant Definitions ****************************/ + +/**************************** Type Definitions ******************************/ + +/***************** Macros (Inline Functions) Definitions ********************/ +#define EXPECTED_FAILURES 2 +#define RANDOM_DEVICEID 1U +/************************** Variable Definitions ****************************/ + +/************************** Function Prototypes *****************************/ +s32 CodeCoverage_Test(XNandPs8 * NandInstPtr); +/************************** Function Definitions ****************************/ + +/****************************************************************************/ +/** +* +* Entry point to call the Code Coverage test. +* +* @param NandInstPtr - Instance to the nand driver. +* @param TestLoops - Number of tests to execute. +* +* @return Number of test failures. +* +* @note None. +* +*****************************************************************************/ +int Intg_CodeCoverageTest(XNandPs8 * NandInstPtr, int TestLoops) +{ + + s32 Status = XST_FAILURE; + CT_TestReset("Module Code Coverage test"); + + while(TestLoops--) { + Status = CodeCoverage_Test(NandInstPtr); + if (Status != XST_SUCCESS) { + CT_LOG_FAILURE("Code Coverage Test Failed\r\n"); + break; + } + CT_NotifyNextPass(); + } + + return(CT_GetTestFailures()); +} + +/****************************************************************************/ +/** +* +* This function runs a test on the NAND flash device using the basic driver +* functions in polled mode. +* The function does the following tasks: +* - Performs Code Coverage for +* -XNandPs8_WriteSpareBytes +* -XNandPs8_LookupConfig +* +* @param NandInstPtr - Instance to the nand driver. +* +* @return +* +* @note +* None +* +****************************************************************************/ +s32 CodeCoverage_Test(XNandPs8 * NandInstPtr) +{ + s32 Status = XST_FAILURE; + u32 Index; + u64 Offset; + u16 Length; + s32 Failures = 0; + + Offset = (u64)(TEST_PAGE_START * NandInstPtr->Geometry.PagesPerBlock); + Length = NandInstPtr->Geometry.BytesPerPage; + + /* + * Initialize the write buffer + */ + for (Index = 0; Index < Length;Index++) { + WriteBuffer[Index] = (u8) (rand() % 256); + } + + /* + * Altering Ecc Address for covering code in + * XNandPs8_WriteSpareBytes API + */ + NandInstPtr->EccCfg.EccAddr -= 8U; + + /* + * Enabling DMA Mode + */ + XNandPs8_EnableDmaMode(NandInstPtr); + /* + * Write to flash Spare Bytes Section + */ + Status = XNandPs8_WriteSpareBytes(NandInstPtr, (u32)Offset, + &WriteBuffer[0]); + if (Status != XST_SUCCESS) { + Failures++; + } + /* + * Reverting the Ecc Address back to original. + */ + NandInstPtr->EccCfg.EccAddr += 8U; + + /* + * Code Coverage for LookUp Config API + */ + Status = XNandPs8_LookupConfig(RANDOM_DEVICEID); + if (Status != XST_SUCCESS){ + Failures++; + } + + if(Failures != EXPECTED_FAILURES){ + Status = XST_SUCCESS; + } + + return Status; +} diff --git a/XilinxProcessorIPLib/drivers/nandps8_v2_0/intgTest/intg_markblockbad_test.c b/XilinxProcessorIPLib/drivers/nandps8_v2_0/intgTest/intg_markblockbad_test.c new file mode 100755 index 00000000..567f1877 --- /dev/null +++ b/XilinxProcessorIPLib/drivers/nandps8_v2_0/intgTest/intg_markblockbad_test.c @@ -0,0 +1,222 @@ +/****************************************************************************** +* +* (c) Copyright 2010-14 Xilinx, Inc. All rights reserved. +* +* This file contains confidential and proprietary information of Xilinx, Inc. +* and is protected under U.S. and international copyright and other +* intellectual property laws. +* +* DISCLAIMER +* This disclaimer is not a license and does not grant any rights to the +* materials distributed herewith. Except as otherwise provided in a valid +* license issued to you by Xilinx, and to the maximum extent permitted by +* applicable law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND WITH ALL +* FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS, +* IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF +* MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE +* and (2) Xilinx shall not be liable (whether in contract or tort, including +* negligence, or under any other theory of liability) for any loss or damage +* of any kind or nature related to, arising under or in connection with these +* materials, including for any direct, or any indirect, special, incidental, +* or consequential loss or damage (including loss of data, profits, goodwill, +* or any type of loss or damage suffered as a result of any action brought by +* a third party) even if such damage or loss was reasonably foreseeable or +* Xilinx had been advised of the possibility of the same. +* +* CRITICAL APPLICATIONS +* Xilinx products are not designed or intended to be fail-safe, or for use in +* any application requiring fail-safe performance, such as life-support or +* safety devices or systems, Class III medical devices, nuclear facilities, +* applications related to the deployment of airbags, or any other applications +* that could lead to death, personal injury, or severe property or +* environmental damage (individually and collectively, "Critical +* Applications"). Customer assumes the sole risk and liability of any use of +* Xilinx products in Critical Applications, subject only to applicable laws +* and regulations governing limitations on product liability. +* +* THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS PART OF THIS FILE +* AT ALL TIMES. +* +******************************************************************************/ +/*****************************************************************************/ +/** +* +* @file intg_markblockbad_test.c +* +* This file contains the design example for using NAND driver (XNandPs8). +* This example tests the erase, read and write feature of the controller. +* The flash is erased and written. The data is +* read back and compared with the data written for correctness. +* +* @note None. +* +* +*
+*
+* MODIFICATION HISTORY:
+*
+* Ver   Who    Date	 Changes
+* ----- -----  -------- -----------------------------------------------
+* 1.0   sb    12/18/2014 First release
+*
+*
+* 
+* +******************************************************************************/ + +/***************************** Include Files ********************************/ + +#include "intg.h" + +/************************** Constant Definitions ****************************/ + +/**************************** Type Definitions ******************************/ + +/***************** Macros (Inline Functions) Definitions ********************/ + +/************************** Variable Definitions ****************************/ + +/************************** Function Prototypes *****************************/ +s32 Mark_BlockBad_Test(XNandPs8 * NandInstPtr); +/************************** Function Definitions ****************************/ + +/****************************************************************************/ +/** +* +* Entry point to call the Mark Block Bad R/W test. +* +* @param NandInstPtr - Instance to the nand driver. +* @param TestLoops - Number of tests to execute. +* +* @return Number of test failures. +* +* @note None. +* +*****************************************************************************/ +int Intg_MarkBlockBadTest(XNandPs8 * NandInstPtr, int TestLoops) +{ + + s32 Status = XST_FAILURE; + CT_TestReset("Module Mark Block Bad test"); + + while(TestLoops--) { + Status = Mark_BlockBad_Test(NandInstPtr); + if (Status != XST_SUCCESS) { + CT_LOG_FAILURE("Mark Block Bad Test Failed" + " with %d mismatches\r\n", MismatchCounter); + break; + } + CT_NotifyNextPass(); + + } + + return(CT_GetTestFailures()); +} + +/****************************************************************************/ +/** +* +* This function runs a test on the NAND flash device using the basic driver +* functions in polled mode. +* The function does the following tasks: +* - Marks Blocks bad. +* - Erase the blocks. +* - Write data to the blocks. +* - Read back the data from the blocks. +* - Compare the data read against the data Written. +* +* @param NandInstPtr - Instance to the nand driver. +* +* @return +* - XST_SUCCESS if successful. +* - XST_FAILURE if failed. +* +* @note +* None +* +****************************************************************************/ +s32 Mark_BlockBad_Test(XNandPs8 * NandInstPtr) +{ + s32 Status = XST_FAILURE; + s32 BlockNo; + s32 i; + u32 Index; + u64 PageOff; + u32 Length; + u32 BlockSize = NandInstPtr->Geometry.BlockSize; + u64 BlockOff; + MismatchCounter = 0; + + PageOff = (u64)(TEST_PAGE_START * NandInstPtr->Geometry.BytesPerPage); + Length = NandInstPtr->Geometry.BytesPerPage; + + /* + * Initialize the write buffer + */ + for (Index = 0; Index < Length;Index++) { + WriteBuffer[Index] = 2U; + } + + /* + * Marking blocks 1 & 3 as bad + */ + for (BlockNo = 0 ; BlockNo < 5 ; BlockNo++){ + if(BlockNo%2 == 0){ + continue; + } + Status = XNandPs8_MarkBlockBad(NandInstPtr,BlockNo); + if(Status != XST_SUCCESS){ + goto Out; + } + } + /* + * Performing Block Erase Read Write on Block 1,2,3 + */ + for (BlockNo = TEST_BLOCK_START ; BlockNo < TEST_BLOCK_START + 3 ; BlockNo++ ){ + + BlockOff = BlockNo * BlockSize; + + xil_printf("Erasing Block = %d \r\n", BlockNo); + /* + * Erase the Block 1,2,3 + */ + Status = XNandPs8_Erase(NandInstPtr, (u64)BlockOff, (u64)BlockSize); + if (Status != XST_SUCCESS) { + goto Out; + } + + PageOff = BlockOff; + + for (i = 0; i < NandInstPtr->Geometry.PagesPerBlock; i++){ + /* + * Write to page offset + */ + Status = XNandPs8_Write(NandInstPtr, (u64)PageOff, (u64)Length, + &WriteBuffer[0]); + if (Status != XST_SUCCESS) { + goto Out; + } + /* + * Read from the page after writing + */ + Status = XNandPs8_Read(NandInstPtr, (u64)PageOff, (u64)Length, + &ReadBuffer[0]); + if (Status != XST_SUCCESS) { + goto Out; + } + /* + * Compare the results + */ + for (Index = 0U; Index < Length;Index++) { + if (ReadBuffer[Index] != WriteBuffer[Index]) { + MismatchCounter++; + Status = XST_FAILURE; + } + } + PageOff = PageOff + NandInstPtr->Geometry.BytesPerPage; + } + } + +Out: + return Status; +}