How do I recognize and mark bad blocks in Cypress NAND devices?
Bad Block Management is an important topic regarding NAND devices. All Cypress NAND datasheets contain a section to cover this topic – look for ”Valid Blocks” or “Error Management” or “Bad Block Replacement” or “Bad Block Management”. The datasheet defines the locations of the bad block markers and specifies how you should manage 'System' bad blocks – these are bad blocks that may appear after the flash device is used.
Cypress SLC NAND products may contain factory bad blocks when shipped. Any block where the 1st byte in the spare area of the 1st or 2nd or last page does not contain the value FFh is a bad block. You should check all three of these locations. If all of them contain FFh, the block is good. The following diagram from the datasheet shows how factory bad blocks are detected during the initial scan of the flash:
Figure 9.2 Bad Block Management Flowchart
Typically for the latest Cypress NAND devices, all factory bad blocks are pre-programmed to all 00h so there is no ambiguity over this. Moreover, if you attempt to erase a factory bad block the erase command will complete with a 'fail' status.
Over the life time of the device, additional bad blocks may develop – i.e., system bad blocks. If program or erase operations complete with a 'fail' status, or if a read operation returns uncorrectable bit errors (i.e., more than the minimum required ECC power can correct), you should mark the block as bad. It is the your responsibility to mark or record any system bad blocks. It is recommended to program the spare area of the 1st, 2nd , and last page to all 00h so that the block can be recognized as bad in the future.
For system bad blocks, it is important not to erase them if you are using the factory bad block marking scheme. If you are not using the factory bad block marking scheme, then you should ensure that your bad block tracking table is not erased because you may not be able to reconstruct it.