nandpsu_v1_0: Renamed integration test directory to "intgtest"
Signed-off-by: Shakti Bhatnagar <shaktib@xilinx.com>
This commit is contained in:
parent
5ebc54dfa8
commit
61ce44e6b9
15 changed files with 0 additions and 3846 deletions
|
@ -1 +0,0 @@
|
|||
Empty application. Add your own sources.
|
|
@ -1,586 +0,0 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* (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 ct.h
|
||||
*
|
||||
* Code test (CT) utility driver.
|
||||
*
|
||||
* This package is intended to help designers test their Xilinx device drivers
|
||||
* in unit and integration testing environments. The macros and functions
|
||||
* provide the following services:
|
||||
*
|
||||
* - Automated data comparison
|
||||
* - Xilinx driver assert testing
|
||||
* - Interrupt utilities
|
||||
* - Error & message logging
|
||||
* - Test sequencing utilities
|
||||
* - Timing utilities
|
||||
*
|
||||
* The main benefit of this package is to simplify test code and make it easier
|
||||
* for the tester to get more coverage in their integration and unit testing
|
||||
* without having to replicate common testing constructs.
|
||||
*
|
||||
* <b>Integrating CT Source code</b>
|
||||
*
|
||||
* This package consists of this header file and an implementation file. The
|
||||
* implementation can be operating system specific. When including this package
|
||||
* in your test, use this file and one of the CT implementation files such as
|
||||
* ct_vxworks.c.
|
||||
*
|
||||
* There are GNU specific "C" extensions used in this package and as a result
|
||||
* make it non-ANSI compliment. The tester must compile this package and their
|
||||
* other test code with the GNU compiler suite.
|
||||
*
|
||||
* The CT package requires that there be available standard header files
|
||||
* stdio.h, string.h, and stdarg.h.
|
||||
*
|
||||
*
|
||||
* <b>Setup and Test Sequencing</b>
|
||||
*
|
||||
* Before calling any comparison or utility function in this package, the tester
|
||||
* should call CT_Init() to initialize the library. This function only needs to
|
||||
* be called once.
|
||||
*
|
||||
* During tests, your code may be segmented into sub tests where you would want
|
||||
* separate out the results. At the end of all sub tests, you may want to
|
||||
summarize
|
||||
* all the tests run. The following pseudo code shows how this is done with CT
|
||||
* sequencing function calls:
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* CT_Init();
|
||||
*
|
||||
* // Subtest #1
|
||||
* CT_TestReset("This is my Subtest #1");
|
||||
* ...
|
||||
* // Subtest code
|
||||
* ...
|
||||
* Failures = CT_GetTestFailures();
|
||||
* CT_Message("Subtest #1 had %d failures\r\n", Failures);
|
||||
*
|
||||
* // Subtest #2
|
||||
* CT_TestReset("This is my Subtest #2");
|
||||
* ...
|
||||
* // Subtest code
|
||||
* ...
|
||||
* Failures = CT_GetTestFailures();
|
||||
* CT_Message("Subtest #2 had %d failures\r\n", Failures);
|
||||
*
|
||||
* Failures = CT_GetTotalFailures();
|
||||
* CT_Message("Total test failures = %d\r\n", Failures);
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* <b>General Usage</b>
|
||||
*
|
||||
* The heart of this package utilizes macros to compare variables or memory
|
||||
* areas. For example,
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* CT_CMP_NUM(int, ActualValue, ExpectedValue);
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* compares two values of type int. If they are not equal, then an error message
|
||||
* is logged and an internal counter is incremented. If they are equal, then the
|
||||
* test proceeds as if nothing had occurred. Other examples:
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* CT_CMP_NUM(int, *ActualPtr, 5);
|
||||
* CT_CMP_NUM(int*, ActualPtr, 0x20002100);
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* With each failure, a descriptive message is printed along with the line number
|
||||
* of the invoking code.
|
||||
*
|
||||
* If the tester needs to make a comparison manually, then they can use the
|
||||
* CT_LOG_FAILURE() macro to note the error in case the comparison is negative.
|
||||
* If the tester needs to emit an informational message, then they can use the
|
||||
* CT_Mesage() function. Calling this function does not increment error counters.
|
||||
*
|
||||
*
|
||||
* <b>Message Logging</b>
|
||||
*
|
||||
* This package uses the printf() library for message logging.
|
||||
*
|
||||
* Ideally, the tester's environment should include some sort of UART. By
|
||||
* default CT utilizes a pre-configured console UART.
|
||||
*
|
||||
* If your system does not contain a UART, then another method of providing
|
||||
* results includes printf'ing messages to memory. To enable this method,
|
||||
* enable the definition of IO_USE_BUFFER in this file. To further tailor this
|
||||
* method of logging, change IO_BUF_SIZE and IO_BUF_CUSHION. All output will
|
||||
* be written to the TextBuf array. Use your debugger or your own test
|
||||
* utilities to examine this buffer for generated output.
|
||||
*
|
||||
*
|
||||
* <b>Limitations</b>
|
||||
*
|
||||
* - This package must be compiled under the GNU compiler suite.
|
||||
* - CT_CMP macros can compare only ordinal data types. Structure type
|
||||
* comparisons require the tester to implement their own function.
|
||||
* - Some sort of BSP is required to support implementation of string.h,
|
||||
* stdio.h, and stdarg.h at a minimum.
|
||||
* - Advanced BSP support of signal.h is required to use CT_SetAlarm().
|
||||
* If support is not available, then this function will return an error.
|
||||
* - Testing asserts requires that NDEBUG not be defined in your driver under
|
||||
* test code.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* --- ---- -------- -----------------------------------------------
|
||||
* 1 rmm 12/23/03 First release for VxWorks
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef CT_H
|
||||
#define CT_H
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xil_types.h" /* Needed for assert testing */
|
||||
#include "xil_assert.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include "intg.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
|
||||
/**
|
||||
* This is what the CT_Log* lines will be prefixed with. The numerical arg
|
||||
* should be the line number within the source file containing the call to
|
||||
* the CT library function or macro.
|
||||
*/
|
||||
#define CT_ERR_FMT " FAIL: %s: %04d:"
|
||||
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
typedef unsigned long long CT_TIME_STAMP; /**< Type defination for Time Stamp.*/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Log a failure with a supplied message. This provides a useful wrapper
|
||||
* around the CT_LogFailure function that prints messages of the same format
|
||||
* as other CT macros:
|
||||
*
|
||||
* <pre>
|
||||
* 1 int i;
|
||||
* 2
|
||||
* 3 i = 10;
|
||||
* 4 if (i != 5)
|
||||
* 5 {
|
||||
* 6 CT_LOG_FAILURE("GetDataFromDevice() returned %d instead of 5", i);
|
||||
* 7 CT_LOG_FAILURE("D'oh");
|
||||
* 8 }
|
||||
* </pre>
|
||||
*
|
||||
* yields the output:
|
||||
*
|
||||
* FAIL: 0006: GetDataFromDevice() returned 10 instead of 5
|
||||
* FAIL: 0007: D'oh
|
||||
*
|
||||
* @param fmt is a printf style format string
|
||||
* @param args is a variable argument list that matches fields in the fmt
|
||||
* string.
|
||||
*
|
||||
* @note
|
||||
* Usage: CT_LOG_FAILURE(char* fmt, ...)
|
||||
*****************************************************************************/
|
||||
#define CT_LOG_FAILURE(fmt, args...) \
|
||||
CT_LogFailure(CT_ERR_FMT fmt "\r\n", __FILE__, __LINE__ , ## args)
|
||||
|
||||
/* Note: In the preceding construct, the space between __FILE__, __LINE__ and
|
||||
* the comma are needed for the ## args to work when there is no "args"
|
||||
* expansion like in line 7 of the example shown above.
|
||||
*/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Test asserts for a function. This macro will verify whether the called
|
||||
* function generates an assert from the provided arguments. If it does not
|
||||
* then a failure message is logged.
|
||||
*
|
||||
* The design of this macro allows the tester to verify an assert occurs
|
||||
* with a single line of code with full type checking of the called
|
||||
* function. For example, if your function under test is coded as:
|
||||
*
|
||||
* <pre>
|
||||
* void XDev_Start(Dev* Instance)
|
||||
* {
|
||||
* Xil_AssertVoid(Dev != NULL);
|
||||
* ...
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* Then use CT_ASSERT in the following way to verify that the assert is caught.
|
||||
*
|
||||
* <pre>
|
||||
* CT_ASSERT(XDev_Start, (Dev*)NULL);
|
||||
* </pre>
|
||||
*
|
||||
* @param Function is the function being tested for asserts.
|
||||
* @param args is a variable number of arguments. It contains whatever arguments
|
||||
* should cause an assert. These arguments are arranged by the
|
||||
* preprocessor in the order provided by the tester.
|
||||
*
|
||||
* @note
|
||||
* Usage: CT_ASSERT(SomeFunc, arg1, arg2, ...)
|
||||
*****************************************************************************/
|
||||
#define CT_ASSERT(Function, args...) \
|
||||
{ \
|
||||
if (CT_IsAssertDisabled()) \
|
||||
CT_LogFailure(CT_ERR_FMT "NDEBUG is defined, assert test failed\r\n", \
|
||||
__FILE__, __LINE__); \
|
||||
else \
|
||||
{ \
|
||||
XAssertStatus = XASSERT_NONE; \
|
||||
XWaitInAssert = FALSE; \
|
||||
(void)Function(args); \
|
||||
XWaitInAssert = TRUE; \
|
||||
if (XAssertStatus == XASSERT_NONE) \
|
||||
CT_LogFailure(CT_ERR_FMT "Assert failed\r\n", __FILE__, __LINE__); \
|
||||
} \
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Compare numbers. If not equal, then output message and increment fail
|
||||
* counter. The message contains the line number of the failure, the
|
||||
* name of the variable, and its actual and expected values in hex and
|
||||
* decimal. An example:
|
||||
*
|
||||
* <pre>
|
||||
* 1 UINT32 result = 5;
|
||||
* 2 UINT32 expected = 17;
|
||||
* 3
|
||||
* 4 CT_CMP_NUM(UINT32, result, expected)
|
||||
*
|
||||
* yields the output:
|
||||
*
|
||||
* FAIL: 0004: result=5(5h), expected 17(11h)
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @param type is data type to compare (must be an ordinal type such as int)
|
||||
* @param actual is the actual data retrieved from test
|
||||
* @param expected is the expected value
|
||||
*
|
||||
* @note
|
||||
* Usage: CT_CMP_NUM(<type>, actual, expected)
|
||||
****************************************************************************/
|
||||
#define CT_CMP_NUM(type, actual, expected) \
|
||||
if ((type)(actual) != (type)(expected)) \
|
||||
{ \
|
||||
printf(CT_ERR_FMT "%s=%d(%Xh), expected %d(%Xh)\r\n", \
|
||||
__FILE__, __LINE__, #actual, (int)actual, (int)actual, \
|
||||
(int)expected, (int)expected); \
|
||||
CT_LogFailure2(); \
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Like CT_CMP_NUM except an extra argument is printed. Helpful if comparing
|
||||
* numbers in a loop where the loop index may prove useful if the test fails.
|
||||
*
|
||||
* <pre>
|
||||
* 1 UINT32 result[5];
|
||||
* 2 UINT32 expected[5];
|
||||
* 3 int i;
|
||||
* 4
|
||||
* 5 for (i=0; i<5; i++)
|
||||
* 6 {
|
||||
* 7 CT_CMP_NUM_ARG(UINT32, result[i], expected[i], i);
|
||||
* 8 }
|
||||
* 9
|
||||
*
|
||||
* yeilds the output if for example failure occurs at i=3:
|
||||
*
|
||||
* FAIL: 0007: result=5(5h), expected 17(11h). i=3
|
||||
* </pre>
|
||||
*
|
||||
* @param type is data type to compare (must be an ordinal type such as int)
|
||||
* @param actual is the actual data retrieved from test
|
||||
* @param expected is the expected value
|
||||
* @param arg is an argument that can be treated as an integer.
|
||||
*
|
||||
* @note
|
||||
* Usage: CT_CMP_NUM_ARG(<type>, actual, expected, arg1)
|
||||
****************************************************************************/
|
||||
#define CT_CMP_NUM_ARG(type, actual, expected, arg) \
|
||||
if ((type)(actual) != (type)(expected)) \
|
||||
{ \
|
||||
CT_LogFailure(CT_ERR_FMT "%s=%d(%Xh), expected %d(%Xh). %s=%d\r\n", \
|
||||
__FILE__, __LINE__, #actual, (int)actual, (int)actual, \
|
||||
(int)expected, (int)expected, #arg, arg); \
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Like CT_CMP_NUM_ARG except a second extra argument is printed. Helpful if
|
||||
* comparing numbers in a loop where the loop index may prove useful if the test
|
||||
* fails.
|
||||
*
|
||||
* <pre>
|
||||
* 1 UINT32 result[5];
|
||||
* 2 UINT32 expected[5];
|
||||
* 3 int i, j=(int)&result[0];
|
||||
* 4
|
||||
* 5 for (i=0; i<5; i++, j++)
|
||||
* 6 {
|
||||
* 7 CT_CMP_NUM_ARG2(UINT32, result[i], expected[i], i, j);
|
||||
* 8 }
|
||||
* 9
|
||||
*
|
||||
* yeilds the output if for example failure occurs at i=3:
|
||||
*
|
||||
* FAIL: 0007: result=5(5h), expected 17(11h). i=3, j=543234
|
||||
* </pre>
|
||||
*
|
||||
* @param type is data type to compare (must be an ordinal type such as int)
|
||||
* @param actual is the actual data retrieved from test
|
||||
* @param expected is the expected value
|
||||
* @param arg1 is an argument that can be treated as an integer.
|
||||
* @param arg2 is an argument that can be treated as an integer.
|
||||
*
|
||||
* @note
|
||||
* Usage: CT_CMP_NUM_ARG2(<type>, actual, expected, arg1, arg2)
|
||||
****************************************************************************/
|
||||
#define CT_CMP_NUM_ARG2(type, actual, expected, arg1, arg2) \
|
||||
if ((type)(actual) != (type)(expected)) \
|
||||
{ \
|
||||
CT_LogFailure(CT_ERR_FMT "%s=%d(%Xh), expected %d(%Xh). %s=%d. \
|
||||
%s=%d\r\n",\
|
||||
__FILE__, __LINE__, #actual, (int)actual, (int)actual,\
|
||||
(int)expected, (int)expected, #arg1, arg1, #arg2, arg2);\
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Like CT_CMP_NUM except a range of memory is compared.
|
||||
*
|
||||
* @param type is data type to compare (must be an ordinal type such as int)
|
||||
* @param actual is the actual data retrieved from test and must be an array
|
||||
* of type
|
||||
* @param bytes is the number of bytes to test
|
||||
* @param expected is the expected value and must be of type.
|
||||
*
|
||||
* @note
|
||||
* Usage: CT_CMP_NUM_RANGE(<type>, <type> actual[], bytes, expected)
|
||||
****************************************************************************/
|
||||
#define CT_CMP_NUM_RANGE(type, actual, bytes, expected) \
|
||||
{ \
|
||||
int d112a; \
|
||||
int words = (bytes)/sizeof(type); \
|
||||
type *a = (type*)(actual); \
|
||||
\
|
||||
for (d112a=0; d112a<words; d112a++) \
|
||||
{ \
|
||||
if (a[d112a] != expected) \
|
||||
{ \
|
||||
CT_LogFailure(CT_ERR_FMT "%s[%d]=%d(%Xh), expected %d(%Xh)\r\n", \
|
||||
__FILE__, __LINE__, #actual, d112a, a[d112a], \
|
||||
a[d112a], \
|
||||
expected, expected); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Macro that compare two ranges of memory. If the areas are not equal, then
|
||||
* a message is output and the CT_NumFailures counter is incremented. Comparison
|
||||
* stops at the first failure.
|
||||
*
|
||||
* The failure message contains the line number of the failure, the
|
||||
* name of the variable, and its actual and expected values in hex and
|
||||
* decimal. An example:
|
||||
*
|
||||
* <pre>
|
||||
* 1 UINT32 result[500];
|
||||
* 2 UINT32 expected[500];
|
||||
* 3
|
||||
* 4 CT_CMP_MEM(UINT32, result, expected, 500)
|
||||
*
|
||||
* yeilds the output if result[13]=100 and expected[13]=121:
|
||||
*
|
||||
* FAIL: 0004: result[13]=100(64h), expected 121(79h)
|
||||
* </pre>
|
||||
*
|
||||
* @param type is data type to compare (must be an ordinal type such as int)
|
||||
* @param actual is the area of memory to test
|
||||
* @param expected is the expected contents
|
||||
* @param words is the number of data type "type" to test.
|
||||
*
|
||||
* @note
|
||||
* Usage: CT_CMP_MEM(<type>, <type> *actual, <type> *expected, unsigned words)
|
||||
****************************************************************************/
|
||||
#define CT_CMP_MEM(type, actual, expected, words) \
|
||||
{ \
|
||||
int d112a; \
|
||||
type *a = (type*)(actual); \
|
||||
type *e = (type*)(expected); \
|
||||
\
|
||||
for (d112a=0; d112a<words; d112a++) \
|
||||
{ \
|
||||
if (a[d112a] != e[d112a]) \
|
||||
{ \
|
||||
CT_LogFailure(CT_ERR_FMT "%s[%d]=%d(%Xh), expected %d(%Xh)\r\n", \
|
||||
__FILE__, __LINE__, #actual, d112a, a[d112a], \
|
||||
a[d112a], \
|
||||
e[d112a], e[d112a]); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Like CT_CMP_MEM except an extra argument is printed. Helpful if comparing
|
||||
* in a loop where the loop index may prove useful if the test fails.
|
||||
*
|
||||
* <pre>
|
||||
* 1 UINT32 result[TEST_WORDS];
|
||||
* 2 UINT32 expected[TEST_WORDS];
|
||||
* 3 int i;
|
||||
* 4
|
||||
* 5 for (i=0; i<3; i++)
|
||||
* 6 {
|
||||
* 7 CT_CMP_MEM_ARG(UINT32, result, expected, TEST_WORDS, i);
|
||||
* 8 taskDelay(10);
|
||||
* 8 }
|
||||
* 9
|
||||
*
|
||||
* yeilds the output if for example failure occurs at i=1, and result[2]=1,
|
||||
* and expected[2]=3:
|
||||
*
|
||||
* FAIL: 0007: result[2]=1(1h), expected 3(3h)
|
||||
* </pre>
|
||||
*
|
||||
* @param type is data type to compare (must be an ordinal type such as int)
|
||||
* @param actual is the area of memory to test
|
||||
* @param expected is the expected contents
|
||||
* @param words is the number of data type "type" to test.
|
||||
* @param index is an argument that can be treated as an integer.
|
||||
*
|
||||
* @note
|
||||
* Usage: CT_CM_MEM_ARG(<type>, <type> actual[], <type> expected[], index)
|
||||
****************************************************************************/
|
||||
#define CT_CMP_MEM_ARG(type, actual, expected, words, index) \
|
||||
{ \
|
||||
int d112a; \
|
||||
type *a = (type*)(actual); \
|
||||
type *e = (type*)(expected); \
|
||||
\
|
||||
for (d112a=0; d112a<words; d112a++) \
|
||||
{ \
|
||||
if (a[d112a] != e[d112a]) \
|
||||
{ \
|
||||
CT_LogFailure(CT_ERR_FMT "%s[%d]=%d(%Xh), expected %d(%Xh). \
|
||||
%s=%d\r\n",\
|
||||
__FILE__, __LINE__, #actual, d112a, a[d112a],\
|
||||
a[d112a], e[d112a], \
|
||||
e[d112a], #index, index); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Duplicate the data type. Can be used on any declared type.
|
||||
*
|
||||
* @param type is data type to copy
|
||||
* @param dest is destination data pointer
|
||||
* @param src is source data pointer
|
||||
*
|
||||
* @note
|
||||
* Usage: CT_COPY_STRUCT(<type>, <type> *dest, <type> *src)
|
||||
****************************************************************************/
|
||||
#define CT_COPY_STRUCT(type,dest,src) \
|
||||
{ \
|
||||
type *td = dest; \
|
||||
type *ts = src; \
|
||||
memcpy(td,ts,sizeof(type)); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
void CT_Init(void);
|
||||
void CT_TestReset(char *fmt, ...);
|
||||
void CT_NotifyNextPass(void);
|
||||
void CT_LogFailure(char* fmt, ...);
|
||||
void CT_LogFailure2();
|
||||
unsigned CT_GetTestFailures(void);
|
||||
unsigned CT_GetTotalFailures(void);
|
||||
void CT_Message(char *fmt, ...);
|
||||
void CT_MemSet(void *Address, char Value, unsigned Bytes);
|
||||
int CT_IsAssertDisabled(void);
|
||||
|
||||
#endif /* CT_H */
|
|
@ -1,299 +0,0 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* (c) Copyright 2010-2014 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 ct_standalone.c
|
||||
*
|
||||
* Implements Code test (CT) utility driver.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* --- ---- -------- -----------------------------------------------
|
||||
* 1.0 rmm 12/23/03 First release
|
||||
* 1.1 xd 03/16/04 Changed to support PPC405 without OS.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
#include "ct.h"
|
||||
#include "intg.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
unsigned CT_TotalFailures; /**< Total failures flag */
|
||||
unsigned CT_TestFailures; /**< Test failures flag */
|
||||
unsigned CT_TestPass; /**< Test pass flag */
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Initialize the CT subsystem.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* Nothing
|
||||
*
|
||||
******************************************************************************/
|
||||
void CT_Init(void)
|
||||
{
|
||||
CT_TestFailures = 0;
|
||||
CT_TotalFailures = 0;
|
||||
CT_TestPass = 0;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Reset for a new test and display a test specific message. This involves:
|
||||
*
|
||||
* - Zero out test failure counter.
|
||||
* - Print a message specified by the fmt parameter and its associated
|
||||
* arguments.
|
||||
*
|
||||
* @param fmt is a "printf" style format string.
|
||||
* @param ... is a variable number of arguments that match "fmt"
|
||||
*
|
||||
* @return Nothing
|
||||
*
|
||||
******************************************************************************/
|
||||
void CT_TestReset(char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
CT_TestFailures = 0;
|
||||
CT_TestPass = 1;
|
||||
|
||||
/* Print out the format and its associated argument list */
|
||||
va_start(args, fmt);
|
||||
printf(fmt, args);
|
||||
CT_Message("\r\n=====================================================");
|
||||
|
||||
va_end(args);
|
||||
CT_Message("\r\n");
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Display current test pass number to user
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* Nothing
|
||||
*
|
||||
******************************************************************************/
|
||||
void CT_NotifyNextPass(void)
|
||||
{
|
||||
printf("\r\n=====>Pass %d\r\n\r\n", CT_TestPass);
|
||||
CT_TestPass++;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Log a test failure. This involves incrementing test failure and total test
|
||||
* failure counters, and displaying test specific message.
|
||||
*
|
||||
* @param fmt is a "printf" style format string.
|
||||
* @param ... is a variable number of arguments that match "fmt"
|
||||
*
|
||||
* @return Nothing
|
||||
*
|
||||
******************************************************************************/
|
||||
void CT_LogFailure(char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
/*
|
||||
* Increment failure counters
|
||||
*/
|
||||
CT_TestFailures++;
|
||||
CT_TotalFailures++;
|
||||
|
||||
/*
|
||||
* Print out the format and its associated argument list.
|
||||
*/
|
||||
va_start(args, fmt);
|
||||
|
||||
printf(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Log a test failure. This involves incrementing test failure and total test
|
||||
* failure counters, and displaying test specific message.
|
||||
*
|
||||
* param fmt is a "printf" style format string.
|
||||
* param ... is a variable number of arguments that match "fmt"
|
||||
*
|
||||
* @return Nothing
|
||||
*
|
||||
******************************************************************************/
|
||||
void CT_LogFailure2()
|
||||
{
|
||||
/*
|
||||
* Increment failure counters
|
||||
*/
|
||||
CT_TestFailures++;
|
||||
CT_TotalFailures++;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Return the number of test failures since CT_TestReset() was called.
|
||||
*
|
||||
* @return Number of failures logged.
|
||||
*
|
||||
******************************************************************************/
|
||||
unsigned CT_GetTestFailures(void)
|
||||
{
|
||||
return(CT_TestFailures);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Return the number of test failures since CT_Init() was called.
|
||||
*
|
||||
* @return Total number of failures logged.
|
||||
*
|
||||
******************************************************************************/
|
||||
unsigned CT_GetTotalFailures(void)
|
||||
{
|
||||
return(CT_TotalFailures);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Return status of the Xilinx driver assert mechanism.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* 1 if asserts are disabled, 0 otherwise.
|
||||
*****************************************************************************/
|
||||
int CT_IsAssertDisabled(void)
|
||||
{
|
||||
#ifdef NDEBUG
|
||||
return(1);
|
||||
#else
|
||||
return(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Print a message based on the given format string and parameters.
|
||||
*
|
||||
* @param fmt is a "printf" style format string.
|
||||
* @param ... is a variable number of arguments that match "fmt"
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* Nothing
|
||||
*
|
||||
******************************************************************************/
|
||||
void CT_Message(char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
|
||||
printf(fmt, args);
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Set a series of bytes in memory to a specific value
|
||||
*
|
||||
* @param Address is the start address in memory to write
|
||||
* @param Value is the value to set memory to
|
||||
* @param Bytes is the number of bytes to set
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* Nothing
|
||||
*
|
||||
******************************************************************************/
|
||||
void CT_MemSet(void *Address, char Value, unsigned Bytes)
|
||||
{
|
||||
char* Ptr = Address;
|
||||
|
||||
while(Bytes--)
|
||||
{
|
||||
*Ptr++ = Value;
|
||||
}
|
||||
}
|
|
@ -1,850 +0,0 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* (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.c
|
||||
*
|
||||
* DESCRIPTION:
|
||||
*
|
||||
* Provides integration test entry point for the XNandPsu component.
|
||||
*
|
||||
* @note None
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- ----------------------------------------------------------------
|
||||
* 1.0 sb 11/28/14 First release.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "intg.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**
|
||||
* Main menu selections.
|
||||
* @{
|
||||
*/
|
||||
#define MENU_MAIN_TEST 1
|
||||
#define MENU_MAIN_UTIL 2
|
||||
#define MENU_MAIN_EXIT 99
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* Test sub-menu selections.
|
||||
* @{
|
||||
*/
|
||||
#define MENU_TEST_ALL 0
|
||||
#define MENU_TEST_ERASE_READ 1
|
||||
#define MENU_TEST_FLASH_RW 2
|
||||
#define MENU_TEST_RANDOM_RW 3
|
||||
#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
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* Create unique bitmasks from the test numbers.
|
||||
* @{
|
||||
*/
|
||||
#define INTG_TEST_ALL 0xFFFFFFFF
|
||||
#define INTG_TEST_ERASE_READ (1 << MENU_TEST_ERASE_READ)
|
||||
#define INTG_TEST_FLASH_RW (1 << MENU_TEST_FLASH_RW)
|
||||
#define INTG_TEST_RANDOM_RW (1 << MENU_TEST_RANDOM_RW)
|
||||
#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)
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* Utility sub-menu selections.
|
||||
* @{
|
||||
*/
|
||||
#define MENU_UTIL_DATA_INTERFACE 1
|
||||
#define MENU_UTIL_OOB_MODE 2
|
||||
#define MENU_UTIL_DMA_MODE 3
|
||||
#define MENU_UTIL_EXIT 99
|
||||
/*@}*/
|
||||
|
||||
typedef enum TimingMode {
|
||||
Mode0 = 0U,
|
||||
Mode1,
|
||||
Mode2,
|
||||
Mode3,
|
||||
Mode4,
|
||||
Mode5
|
||||
}NandPsu_TimingMode;
|
||||
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
/*
|
||||
* Buffers used during read and write transactions.
|
||||
*/
|
||||
u8 ReadBuffer[TEST_BUF_SIZE] __attribute__ ((aligned(64)));/**< Read buffer */
|
||||
u8 WriteBuffer[TEST_BUF_SIZE] __attribute__ ((aligned(64)));/**< write buffer */
|
||||
/**
|
||||
* Nand driver instance for the Nand device.
|
||||
*/
|
||||
XNandPsu NandInstance;
|
||||
XNandPsu *NandInstPtr = &NandInstance;
|
||||
|
||||
s32 MismatchCounter;
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
#ifndef AUTOMATIC_TEST_MODE
|
||||
static unsigned int GetUserInput(char* Prompt, char* Response,
|
||||
unsigned int
|
||||
MaxChars);
|
||||
static int GetMainMenuCommand(char* CmdLine);
|
||||
static void RunTestMenu(char* CmdLine);
|
||||
static void RunUtilMenu(char* CmdLine);
|
||||
#endif
|
||||
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
|
||||
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
* Retrieve a line of input from the user. A line is defined as all characters
|
||||
* up to a new line.
|
||||
*
|
||||
* This basically implements a fgets function. The standalone EDK stdin
|
||||
* is apparently buggy because it behaves differently when new line is
|
||||
* entered by itself vs. when it is entered after a number of regular chars
|
||||
* have been entered. Characters entered are echoed back.
|
||||
*
|
||||
* @param Prompt - Printed before string is accepted to ask the user to
|
||||
* enter something.
|
||||
* @param Response - User entered string with new line stripped
|
||||
* @param MaxChars - Maximum number of characters to read
|
||||
*
|
||||
* @return Number of characters read (excluding newlines)
|
||||
*
|
||||
*****************************************************************************/
|
||||
unsigned int GetUserInput(char* Prompt, char* Response, unsigned int MaxChars)
|
||||
{
|
||||
int Finished, i;
|
||||
|
||||
/* display prompt */
|
||||
if (Prompt) printf(Prompt);
|
||||
|
||||
Finished = 0;
|
||||
i = 0;
|
||||
|
||||
while(!Finished && (i < MaxChars - 1)) {
|
||||
/* flush out any output pending in stdout */
|
||||
fflush(stdout);
|
||||
|
||||
/* wait for a character to arrive */
|
||||
Response[i] = inbyte();
|
||||
|
||||
/* normal chars, add them to the string and keep going */
|
||||
if ((Response[i] >= 0x20) && (Response[i] <=0x7E)) {
|
||||
printf("%c", Response[i++]);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* control chars */
|
||||
switch(Response[i]) {
|
||||
/* carriage return */
|
||||
case 0x0D:
|
||||
/* Case Fall through */
|
||||
/* Line Feed */
|
||||
case 0x0A:
|
||||
Response[i++] = '\n';
|
||||
Finished = 1;
|
||||
printf("\r\n");
|
||||
break;
|
||||
|
||||
/* backspace */
|
||||
case 0x08:
|
||||
if (i != 0) {
|
||||
/* erase previous character and move
|
||||
cursor back one space */
|
||||
printf("\b \b");
|
||||
Response[--i] = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
/* ignore all other control chars */
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Response[i] = 0;
|
||||
return i;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Intg_Entry
|
||||
*
|
||||
* Executes all unit tests for the device
|
||||
*
|
||||
* param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*
|
||||
******************************************************************************/
|
||||
void Intg_Entry(void)
|
||||
{
|
||||
s32 Status = XST_FAILURE;
|
||||
#ifdef AUTOMATIC_TEST_MODE
|
||||
int TestLoops;
|
||||
int TestFailures;
|
||||
u32 t_mode = 0U;
|
||||
#else
|
||||
char CmdLine[132];
|
||||
#endif
|
||||
|
||||
/* print banner */
|
||||
printf("\r\n\r\nNand Driver Integration Test\r\n"
|
||||
"Created on %s\n\n\r", __DATE__);
|
||||
printf("=====================================================\r\n");
|
||||
|
||||
CT_Init();
|
||||
|
||||
Status = FlashInit(NAND_DEVICE_ID);
|
||||
if(Status != XST_SUCCESS){
|
||||
printf("Flash Initialization Failed\r\n");
|
||||
goto Out;
|
||||
}
|
||||
printf("Flash initialization done\r\n");
|
||||
#ifndef AUTOMATIC_TEST_MODE
|
||||
/* prompt user for menu selections */
|
||||
while(1) {
|
||||
switch(GetMainMenuCommand(CmdLine)) {
|
||||
case MENU_MAIN_TEST:
|
||||
RunTestMenu(CmdLine);
|
||||
break;
|
||||
|
||||
case MENU_MAIN_UTIL:
|
||||
RunUtilMenu(CmdLine);
|
||||
break;
|
||||
|
||||
case MENU_MAIN_EXIT:
|
||||
printf("\r\nByebye!\r\n");
|
||||
return;
|
||||
|
||||
default:
|
||||
printf("Invalid selection\r\n");
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* set defaults */
|
||||
TestLoops = 1;
|
||||
TestFailures = 0;
|
||||
|
||||
/*
|
||||
* Setting Interface
|
||||
*/
|
||||
NandInstPtr->DataInterface = XNANDPSU_SDR;
|
||||
|
||||
for (t_mode = Mode0; t_mode <= Mode5; t_mode++){
|
||||
NandInstPtr->DataInterface = XNANDPSU_SDR;
|
||||
|
||||
/*
|
||||
* Set Timing mode
|
||||
*/
|
||||
Status = XNandPsu_ChangeTimingMode(NandInstPtr, XNANDPSU_SDR, t_mode);
|
||||
if (Status != XST_SUCCESS) {
|
||||
goto Out;
|
||||
}
|
||||
xil_printf("\n\tCurrent Interface is SDR and Timing Mode is %d\r\n",
|
||||
t_mode);
|
||||
/*
|
||||
* Run the test cases
|
||||
*/
|
||||
TestFailures += Automode_Tests(TestLoops);
|
||||
}
|
||||
|
||||
for (t_mode = Mode0; t_mode <= Mode5; t_mode++){
|
||||
|
||||
NandInstPtr->DataInterface = XNANDPSU_NVDDR;
|
||||
/*
|
||||
* Set Timing mode
|
||||
*/
|
||||
Status = XNandPsu_ChangeTimingMode(NandInstPtr, XNANDPSU_NVDDR,
|
||||
t_mode);
|
||||
if (Status != XST_SUCCESS) {
|
||||
goto Out;
|
||||
}
|
||||
xil_printf("\n\tCurrent Interface is NVDDR and Timing Mode is "
|
||||
"%d\r\n", t_mode);
|
||||
/*
|
||||
* Run the test cases
|
||||
*/
|
||||
TestFailures += Automode_Tests(TestLoops);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set No OOB Option and Run Test Cases
|
||||
*/
|
||||
XNandPsu_DisableBbtOobMode(NandInstPtr);
|
||||
printf("NO OOB Mode selected..Scanning for BBT\r\n");
|
||||
Status = XNandPsu_ScanBbt(NandInstPtr);
|
||||
if(Status != XST_SUCCESS){
|
||||
printf("Scan BBT Failed\r\n");
|
||||
goto Out;
|
||||
}
|
||||
TestFailures += Automode_Tests(TestLoops);
|
||||
|
||||
/*
|
||||
* Run Code Coverage Tests
|
||||
*/
|
||||
TestFailures += CodeCoverage_Tests(TestLoops);
|
||||
|
||||
if (TestFailures) {
|
||||
XIL_FAIL(TestFailures);
|
||||
} else {
|
||||
XIL_PASS();
|
||||
}
|
||||
#endif
|
||||
|
||||
Out:
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef AUTOMATIC_TEST_MODE
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Auto Mode Tests
|
||||
*
|
||||
* Executes all unit tests for the device
|
||||
*
|
||||
* param TestLoops: Number of times a test should run.
|
||||
*
|
||||
* @return Total Test failures
|
||||
*
|
||||
* @note None
|
||||
*
|
||||
******************************************************************************/
|
||||
int Automode_Tests(int TestLoops)
|
||||
{
|
||||
volatile int failures = 0;
|
||||
|
||||
failures += Intg_EraseReadTest(NandInstPtr, TestLoops);
|
||||
failures += Intg_FlashRWTest(NandInstPtr, TestLoops);
|
||||
failures += Intg_RandomRWTest(NandInstPtr, TestLoops);
|
||||
failures += Intg_SpareBytesRWTest(NandInstPtr, TestLoops);
|
||||
failures += Intg_PartialRWTest(NandInstPtr, TestLoops);
|
||||
failures += Intg_EccTest(NandInstPtr, 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;
|
||||
|
||||
printf("\tRunning Code Coverage Tests Now\r\n");
|
||||
|
||||
XNandPsu_DisableDmaMode(NandInstPtr);
|
||||
failures += Automode_Tests(TestLoops);
|
||||
XNandPsu_EnableDmaMode(NandInstPtr);
|
||||
failures += Intg_BbtTest(NandInstPtr, TestLoops);
|
||||
failures += Intg_MarkBlockBadTest(NandInstPtr, TestLoops);
|
||||
failures += Intg_CodeCoverageTest(NandInstPtr, TestLoops);
|
||||
|
||||
return failures;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef AUTOMATIC_TEST_MODE
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Prompt the user for selections in the main menu. The user is allowed to
|
||||
* enter one command at a time.
|
||||
*
|
||||
* @param CmdLine - Storage to use for User input.
|
||||
*
|
||||
* @return Numeric command entered.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
static int GetMainMenuCommand(char* CmdLine)
|
||||
{
|
||||
/* prompt user */
|
||||
printf("\r\n\r\n\r\nMain Menu:\r\n"
|
||||
"==========\r\n");
|
||||
printf("%d - Test menu\r\n", MENU_MAIN_TEST);
|
||||
printf("%d - Util menu\r\n", MENU_MAIN_UTIL);
|
||||
printf("%d - Exit\r\n\r\n", MENU_MAIN_EXIT);
|
||||
|
||||
*CmdLine = '\n';
|
||||
while(*CmdLine == '\n') {
|
||||
printf("Enter selection: ");
|
||||
GetUserInput(0, CmdLine, 131);
|
||||
}
|
||||
return(atoi(CmdLine));
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Prompt the user for a sequence of tests to run in the test sub-menu
|
||||
*
|
||||
* @param CmdLine - Storage to use for User input
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*
|
||||
*****************************************************************************/
|
||||
static void RunTestMenu(char* CmdLine)
|
||||
{
|
||||
char* Token;
|
||||
char* tmp;
|
||||
int QuitToMain = 0;
|
||||
int TestLoops;
|
||||
int TestFailures;
|
||||
u32 RunTestMask;
|
||||
|
||||
/*
|
||||
* Flash Initialization Function
|
||||
*/
|
||||
|
||||
while(!QuitToMain) {
|
||||
/* set defaults */
|
||||
TestLoops = 1;
|
||||
RunTestMask = 0;
|
||||
TestFailures = 0;
|
||||
|
||||
/* prompt user */
|
||||
printf("\r\n\r\n\r\nTest Menu:\r\n"
|
||||
"==========\r\n");
|
||||
printf("%d - Run all tests\r\n", MENU_TEST_ALL);
|
||||
printf("%d - Flash Erase Read Test\r\n", MENU_TEST_ERASE_READ);
|
||||
printf("%d - Flash Read Write Test \r\n", MENU_TEST_FLASH_RW);
|
||||
printf("%d - Random Block Flash Read Write Test\r\n",
|
||||
MENU_TEST_RANDOM_RW);
|
||||
printf("%d - Spare Bytes Read Write Test \r\n",
|
||||
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 - 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"
|
||||
"Adding l <number> sets the number of test loops\n\n");
|
||||
|
||||
/* wait for input */
|
||||
*CmdLine = '\n';
|
||||
while(*CmdLine == '\n') {
|
||||
printf("Enter test(s) to execute: ");
|
||||
GetUserInput(0, CmdLine, 131);
|
||||
}
|
||||
|
||||
/* parse input line */
|
||||
Token = strtok_r(CmdLine, " ", &tmp);
|
||||
while(Token) {
|
||||
if ((*Token == 'l') || (*Token == 'L')) {
|
||||
TestLoops = atoi(Token+1);
|
||||
}
|
||||
else {
|
||||
switch(atoi(Token)) {
|
||||
case MENU_TEST_ALL:
|
||||
RunTestMask |= INTG_TEST_ALL;
|
||||
break;
|
||||
|
||||
case MENU_TEST_FLASH_RW:
|
||||
RunTestMask |= INTG_TEST_FLASH_RW;
|
||||
break;
|
||||
|
||||
case MENU_TEST_ERASE_READ:
|
||||
RunTestMask |= INTG_TEST_ERASE_READ;
|
||||
break;
|
||||
|
||||
case MENU_TEST_RANDOM_RW:
|
||||
RunTestMask |= INTG_TEST_RANDOM_RW;
|
||||
break;
|
||||
|
||||
case MENU_TEST_SPAREBYTES_RW:
|
||||
RunTestMask |=
|
||||
INTG_TEST_SPAREBYTES_RW;
|
||||
break;
|
||||
|
||||
case MENU_TEST_PARTIAL_RW:
|
||||
RunTestMask |=
|
||||
INTG_TEST_PARTIAL_RW;
|
||||
break;
|
||||
|
||||
case MENU_TEST_ECC:
|
||||
RunTestMask |=
|
||||
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;
|
||||
|
||||
default:
|
||||
printf("Unknown test id %s\r\n",
|
||||
Token);
|
||||
}
|
||||
}
|
||||
|
||||
Token = strtok_r(0, " ", &tmp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute selected tests
|
||||
*/
|
||||
if (QuitToMain == 1) break;
|
||||
|
||||
printf("\r\n\r\n");
|
||||
if (RunTestMask & INTG_TEST_ERASE_READ) {
|
||||
TestFailures += Intg_EraseReadTest(NandInstPtr, TestLoops);
|
||||
}
|
||||
|
||||
if (RunTestMask & INTG_TEST_FLASH_RW) {
|
||||
TestFailures += Intg_FlashRWTest(NandInstPtr, TestLoops);
|
||||
}
|
||||
|
||||
if (RunTestMask & INTG_TEST_RANDOM_RW) {
|
||||
TestFailures += Intg_RandomRWTest(NandInstPtr, TestLoops);
|
||||
}
|
||||
|
||||
if (RunTestMask & INTG_TEST_SPAREBYTES_RW) {
|
||||
TestFailures += Intg_SpareBytesRWTest(NandInstPtr, TestLoops);
|
||||
}
|
||||
|
||||
if (RunTestMask & INTG_TEST_PARTIAL_RW) {
|
||||
TestFailures += Intg_PartialRWTest(NandInstPtr, TestLoops);
|
||||
}
|
||||
|
||||
if (RunTestMask & INTG_TEST_ECC) {
|
||||
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", \
|
||||
TestFailures);
|
||||
} else {
|
||||
printf("* Tests pass\r\n");
|
||||
}
|
||||
printf("*********************************************\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Prompt the user for a selection in the utility sub-menu
|
||||
*
|
||||
* @param CmdLine - Storage to use for User input
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
static void RunUtilMenu(char* CmdLine)
|
||||
{
|
||||
int QuitToMain = 0;
|
||||
int Status = XST_FAILURE;
|
||||
|
||||
while(!QuitToMain) {
|
||||
/* prompt user */
|
||||
printf("\r\n\r\n\r\nUtil Menu:\r\n"
|
||||
"==========\r\n");
|
||||
printf("%d - Set Data Interface Timing Mode"
|
||||
"\r\n",MENU_UTIL_DATA_INTERFACE);
|
||||
printf("%d - Set OOB MODE\r\n",
|
||||
MENU_UTIL_OOB_MODE);
|
||||
printf("%d - Set DMA MODE\r\n",
|
||||
MENU_UTIL_DMA_MODE);
|
||||
/* wait for input */
|
||||
*CmdLine = '\n';
|
||||
while(*CmdLine == '\n') {
|
||||
printf("Enter selection: ");
|
||||
GetUserInput(0, CmdLine, 131);
|
||||
}
|
||||
|
||||
/* execute selection */
|
||||
switch(atoi(CmdLine)) {
|
||||
case MENU_UTIL_DATA_INTERFACE:
|
||||
printf(" 0. SDR \r\n 1. NVDDR\r\n");
|
||||
/* wait for input */
|
||||
*CmdLine = '\n';
|
||||
while(*CmdLine == '\n') {
|
||||
printf("Enter selection: ");
|
||||
GetUserInput(0, CmdLine, 131);
|
||||
}
|
||||
switch(atoi(CmdLine)) {
|
||||
case XNANDPSU_SDR:
|
||||
printf("Enter Timing Mode (0 - 5): ");
|
||||
/* wait for input */
|
||||
*CmdLine = '\n';
|
||||
while(*CmdLine == '\n') {
|
||||
GetUserInput(0, CmdLine, 131);
|
||||
}
|
||||
if((u8)atoi(CmdLine) >= 0 && (u8)atoi(CmdLine) <= 5){
|
||||
Status = XNandPsu_ChangeTimingMode(NandInstPtr,
|
||||
XNANDPSU_SDR,atoi(CmdLine));
|
||||
if (Status != XST_SUCCESS) {
|
||||
printf("Data Interface / Timing Mode Change"
|
||||
" failed\r\n");
|
||||
}
|
||||
else{
|
||||
printf("\tCurrent Interface type : %d, Timing "
|
||||
"mode is %d\r\n\n",
|
||||
NandInstPtr->DataInterface,
|
||||
NandInstPtr->TimingMode);
|
||||
}
|
||||
}
|
||||
else{
|
||||
printf("Invalid Input\n\r");
|
||||
}
|
||||
break;
|
||||
|
||||
case XNANDPSU_NVDDR:
|
||||
printf("Enter Timing Mode (0 - 5) : ");
|
||||
/* wait for input */
|
||||
*CmdLine = '\n';
|
||||
while(*CmdLine == '\n') {
|
||||
GetUserInput(0, CmdLine, 131);
|
||||
}
|
||||
if((u8)atoi(CmdLine) >= 0 && (u8)atoi(CmdLine) <= 5){
|
||||
Status = XNandPsu_ChangeTimingMode(NandInstPtr,
|
||||
XNANDPSU_NVDDR,atoi(CmdLine));
|
||||
if (Status != XST_SUCCESS) {
|
||||
printf("Data Interface / Timing Mode Change"
|
||||
" failed\r\n");
|
||||
}
|
||||
else{
|
||||
printf("\tCurrent Interface type : %d, Timing "
|
||||
"mode is %d\r\n\n",
|
||||
NandInstPtr->DataInterface,
|
||||
NandInstPtr->TimingMode - 16);
|
||||
}
|
||||
}
|
||||
else{
|
||||
printf("Invalid Input\n\r");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
printf("Invalid selection\r\n");
|
||||
}
|
||||
break;
|
||||
case MENU_UTIL_DMA_MODE:
|
||||
printf("0. Disable DMA Mode\r\n"
|
||||
"1. Enable DMA Mode\r\n");
|
||||
/* wait for input */
|
||||
*CmdLine = '\n';
|
||||
while(*CmdLine == '\n') {
|
||||
printf("Enter selection: ");
|
||||
GetUserInput(0, CmdLine, 131);
|
||||
}
|
||||
switch(atoi(CmdLine)) {
|
||||
case 0:
|
||||
XNandPsu_DisableDmaMode(NandInstPtr);
|
||||
printf("DMA Mode Disabled\r\n");
|
||||
break;
|
||||
case 1:
|
||||
XNandPsu_EnableDmaMode(NandInstPtr);
|
||||
printf("DMA Mode Enabled\r\n");
|
||||
break;
|
||||
default:
|
||||
printf("Invalid selection\r\n");
|
||||
}
|
||||
break;
|
||||
case MENU_UTIL_OOB_MODE:
|
||||
printf("0. Enable OOB Mode\r\n"
|
||||
"1. Disable OOB Mode\r\n");
|
||||
/* wait for input */
|
||||
*CmdLine = '\n';
|
||||
while(*CmdLine == '\n') {
|
||||
printf("Enter selection: ");
|
||||
GetUserInput(0, CmdLine, 131);
|
||||
}
|
||||
switch(atoi(CmdLine)) {
|
||||
case XNANDPSU_BBT_OOB:
|
||||
XNandPsu_EnableBbtOobMode(NandInstPtr);
|
||||
printf("OOB Mode selected..Scanning for BBT\r\n");
|
||||
Status = XNandPsu_ScanBbt(NandInstPtr);
|
||||
if(Status != XST_SUCCESS){
|
||||
printf("Scan BBT Failed\r\n");
|
||||
}
|
||||
break;
|
||||
case XNANDPSU_BBT_NO_OOB:
|
||||
XNandPsu_DisableBbtOobMode(NandInstPtr);
|
||||
printf("NO OOB Mode selected..Scanning for BBT\r\n");
|
||||
Status = XNandPsu_ScanBbt(NandInstPtr);
|
||||
if(Status != XST_SUCCESS){
|
||||
printf("Scan BBT Failed\r\n");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
printf("Invalid selection\r\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case MENU_UTIL_EXIT:
|
||||
QuitToMain = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Invalid selection\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function initialize the Nand flash.
|
||||
*
|
||||
* @param NandDeviceId is is the XPAR_<NAND_instance>_DEVICE_ID value
|
||||
* from xparameters.h.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if failed.
|
||||
*
|
||||
* @note
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
s32 FlashInit(u16 NandDeviceId){
|
||||
|
||||
s32 Status = XST_FAILURE;
|
||||
XNandPsu_Config *Config;
|
||||
|
||||
Config = XNandPsu_LookupConfig(NandDeviceId);
|
||||
if (Config == NULL) {
|
||||
Status = XST_FAILURE;
|
||||
goto Out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the flash driver.
|
||||
*/
|
||||
Status = XNandPsu_CfgInitialize(NandInstPtr, Config,
|
||||
Config->BaseAddress);
|
||||
if (Status != XST_SUCCESS) {
|
||||
goto Out;
|
||||
}
|
||||
|
||||
Out:
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Main entry function for the whole integration test.
|
||||
*
|
||||
* param None.
|
||||
*
|
||||
* @return 0
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
int main()
|
||||
{
|
||||
Intg_Entry();
|
||||
return 0;
|
||||
}
|
|
@ -1,172 +0,0 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* (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.h - defines integration test API for the nandpsu driver
|
||||
*
|
||||
* @note None
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------
|
||||
* 1.0 sb 11/28/14 First release.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef INTG_H /**< prevent circular inclusions */
|
||||
#define INTG_H /**< by using protection macros */
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "xparameters.h"
|
||||
#include "xnandpsu.h"
|
||||
#include "xscugic.h"
|
||||
#include "xstatus.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "ct.h"
|
||||
#include "xil_exception.h"
|
||||
#include "xil_testlib.h"
|
||||
#ifdef __aarch64__
|
||||
#include "xreg_cortexa53.h"
|
||||
#else
|
||||
#include "xreg_cortexr5.h"
|
||||
#endif
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
/**
|
||||
* Nand device and other important HW properties for this build
|
||||
* @{
|
||||
*/
|
||||
#define INTG_XPAR_INTC_DEVICE_ID XPAR_SCUGIC_SINGLE_DEVICE_ID
|
||||
#define INTG_XPAR_DEVICE_INTR_VEC XPAR_XNANDPSU_0_INTR
|
||||
#define printf xil_printf
|
||||
/*@}*/
|
||||
#define NAND_DEVICE_ID 0U
|
||||
#define TEST_BUF_SIZE 0x4000U
|
||||
#define TEST_PAGE_START 0x0U
|
||||
#define TEST_BLOCK_START 0x1U
|
||||
|
||||
/*
|
||||
* Buffers used during read and write transactions.
|
||||
*/
|
||||
extern u8 ReadBuffer[]; /**< read buffer */
|
||||
extern u8 WriteBuffer[]; /**< write buffer */
|
||||
|
||||
/**
|
||||
* Pele Regression tests
|
||||
*/
|
||||
#define AUTOMATIC_TEST_MODE
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
#define printf xil_printf
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
/**< Clear the Structure variable to zero */
|
||||
#define Intg_ClearStruct(s) (memset(&(s), 0, sizeof(s)))
|
||||
|
||||
/************************** Variable Definitions ****************************/
|
||||
|
||||
/**< XNandPs instance used throughout tests */
|
||||
extern XNandPsu* NandInstPtr;
|
||||
extern s32 MismatchCounter;
|
||||
/************************** Function Prototypes *****************************/
|
||||
|
||||
/*
|
||||
* Utility test functions implemented in intg.c
|
||||
*/
|
||||
void Intg_Entry(void);
|
||||
int Intg_ReinitializeInstance(void);
|
||||
int UART_RecvByte(u8 *Data);
|
||||
|
||||
/*
|
||||
* Flash Erase Read test implemented in intg_erase_read.c
|
||||
*/
|
||||
int Intg_EraseReadTest(XNandPsu * NandInstPtr, int TestLoops);
|
||||
|
||||
/*
|
||||
* Flash Read Write test implemented in intg_flash_rw.c
|
||||
*/
|
||||
int Intg_FlashRWTest(XNandPsu * NandInstPtr, int TestLoops);
|
||||
|
||||
/*
|
||||
* Random Block Read Write test implemented in intg_random_rw.c
|
||||
*/
|
||||
int Intg_RandomRWTest(XNandPsu * NandInstPtr, int TestLoops);
|
||||
|
||||
/*
|
||||
* SpareBytes Read Write test implemented in intg_sparebytes_rw.c
|
||||
*/
|
||||
int Intg_SpareBytesRWTest(XNandPsu * NandInstPtr,int TestLoops);
|
||||
|
||||
/*
|
||||
* Partial Page Read Write test implemented in intg_partialpage_rw.c
|
||||
*/
|
||||
int Intg_PartialRWTest(XNandPsu * NandInstPtr,int TestLoops);
|
||||
|
||||
/*
|
||||
* ECC error check tests implemented in intg_ecc_test.c
|
||||
*/
|
||||
int Intg_EccTest(XNandPsu * NandInstPtr,int TestLoops);
|
||||
|
||||
/*
|
||||
* BBT Scan test implemented in intg_bbt_test.c
|
||||
*/
|
||||
int Intg_BbtTest(XNandPsu * NandInstPtr, int TestLoops);
|
||||
|
||||
/*
|
||||
* Mark Block Bad test implemented in intg_markblockbad_test.c
|
||||
*/
|
||||
int Intg_MarkBlockBadTest(XNandPsu * NandInstPtr, int TestLoops);
|
||||
|
||||
/*
|
||||
* Code Coverage test implemented in intg_codecoverage_test.c
|
||||
*/
|
||||
int Intg_CodeCoverageTest(XNandPsu * NandInstPtr, int TestLoops);
|
||||
|
||||
#endif /**< End of protection macro */
|
|
@ -1,145 +0,0 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* (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 (XNandPsu).
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------
|
||||
* 1.0 sb 11/28/2014 First release
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "intg.h"
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
/************************** Variable Definitions ****************************/
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
s32 Bbt_Test(XNandPsu * 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(XNandPsu * 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.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @note
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
s32 Bbt_Test(XNandPsu * NandInstPtr)
|
||||
{
|
||||
s32 Status = XST_FAILURE;
|
||||
|
||||
/*
|
||||
* Enabling Ecc Mode
|
||||
*/
|
||||
XNandPsu_EnableEccMode(NandInstPtr);
|
||||
|
||||
/*
|
||||
* Scanning for Bbt
|
||||
*/
|
||||
Status = XNandPsu_ScanBbt(NandInstPtr);
|
||||
|
||||
return Status;
|
||||
}
|
|
@ -1,187 +0,0 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* (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 (XNandPsu).
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------
|
||||
* 1.0 sb 12/18/2014 First release
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** 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(XNandPsu *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(XNandPsu *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
|
||||
* -XNandPsu_WriteSpareBytes
|
||||
* -XNandPsu_LookupConfig
|
||||
*
|
||||
* @param NandInstPtr - Instance to the nand driver.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @note
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
s32 CodeCoverage_Test(XNandPsu *NandInstPtr)
|
||||
{
|
||||
s32 Status = XST_FAILURE;
|
||||
XNandPsu_Config *StatusPtr = NULL;
|
||||
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
|
||||
* XNandPsu_WriteSpareBytes API
|
||||
*/
|
||||
NandInstPtr->EccCfg.EccAddr -= 8U;
|
||||
|
||||
/*
|
||||
* Enabling DMA Mode
|
||||
*/
|
||||
XNandPsu_EnableDmaMode(NandInstPtr);
|
||||
/*
|
||||
* Write to flash Spare Bytes Section
|
||||
*/
|
||||
Status = XNandPsu_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
|
||||
*/
|
||||
StatusPtr = XNandPsu_LookupConfig(RANDOM_DEVICEID);
|
||||
if (StatusPtr == NULL){
|
||||
Failures++;
|
||||
}
|
||||
|
||||
if(Failures == EXPECTED_FAILURES){
|
||||
Status = XST_SUCCESS;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
|
@ -1,271 +0,0 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* (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_ecc_test.c
|
||||
*
|
||||
* This file contains the design example for using NAND driver (XNandPsu).
|
||||
* This example tests the erase, read and write feature of the controller
|
||||
* in the spare bytes region.The flash is erased and written. The data is
|
||||
* read back and compared with the data written for correctness.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------
|
||||
* 1.0 sb 11/28/2014 First release
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "intg.h"
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
/************************** Variable Definitions ****************************/
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
s32 Ecc_Test(XNandPsu * NandInstPtr);
|
||||
/************************** Function Definitions ****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Entry point to call the ECC 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_EccTest(XNandPsu * NandInstPtr, int TestLoops)
|
||||
{
|
||||
|
||||
s32 Status = XST_FAILURE;
|
||||
CT_TestReset("Module Ecc Error Check test");
|
||||
|
||||
while(TestLoops--) {
|
||||
Status = Ecc_Test(NandInstPtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
CT_LOG_FAILURE("Ecc Error Check 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:
|
||||
* - Erase the block.
|
||||
* - Write data to the page.
|
||||
* - Read back the data from the page.
|
||||
* - Compare the data read against the data Written.
|
||||
* - Corrupt data by writing random data to page
|
||||
* - Read back the data from the page.
|
||||
* - Compare the data read against the data Written before corruption.
|
||||
*
|
||||
* @param NandInstPtr - Instance to the nand driver.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if failed.
|
||||
*
|
||||
* @note
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
s32 Ecc_Test(XNandPsu * NandInstPtr)
|
||||
{
|
||||
s32 Status = XST_FAILURE;
|
||||
u32 Index;
|
||||
u64 Offset;
|
||||
u32 SpareOffset,ReadSpareOffset,WriteSpareOffset;
|
||||
u32 Length;
|
||||
s32 i,j;
|
||||
MismatchCounter = 0;
|
||||
u8 SpareBuffer[TEST_BUF_SIZE];
|
||||
u32 BlockSize = NandInstPtr->Geometry.BlockSize;
|
||||
NandInstPtr->Ecc_Stats_total_flips = 0;
|
||||
|
||||
Offset = (u64)(TEST_PAGE_START * NandInstPtr->Geometry.BytesPerPage);
|
||||
/*
|
||||
* Offset to write in spare area
|
||||
*/
|
||||
SpareOffset = TEST_PAGE_START;
|
||||
|
||||
Length = NandInstPtr->Geometry.BytesPerPage;
|
||||
|
||||
/*
|
||||
* Initialize the write buffer
|
||||
*/
|
||||
for (Index = 0; Index < Length;Index++) {
|
||||
WriteBuffer[Index] = (u8)0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Erase the Block
|
||||
*/
|
||||
Status = XNandPsu_Erase(NandInstPtr, (u64)Offset, (u64)BlockSize);
|
||||
if (Status != XST_SUCCESS) {
|
||||
goto Out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable ECC
|
||||
*/
|
||||
XNandPsu_EnableEccMode(NandInstPtr);
|
||||
|
||||
/*
|
||||
* Write first 30 pages of the block.
|
||||
*/
|
||||
for(i = 0 ; i < 24 ; i++){
|
||||
/*
|
||||
* Write to flash
|
||||
*/
|
||||
Status = XNandPsu_Write(NandInstPtr, (u64)Offset, (u64)Length,
|
||||
&WriteBuffer[0]);
|
||||
if (Status != XST_SUCCESS) {
|
||||
goto Out;
|
||||
}
|
||||
|
||||
Offset = Offset + NandInstPtr->Geometry.BytesPerPage;
|
||||
}
|
||||
|
||||
ReadSpareOffset = SpareOffset;
|
||||
WriteSpareOffset = Offset/(NandInstPtr->Geometry.BytesPerPage);
|
||||
|
||||
for(i = 0 ; i < 24 ; i++){
|
||||
/*
|
||||
* Read the Spare Area
|
||||
*/
|
||||
Status = XNandPsu_ReadSpareBytes(NandInstPtr, ReadSpareOffset,
|
||||
&SpareBuffer[0]);
|
||||
if (Status != XST_SUCCESS) {
|
||||
goto Out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Disable the ecc mode
|
||||
*/
|
||||
XNandPsu_DisableEccMode(NandInstPtr);
|
||||
|
||||
|
||||
/*
|
||||
* Corrupting the data in write buffer.
|
||||
*/
|
||||
for(j = 0; j<= i ; j++){
|
||||
WriteBuffer[j] = (u8)1;
|
||||
}
|
||||
|
||||
Status = XNandPsu_Write(NandInstPtr, Offset, Length, &WriteBuffer[0]);
|
||||
if(Status != XST_SUCCESS){
|
||||
goto Out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the Ecc Data into the spare area of next page.
|
||||
*/
|
||||
Status = XNandPsu_WriteSpareBytes(NandInstPtr, WriteSpareOffset,
|
||||
&SpareBuffer[0]);
|
||||
if (Status != XST_SUCCESS) {
|
||||
goto Out;
|
||||
}
|
||||
|
||||
for(j = 0; j<= i ; j++){
|
||||
WriteBuffer[j] = (u8)0;
|
||||
}
|
||||
/*
|
||||
* Enable Ecc Mode
|
||||
*/
|
||||
XNandPsu_EnableEccMode(NandInstPtr);
|
||||
|
||||
/*
|
||||
* Read the page after writing
|
||||
*/
|
||||
Status = XNandPsu_Read(NandInstPtr, Offset, 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;
|
||||
}
|
||||
|
||||
}
|
||||
ReadSpareOffset++;
|
||||
WriteSpareOffset++;
|
||||
Offset = Offset + NandInstPtr->Geometry.BytesPerPage;
|
||||
}
|
||||
xil_printf("Total Ecc Error Flips = %d\r\n",
|
||||
NandInstPtr->Ecc_Stats_total_flips);
|
||||
Out:
|
||||
return Status;
|
||||
}
|
|
@ -1,190 +0,0 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* (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_erase_read.c
|
||||
*
|
||||
* This file contains the design example for using NAND driver (XNandPsu).
|
||||
* This example tests the erase and read feature of the controller.
|
||||
* The flash is erased. The data is
|
||||
* read back and compared with the 0xFF for correctness.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------
|
||||
* 1.0 sb 11/28/2014 First release
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "intg.h"
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
/************************** Variable Definitions ****************************/
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
s32 Erase_Read_Test(XNandPsu * NandInstPtr);
|
||||
/************************** Function Definitions ****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Entry point to call the Erase Read test.
|
||||
*
|
||||
* @param NandInstPtr - Instance to the nand driver.
|
||||
* @param TestLoops - Number of tests to execute.
|
||||
*
|
||||
* @return Number of test failures.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
int Intg_EraseReadTest(XNandPsu * NandInstPtr, int TestLoops)
|
||||
{
|
||||
|
||||
s32 Status = XST_FAILURE;
|
||||
CT_TestReset("Module FLASH Erase Read test");
|
||||
|
||||
while(TestLoops--) {
|
||||
Status = Erase_Read_Test(NandInstPtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
CT_LOG_FAILURE("Nand Flash Erase ReadTest 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:
|
||||
* - Erase the block.
|
||||
* - Read back the data from the block.
|
||||
* - Compare the data read against 0xFF.
|
||||
*
|
||||
* @param NandInstPtr - Instance to the nand driver.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if failed.
|
||||
*
|
||||
* @note
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
s32 Erase_Read_Test(XNandPsu * NandInstPtr)
|
||||
{
|
||||
s32 Status = XST_FAILURE;
|
||||
s32 i = 0;
|
||||
u32 Index;
|
||||
u64 Offset;
|
||||
u32 Length;
|
||||
u32 BlockSize = NandInstPtr->Geometry.BlockSize;
|
||||
MismatchCounter = 0;
|
||||
|
||||
Offset = (u64)TEST_BLOCK_START * NandInstPtr->Geometry.BlockSize;
|
||||
Length = NandInstPtr->Geometry.BytesPerPage;
|
||||
|
||||
/*
|
||||
* Erasing whole block
|
||||
*/
|
||||
Status = XNandPsu_Erase(NandInstPtr, (u64)Offset, (u64)BlockSize);
|
||||
if (Status != XST_SUCCESS) {
|
||||
goto Out;
|
||||
}
|
||||
|
||||
for (i = 0; i < NandInstPtr->Geometry.PagesPerBlock; i++){
|
||||
/*
|
||||
* Disbale ECC
|
||||
*/
|
||||
XNandPsu_DisableEccMode(NandInstPtr);
|
||||
|
||||
/*
|
||||
* Read the block.
|
||||
*/
|
||||
Status = XNandPsu_Read(NandInstPtr, (u64)Offset, (u64)Length,
|
||||
&ReadBuffer[0]);
|
||||
if (Status != XST_SUCCESS) {
|
||||
goto Out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable ECC
|
||||
*/
|
||||
XNandPsu_EnableEccMode(NandInstPtr);
|
||||
|
||||
/*
|
||||
* Compare the results
|
||||
*/
|
||||
for (Index = 0U; Index < Length;Index++) {
|
||||
if (ReadBuffer[Index] != (u8)0xFF) {
|
||||
MismatchCounter++;
|
||||
Status = XST_FAILURE;
|
||||
}
|
||||
}
|
||||
Offset = Offset + NandInstPtr->Geometry.BytesPerPage;
|
||||
}
|
||||
|
||||
Out:
|
||||
return Status;
|
||||
}
|
|
@ -1,193 +0,0 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* (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_flash_rw.c
|
||||
*
|
||||
* This file contains the design example for using NAND driver (XNandPsu).
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------
|
||||
* 1.0 sb 11/28/2014 First release
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "intg.h"
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
/************************** Variable Definitions ****************************/
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
s32 Flash_RW_Test(XNandPsu * NandInstPtr);
|
||||
/************************** Function Definitions ****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Entry point to call the Flash 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_FlashRWTest(XNandPsu * NandInstPtr, int TestLoops)
|
||||
{
|
||||
|
||||
s32 Status = XST_FAILURE;
|
||||
CT_TestReset("Module FLASH Read Write test");
|
||||
|
||||
while(TestLoops--) {
|
||||
Status = Flash_RW_Test(NandInstPtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
CT_LOG_FAILURE("Nand Flash Read Write 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:
|
||||
* - Initialize the driver.
|
||||
* - Erase the block.
|
||||
* - Write data to the page.
|
||||
* - Read back the data from the page.
|
||||
* - 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 Flash_RW_Test(XNandPsu * NandInstPtr)
|
||||
{
|
||||
s32 Status = XST_FAILURE;
|
||||
u32 Index;
|
||||
u64 Offset;
|
||||
u32 Length;
|
||||
MismatchCounter = 0;
|
||||
|
||||
Offset = (u64)(TEST_PAGE_START * NandInstPtr->Geometry.BytesPerPage);
|
||||
Length = NandInstPtr->Geometry.BytesPerPage;
|
||||
|
||||
/*
|
||||
* Initialize the write buffer
|
||||
*/
|
||||
for (Index = 0; Index < Length;Index++) {
|
||||
WriteBuffer[Index] = (u8) (rand() % 256);
|
||||
}
|
||||
/*
|
||||
* Erase the Block
|
||||
*/
|
||||
Status = XNandPsu_Erase(NandInstPtr, (u64)Offset, (u64)Length);
|
||||
if (Status != XST_SUCCESS) {
|
||||
goto Out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write to page offset
|
||||
*/
|
||||
Status = XNandPsu_Write(NandInstPtr, (u64)Offset, (u64)Length,
|
||||
&WriteBuffer[0]);
|
||||
if (Status != XST_SUCCESS) {
|
||||
goto Out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read from the page after writing
|
||||
*/
|
||||
Status = XNandPsu_Read(NandInstPtr, (u64)Offset, (u64)Length,
|
||||
&ReadBuffer[0]);
|
||||
if (Status != XST_SUCCESS) {
|
||||
goto Out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare the results
|
||||
*/
|
||||
for (Index = 0U; Index < 10;Index++) {
|
||||
if (ReadBuffer[Index] != WriteBuffer[Index]) {
|
||||
MismatchCounter++;
|
||||
Status = XST_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
Out:
|
||||
return Status;
|
||||
}
|
|
@ -1,221 +0,0 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* (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_flash_rw.c
|
||||
*
|
||||
* This file contains the design example for using NAND driver (XNandPsu).
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------
|
||||
* 1.0 sb 12/18/2014 First release
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "intg.h"
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
/************************** Variable Definitions ****************************/
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
s32 Mark_BlockBad_Test(XNandPsu * 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(XNandPsu * 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(XNandPsu * 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 = XNandPsu_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;
|
||||
|
||||
/*
|
||||
* Erase the Block 1,2,3
|
||||
*/
|
||||
Status = XNandPsu_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 = XNandPsu_Write(NandInstPtr, (u64)PageOff, (u64)Length,
|
||||
&WriteBuffer[0]);
|
||||
if (Status != XST_SUCCESS) {
|
||||
goto Out;
|
||||
}
|
||||
/*
|
||||
* Read from the page after writing
|
||||
*/
|
||||
Status = XNandPsu_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;
|
||||
}
|
|
@ -1,208 +0,0 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* (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_partialpage_rw.c
|
||||
*
|
||||
* This file contains the design example for using NAND driver (XNandPsu).
|
||||
* This example tests the erase, read and write feature of the controller
|
||||
* to the page.The flash is erased and written. The data is
|
||||
* read back and compared with the data written for correctness.
|
||||
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------
|
||||
* 1.0 sb 11/28/2014 First release
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "intg.h"
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
/************************** Variable Definitions ****************************/
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
s32 PartialPage_RW_Test(XNandPsu * NandInstPtr);
|
||||
/************************** Function Definitions ****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Entry point to call the Partial Page 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_PartialRWTest(XNandPsu * NandInstPtr, int TestLoops)
|
||||
{
|
||||
|
||||
s32 Status = XST_FAILURE;
|
||||
CT_TestReset("Module Partial Page Read Write test");
|
||||
|
||||
while(TestLoops--) {
|
||||
Status = PartialPage_RW_Test(NandInstPtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
CT_LOG_FAILURE("Nand Partial Page Read Write 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:
|
||||
* - Choose random page size for read write Operations.
|
||||
* - Erase the block.
|
||||
* - Write data to the page.
|
||||
* - Read back the data from the page.
|
||||
* - 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 PartialPage_RW_Test(XNandPsu * NandInstPtr)
|
||||
{
|
||||
s32 Status = (s32)XST_FAILURE;
|
||||
u32 Index;
|
||||
u64 Offset;
|
||||
u32 Length;
|
||||
s32 i;
|
||||
MismatchCounter = 0;
|
||||
Offset = (u64)(TEST_PAGE_START * (u64)NandInstPtr->Geometry.BytesPerPage);
|
||||
Length = NandInstPtr->Geometry.BytesPerPage;
|
||||
|
||||
/*
|
||||
* Repeat the test for 5 iterations
|
||||
*/
|
||||
for(i = 0; i< 5; i++){
|
||||
|
||||
/*
|
||||
* Select Random Length of data to be written to the page.
|
||||
*/
|
||||
Length = rand()%NandInstPtr->Geometry.BytesPerPage;
|
||||
if(Length == 0U){
|
||||
Length = NandInstPtr->Geometry.BytesPerPage;
|
||||
}
|
||||
|
||||
/*
|
||||
* Erase the Block
|
||||
*/
|
||||
Status = XNandPsu_Erase(NandInstPtr, (u64)Offset, (u64)Length);
|
||||
if (Status != (s32)XST_SUCCESS) {
|
||||
goto Out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the write buffer
|
||||
*/
|
||||
for (Index = 0U; Index < Length;Index++) {
|
||||
WriteBuffer[Index] = ((u8)rand() % 256);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write to page
|
||||
*/
|
||||
Status = XNandPsu_Write(NandInstPtr, (u64)Offset, (u64)Length,
|
||||
&WriteBuffer[0]);
|
||||
if (Status != (s32)XST_SUCCESS) {
|
||||
goto Out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the page after writing
|
||||
*/
|
||||
Status = XNandPsu_Read(NandInstPtr, (u64)Offset, (u64)Length,
|
||||
&ReadBuffer[0]);
|
||||
if (Status != (s32)XST_SUCCESS) {
|
||||
goto Out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare the results
|
||||
*/
|
||||
for (Index = 0U; Index < Length;Index++) {
|
||||
if (ReadBuffer[Index] != WriteBuffer[Index]) {
|
||||
MismatchCounter++;
|
||||
Status = (s32)XST_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Out:
|
||||
return Status;
|
||||
}
|
|
@ -1,206 +0,0 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* (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_random_rw.c
|
||||
*
|
||||
* This file contains the design example for using NAND driver (XNandPsu).
|
||||
* This example tests the erase, read and write feature of the controller
|
||||
* to a complete block. The block is randomly selected.
|
||||
* The flash is erased and written. The data is read back and compared
|
||||
* with the data written for correctness.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------
|
||||
* 1.0 sb 11/28/2014 First release
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "intg.h"
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
/************************** Variable Definitions ****************************/
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
s32 Random_Block_RW_Test(XNandPsu * NandInstPtr);
|
||||
/************************** Function Definitions ****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Entry point to call the Random Block Read Write test.
|
||||
*
|
||||
* @param NandInstPtr - Instance to the nand driver.
|
||||
* @param TestLoops - Number of tests to execute.
|
||||
*
|
||||
* @return Number of test failures.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
int Intg_RandomRWTest(XNandPsu * NandInstPtr, int TestLoops)
|
||||
{
|
||||
|
||||
s32 Status = XST_FAILURE;
|
||||
CT_TestReset("Module Random Block Read Write test");
|
||||
|
||||
while(TestLoops--) {
|
||||
Status = Random_Block_RW_Test(NandInstPtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
CT_LOG_FAILURE("Nand Random Block Read Write 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:
|
||||
* - Initialize the driver.
|
||||
* - Erase the block.
|
||||
* - Write data to the pages of block.
|
||||
* - Read back the data from the pages of block.
|
||||
* - 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 Random_Block_RW_Test(XNandPsu * NandInstPtr)
|
||||
{
|
||||
s32 Status = XST_FAILURE;
|
||||
u32 Index;
|
||||
u64 Offset;
|
||||
u32 Length;
|
||||
s32 i = 0;
|
||||
u32 BlockSize = NandInstPtr->Geometry.BlockSize;
|
||||
|
||||
Offset = (u64) ((rand()% 50) *
|
||||
NandInstPtr->Geometry.BlockSize);
|
||||
|
||||
Length = NandInstPtr->Geometry.BytesPerPage;
|
||||
|
||||
/*
|
||||
* Erase the Block
|
||||
*/
|
||||
Status = XNandPsu_Erase(NandInstPtr, (u64)Offset, (u64)BlockSize);
|
||||
if (Status != XST_SUCCESS) {
|
||||
goto Out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Flash operation i.e. write and read for all the pages
|
||||
* of the block.
|
||||
* This test will take some time to execute. Please be patient.
|
||||
*/
|
||||
for (i = 0; i < NandInstPtr->Geometry.PagesPerBlock; i++){
|
||||
|
||||
/*
|
||||
* Initialize the write buffer
|
||||
*/
|
||||
for (Index = 0; Index < Length;Index++) {
|
||||
WriteBuffer[Index] = (u8) (rand() % 256);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write to page
|
||||
*/
|
||||
Status = XNandPsu_Write(NandInstPtr, (u64)Offset, (u64)Length,
|
||||
&WriteBuffer[0]);
|
||||
if (Status != XST_SUCCESS) {
|
||||
goto Out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the page after writing
|
||||
*/
|
||||
Status = XNandPsu_Read(NandInstPtr, (u64)Offset, (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;
|
||||
}
|
||||
}
|
||||
Offset = Offset + NandInstPtr->Geometry.BytesPerPage;
|
||||
}
|
||||
|
||||
Out:
|
||||
return Status;
|
||||
}
|
|
@ -1,221 +0,0 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* (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_sparebytes_rw.c
|
||||
*
|
||||
* This file contains the design example for using NAND driver (XNandPsu).
|
||||
* This example tests the erase, read and write feature of the controller
|
||||
* in the spare bytes region.The flash is erased and written. The data is
|
||||
* read back and compared with the data written for correctness.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ----- -------- -----------------------------------------------
|
||||
* 1.0 sb 11/28/2014 First release
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "intg.h"
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
/************************** Variable Definitions ****************************/
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
s32 SpareBytes_RW_Test(XNandPsu * NandInstPtr);
|
||||
/************************** Function Definitions ****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Entry point to call the Spare Bytes test.
|
||||
*
|
||||
* @param NandInstPtr - Instance to the nand driver.
|
||||
* @param TestLoops - Number of tests to execute.
|
||||
*
|
||||
* @return Number of test failures.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
int Intg_SpareBytesRWTest(XNandPsu * NandInstPtr, int TestLoops)
|
||||
{
|
||||
|
||||
s32 Status = XST_FAILURE;
|
||||
CT_TestReset("Module Spare Bytes Read Write test");
|
||||
|
||||
while(TestLoops--) {
|
||||
Status = SpareBytes_RW_Test(NandInstPtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
CT_LOG_FAILURE("Nand Spare Bytes Read Write 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:
|
||||
* - Erase the Block.
|
||||
* - Write data to the spare byte section of page.
|
||||
* - Read back the data from the spare byte section of page.
|
||||
* - 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 SpareBytes_RW_Test(XNandPsu * NandInstPtr)
|
||||
{
|
||||
s32 Status = XST_FAILURE;
|
||||
u32 Index;
|
||||
u64 Offset;
|
||||
u32 SpareOffset;
|
||||
u16 Length;
|
||||
s32 i;
|
||||
MismatchCounter = 0;
|
||||
|
||||
Offset = (u64)(TEST_PAGE_START * NandInstPtr->Geometry.BytesPerPage);
|
||||
Length = NandInstPtr->Geometry.BytesPerPage;
|
||||
|
||||
/*
|
||||
* Offset to write in spare area
|
||||
*/
|
||||
SpareOffset = TEST_PAGE_START;
|
||||
|
||||
/*
|
||||
* Repeat the test for 5 iterations
|
||||
*/
|
||||
for(i = 0; i< 5; i++){
|
||||
|
||||
/*
|
||||
* Erase the Block
|
||||
*/
|
||||
Status = XNandPsu_Erase(NandInstPtr, (u64)Offset, (u64)Length);
|
||||
if (Status != XST_SUCCESS) {
|
||||
goto Out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Select Random Length of data to be written in Spare Region.
|
||||
*/
|
||||
Length = rand() % (NandInstPtr->Geometry.SpareBytesPerPage);
|
||||
if(Length == 0U){
|
||||
Length = (NandInstPtr->Geometry.SpareBytesPerPage);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the write buffer
|
||||
*/
|
||||
for (Index = 0; Index < Length;Index++) {
|
||||
WriteBuffer[Index] = (u8) (rand() % 256);
|
||||
}
|
||||
|
||||
/*
|
||||
* Disable the ECC mode
|
||||
*/
|
||||
XNandPsu_DisableEccMode(NandInstPtr);
|
||||
|
||||
/*
|
||||
* Write to Spare Bytes Section of page.
|
||||
*/
|
||||
Status = XNandPsu_WriteSpareBytes(NandInstPtr, SpareOffset,
|
||||
&WriteBuffer[0]);
|
||||
if (Status != XST_SUCCESS) {
|
||||
goto Out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read from the Spare Bytes after writing
|
||||
*/
|
||||
Status = XNandPsu_ReadSpareBytes(NandInstPtr, SpareOffset,
|
||||
&ReadBuffer[0]);
|
||||
if (Status != XST_SUCCESS) {
|
||||
goto Out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable the ECC mode
|
||||
*/
|
||||
XNandPsu_EnableEccMode(NandInstPtr);
|
||||
/*
|
||||
* Compare the results
|
||||
*/
|
||||
for (Index = 0U; Index < Length;Index++) {
|
||||
if (ReadBuffer[Index] != WriteBuffer[Index]) {
|
||||
MismatchCounter++;
|
||||
Status = XST_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Out:
|
||||
return Status;
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
/* $Id: xil_testlib.h,v 1.00 2009/2/19 */
|
||||
/******************************************************************************
|
||||
*
|
||||
* (c) Copyright 2010-13 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
#include <xil_printf.h>
|
||||
#include "intg.h"
|
||||
|
||||
/**
|
||||
*
|
||||
* @file xil_testlib.h
|
||||
*
|
||||
* This file contains Xilinx software exit messages.These messages are set to be
|
||||
* matched with the scan strings for board test such that board test would know
|
||||
* the result of a standalone test program
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef XIL_TESTLIB_H /**< prevent circular inclusions */
|
||||
#define XIL_TESTLIB_H /**< by using protection macros */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
/**
|
||||
* XIL_PASS puts out a message to signal board test that a program has pass
|
||||
* the testing program without errors
|
||||
*
|
||||
* param None.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*/
|
||||
#define XIL_PASS() xil_printf("\r\nREGRESSION TEST PASS.\r\n")
|
||||
|
||||
/*
|
||||
* XIL_FAIL puts out a message to signal board test that a program has not pass
|
||||
* the testing program
|
||||
*
|
||||
* @param number of errors.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*/
|
||||
#define XIL_FAIL(numErrors) \
|
||||
xil_printf("\r\nREGRESSION TEST FAIL WITH %d ERRORS.\r\n", numErrors)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /**< End of protection macro */
|
Loading…
Add table
Reference in a new issue