erase_block()

PROTOTYPE

#include <bfs.h>

int erase_block(ui32 addr, void *dev);

DESCRIPTION

erase_block() erases the block of NOR flash at address addr. 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 minimum ‘chunk’ of flash memory that can be erased. Its size depends both on the flash device used and the target architecture. If two 16-bit wide devices, each with a minimum erase size of 64 KB, are used in parallel to present a 32-bit bus interface, then the block size is 128 KB.

The effective block size must match the value of the BFS_BLK_SIZE definition. The number of flash blocks must match the BFS_NUM_BLKS definition.

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

erase_block() returns 0 for success. Any other value is interpreted as a fatal error. 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 if a removable device has been extracted.