NOR Flash Physical-Layer Driver

The NOR driver is divided into three layers. The topmost layer, the generic driver, requires an intermediate physical-layer driver to effect flash operations like erasing blocks and writing octets. The physical-layer driver includes one code/header file pair named according to the following rubric:

FS_DEV_NOR_<device_name>.C

FS_DEV_NOR_<device_name>.H

A non-uniform flash—a flash with some blocks of one size and some blocks of another—will require a custom driver adapted from the generic driver for the most similar medium type. Multiple small blocks should be grouped together to form large blocks, effectively making the flash appear uniform to the generic driver. A custom physical-layer driver can also implement advanced program operations unique to a NOR device family.

The physical-layer driver acts via a BSP. The generic drivers for traditional NOR flash require a BSP as described in NOR Flash BSP. The drivers for SPI flash require a SPI BSP as described in NOR Flash SPI BSP.

NOR driver architecture

Each physical-layer driver must implement the functions to be placed into a FS_DEV_NOR_PHY_API structure:

const FS_DEV_NOR_PHY_API  FSDev_NOR_#### {
    FSDev_NOR_PHY_Open,
    FSDev_NOR_PHY_Close,
    FSDev_NOR_PHY_Rd,
    FSDev_NOR_PHY_Wr,
    FSDev_NOR_PHY_EraseBlk,
    FSDev_NOR_PHY_IO_Ctrl,
};

The functions which must be implemented are listed and described in the table below. The first argument of each of these is a pointer to a FS_DEV_NOR_PHY_DATA structure which holds physical device information. Specific members will be described in subsequent sections as necessary. The NOR driver populates an internal instance of this type based upon configuration information. Before the file system suite has been initialized, the application may do the same if raw device accesses are a necessary part of its start-up procedure.

NOR flash physical-layer driver functions
FunctionDescription
Open()Open (initialize) a NOR device and get NOR device information.
Close()Close (uninitialize) a NOR device.
Rd()Read from a NOR device and store data in buffer.
Wr()Write to a NOR device from a buffer.
EraseBlk()Erase block of NOR device.
IO_Ctrl()Perform NOR device I/O control operation.