You are here

How to use the NAND Flash Page Reader? – KBA89950 | Cypress Semiconductor

Support & Community

How to use the NAND Flash Page Reader? – KBA89950

Last Updated: October 03, 2016

How to use the NAND Flash Page Reader?


NAND flash page reader is a host application that is developed in VC# to demonstrate reading and writing to the pages of a NAND Flash interfaced to an NX2LP/NX2LP-Flex device. NAND flash page reader is there in the attachment to this KB article. 

System Requirements


  • MS VC# 2008 Express/Full Edition.
  • NX2LP.dll included in the “Libraries” folder in the attachment.
  • CyUSB.dll included in “Libraries” folder in the attachment.


The firmware to configure NX2LP-Flex is included in CY3686 DVK.


The NX2LP-Flex Reference Design Kit (CY3686) was used as the development and testing platforms for this example. A detailed schematic of the DVK is provided in the “Hardware” folder in the attachment.

OS Platforms

The associated project has been tested in Windows XP, Vista and windows 7. In Windows 7, we have seen the utility showing unexpected behavior like, returning incorrect page size of data. This is due to the access rights issues related to windows 7 driver. If this occurs, launch the utility from “Project\NandPageReader\bin\Release” and right click on the exe and select the 'Run as administrator' option. 


The NAND Flash Page Reader is created in Microsoft Visual C# 2008 using NX2LP.dll that presents a set of methods to communicate with an NX2LP/NX2LP-Flex based mass storage device bound either to the CyUSB.sys driver or to the mass storage class driver usbstor.sys. The NX2Device class of NX2LP.dll contains a number of functions such as CbwIn(), CbwOut(), GetNandCapacity(), LookUpNandParams(), SendCbwCommand(), and so on that communicate with the NX2LP device to obtain and write data or configuration information. To read and write data from the NAND Flash, Page Reader uses the following functions: 

  • Public bool CbwIn(byte cmd, byte op, byte lun, int bank, int lba, int bytes, byte[] data) 
  • Public bool CbwOut(byte cmd, byte op, byte lun, int bank, int lba, int bytes, byte[] data)

Sending a CBW (Command Block Wrapper) packet to the NX2LP device with the first byte of the CBW Command Block as 0xC8 implies that the opcode that follows it belongs to a set of NX2LP Manufacturing and Support vendor commands, implemented in CY3686 firmware. These commands include those to read and write NAND pages, to erase blocks, to read Flash ID, to read and write 8051 memory, and so on. The implementation of these commands is provided in the file vend_cbw.c (inside handleVendorCBW() function) included in the CY3686 firmware. 

Block Diagram


Read and Write Test (CY3686 Development Board is used for the test)

  • Follow the procedure detailed in CY3686 EZ-USB NX2LP-Flex Development Kit Guide in order to configure your NX2LP-based USB device as a mass storage device, which can be found in the “Documentation” folder in the install directory after installing CY3686 DVK. 
  • Make sure that your mass storage device appears in the Device Manager and a Removable Drive in "My Computer‟. Try to copy a file to the device. After disconnecting and reconnecting the device, check for data corruption. 
  • Open the Page Reader Utility.
  • Enter the VID/PID of the mass storage device in the utility and press the "VERIFY‟ button. When the VERIFY button is pressed, the application searches for a device bound to either the mass storage device class driver or the CyUSB.sys driver with the VID/PID entered by the user. If no such device found, status will be displayed as “No Mass Storage device found with VID/PID vvvv pppp”. ​
  • If the device is found, the status will be displayed as "VERIFIED‟. After the status bar displays the information "VERIFIED‟, fill in the required Bank number in the field "BANK‟ and the actual Physical address in the field "PAGE‟. ​
  • Asserting the Read button causes the utility to issue a CBW command to the Mass Storage Device to read from the user specified page. Data and spare area for the page are displayed.​
  • Asserting the Write button causes the utility to write the data specified by the user into the NAND page. If the length of the data entered by the user does not equal the page size, then the data is padded with zeroes to make its length equivalent to the page size. ​

Note: Make sure not to overwrite the firmware and the bad block information as this would lead to malfunctioning of the device.


This article demonstrates a basic utility to read NAND Flash Pages from an NX2LP/NX2LP-Flex based mass storage device, by specifying the physical addresses.

File TitleLanguageFile SizeLast Updated
Download NAND Flash Page Reader Project.zipEnglish461.91 KB10/03/16

Provide feedback on this article

Browse KB By Product

Browse KB by Type