<< Previous | Next >>

nf_initDevice

int nf_initDevice( nf_device * dev, int which );

Description

Initializes a particular NAND flash device. This function must be called before the particular NAND flash device can be used. See nf_devtable[] in NFLASH.LIB for the user-updatable list of supported NAND flash devices. Note that xalloc is called to allocate buffer(s) memory for each NAND flash device; a run time error will occur if the available xmem RAM is insufficient.

There are two modes of operation for NAND flash devices: FAT and direct. If you are using the FAT file system in the default configuration, i.e., the NAND flash has one FAT partition that takes up the entire device, you do not need to call nf_initDevice(). You only need to call nf_InitDriver(), which is the default device driver for the FAT file system on a NAND flash device.

Configurations other than the default one require more work. For example, having two partitions on the device, one a FAT partition and the other a non-FAT partition, require you to know how to fit more than one partition on a device. A good example of how to do this is in the remote application upload utility. The function dlm_initserialflash() in /LIB/RCM3300/downloadmanager.lib is where to look for code details.The upload utility is specifically for the RCM3300; however, even without the RCM3300, the utility is still useful in detailing what is necessary to manage multiple partitions.

The second mode of operation for NAND flash devices is direct access. An application that directly accesses the NAND flash (using calls such as nf_readPage() and nf_writePage()) may define NFLASH_USEERASEBLOCKSIZE to be either 0 (zero) or 1 (one) before NFLASH.LIB is #used, in order to set the NAND flash driver's main data program unit size to either the devices' program page size of 512 bytes or to its erase block size of 16 KB.

If not defined by the application, NFLASH_USEERASEBLOCKSIZE is set to the value 1 in NFLASH.LIB; this mode should maximize the NAND flash devices' life.

NFLASH_USEERASEBLOCKSIZE value 1 sets the driver up to program an erase block size at a time. This mode may be best for applications with only a few files open in write mode with larger blocks of data being written, and may be especially good at append operations. The trade off is reduced flash erasures at the expense of chunkier overhead due to the necessity of performing all 32 pages' ECC calculations for each programming unit written.

NFLASH_USEERASEBLOCKSIZE value 0 sets the driver up to program a program page size at a time. This mode may be best for applications with more than a few files open in write mode with smaller blocks of data being written, and may be especially good at interleaved file writes and/or random access write operations. The trade off is increased flash erasures with the benefit of spread out overhead due to the necessity of performing only 1 page's ECC calculations per programming unit written.

Parameters

dev
Pointer to an nf_device structure that will be filled in. An initialized nf_device struct acts as a handle for the NAND flash device.

which
Number of the NAND flash device to initialize. Currently supported device numbers are 0 for the soldered-on device or 1 for the socketed NAND flash device.

Return value

 0: Success
-1: Unknown index or bad internal I/O port information
-2: Error communicating with flash chip
-3: Unknown flash chip type

Library

NFLASH.LIB (This function was introduced in Dynamic C 9.01)

See Also

CalculateECC256, ChkCorrectECC256, xCalculateECC256, xChkCorrectECC256


Dynamic C Functions << Previous | Next >> rabbit.com