| nandps Vitis Drivers API Documentation

- Overview
- Data Structures
- APIs
- File List
- Examples

Macros | Functions | Variables
xnandps_cache_example.c File Reference

## Overview

This file contains a design example using the NAND driver (XNandPs).

This example tests NAND page cache read and write commands. The page cache commands are not supported by OnDie ECC flash since ECC is enabled by default. Tested Spansion S34ML04G100TFI00 flash with this example.

This example tests the block erase, block read and block write features. The flash blocks are erased and written. The data is read back and compared with the data written for correctness. The bad blocks are not erased/programmed.

Note

None.

     MODIFICATION HISTORY:

     Ver   Who  Date        Changes

     1.00  nm   04/25/2013  First release.
           ms   04/10/17    Modified Comment lines to follow doxygen rules
     2.8  akm   07/06/23    Add support for system device-tree flow.

## Macros
#define | NAND_TEST_START_BLOCK 64
| Starting block to test. More...
#define | NAND_TEST_NUM_BLOCKS 16
| Number of blocks to test. More...
#define | NAND_TEST_BLOCK_SIZE 0x20000
| Test Block Size, must be same as the flash block size. More...

## Functions
int | NandReadWriteCacheExample (u32 NandDeviceId)
| This function runs a test on the NAND flash device using the basic driver functions. More...
int | main (void)
| Main function to execute the Nand Flash read write example. More...

## Variables
u8 | ReadBuffer [NAND_TEST_BLOCK_SIZE]
| Block sized Read buffer. More...
u8 | WriteBuffer [NAND_TEST_BLOCK_SIZE]
| Block sized write buffer. More...

## Macro Definition Documentation

#define NAND_TEST_BLOCK_SIZE 0x20000

Test Block Size, must be same as the flash block size.

Referenced by NandReadWriteCacheExample().

#define NAND_TEST_NUM_BLOCKS 16

Number of blocks to test.

Referenced by NandReadWriteCacheExample().

#define NAND_TEST_START_BLOCK 64

Starting block to test.

Referenced by NandReadWriteCacheExample().

## Function Documentation

int main | ( | void |  | ) |

Main function to execute the Nand Flash read write example.

Returns
  - XST_SUCCESS if the example has completed successfully.
  - XST_FAILURE if the example has failed.

Note
  None.

References NandReadWriteCacheExample().

int NandReadWriteCacheExample | ( | u32 | NandDeviceId | ) |

This function runs a test on the NAND flash device using the basic driver functions.

The function does the following tasks:

- Initialize the driver.
- Erase the blocks.
- Write in to all the blocks.
- Read back the data from the blocks.
- Compare the data read against the data Written.

Parameters

  NandDeviceId | is is the XPAR_<NAND_instance>_DEVICE_ID value from xparameters.h.

Returns
  - XST_SUCCESS if successful.
  - XST_FAILURE if failed.

Note
  When bad blocks are encountered, they are not erased and programmed.

References XNandPs_Geometry::BlockSize, XNandPs_Config::FlashBase, XNandPsTag::Geometry, NAND_TEST_BLOCK_SIZE, NAND_TEST_NUM_BLOCKS, NAND_TEST_START_BLOCK, ReadBuffer, XNandPs_Config::SmcBase, WriteBuffer, XNandPs_CfgInitialize(), XNandPs_EraseBlock(), XNandPs_IsBlockBad(), XNandPs_LookupConfig(), XNandPs_ReadCache(), and XNandPs_WriteCache().

Referenced by main().

## Variable Documentation

u8 ReadBuffer[NAND_TEST_BLOCK_SIZE]

Block sized Read buffer.

Referenced by NandReadWriteCacheExample(), NandReadWriteExample(), and NandSkipBlockExample().

u8 WriteBuffer[NAND_TEST_BLOCK_SIZE]

Block sized write buffer.

Referenced by NandReadWriteCacheExample(), NandReadWriteExample(), and NandSkipBlockExample().