nand.c File Reference

ONFI 1.0 compliant NAND kblock driver. More...

#include "nand.h"
#include <cfg/log.h>
#include <struct/heap.h>
#include <string.h>

Go to the source code of this file.

Functions

int nand_blockErase (Nand *chip, uint16_t block)
 Erase the whole block.
bool nand_getDevId (Nand *chip, uint8_t dev_id[5])
 Read Device ID and configuration codes.
void nand_format (Nand *chip)
 Reset bad blocks map and erase all blocks.
bool nand_init (Nand *chip, struct Heap *heap, unsigned chip_select)
 Initialize NAND kblock driver in buffered mode.
bool nand_initUnbuffered (Nand *chip, struct Heap *heap, unsigned chip_select)
 Initialize NAND kblock driver in unbuffered mode.

Detailed Description

ONFI 1.0 compliant NAND kblock driver.

Defective blocks are remapped in a reserved area of configurable size at the bottom of the NAND. At the moment there is no wear-leveling block translation: kblock's blocks are mapped directly on NAND erase blocks: when a (k)block is written the corresponding erase block is erased and all pages within are rewritten. Partial write is not possible: it's recommended to use buffered mode.

The driver needs to format the NAND before use. If the initialization code detects a fresh memory it does a bad block scan and a formatting. Format info isn't stored in NAND in a global structure: each block has its info written in the spare area of its first page. These info contais a tag to detect formatted blocks and an index for bad block remapping (struct RemapInfo).

The ECC for each page is written in the spare area too.

Works only in 8 bit data mode and NAND parameters are not detected at run-time, but hand-configured in cfg_nand.h.

Heap is needed to allocate the tipically large buffer necessary to erase and write a block.

Author:
Stefano Fedrigo <aleph@develer.com>

Definition in file nand.c.


Function Documentation

void nand_format ( Nand chip)

Reset bad blocks map and erase all blocks.

Note:
DON'T USE on production chips: this function will try to erase factory marked bad blocks too.

Definition at line 511 of file nand.c.