erase_block()

PROTOTYPE

#include <bfs.h>

int erase_block(ui32 page, void *dev);

DESCRIPTION

erase_block() erases the block of NAND flash that has page as its first page number. It should not return until erasure is finished. It can poll the flash device’s “ready” bit or, if the system supports this, block until an interrupt from the flash device signals that the operation is finished.

A block is the minimal unit of flash memory that can be erased and usually contains 32 pages or more.

dev is a driver-supplied data pointer. The value passed to TargetBFS by the bfsAddNandVol() call is passed back as the last parameter of each driver callback function. It can be used in any way that is convenient for the driver implementation.

erase_block() returns 0 for success, -1 if a chip error occurs, or -2 if a fatal error occurs. If -1 is returned, TargetBFS performs bad block recovery and records the block as “bad”. Once a block becomes bad, it is no longer erased or written to. A fatal error causes all subsequent accesses to fail with errno set to EIO. A fatal error should be reported if a permanent error condition exists, such as a removable device has been extracted.