Flash memory is an increasingly common storage medium in embedded devices, because it provides solid state storage with high reliability and high density, at a relatively low cost.
Flash is a form of Electrically Erasable Read Only Memory (EEPROM), available in two major types -- the traditional NOR flash which is directly accessible, and the newer, cheaper NAND flash which is addressable only through a single 8-bit bus used for both data and addresses, with separate control lines.
These types of flash share their most important characteristics -- each bit in a clean flash chip will be set to a logical one, and can be set to zero by a write operation.
Flash chips are arranged into blocks which are typically 128KiB on NOR flash and 8KiB on NAND flash. Resetting bits from zero to one cannot be done individually, but only by resetting (or ``erasing'') a complete block. The lifetime of a flash chip is measured in such erase cycles, with the typical lifetime being 100,000 erases per block. To ensure that no one erase block reaches this limit before the rest of the chip, most users of flash chips attempt to ensure that erase cycles are evenly distributed around the flash; a process known as ``wear levelling''.
Aside from the difference in erase block sizes, NAND flash chips also have other differences from NOR chips. They are further divided into ``pages'' which are typically 512 bytes in size, each of which has an extra 16 bytes of ``out of band'' storage space, intended to be used for metadata or error correction codes. NAND flash is written by loading the required data into an internal buffer one byte at a time, then issuing a write command. While NOR flash allows bits to be cleared individually until there are none left to be cleared, NAND flash allows only ten such write cycles to each page before leakage causes the contents to become undefined until the next erase of the block in which the page resides.
Until recently, the majority of applications of flash for file storage have involved using the flash to emulate a block device with standard 512-byte sectors, and then using standard file systems on that emulated device.
The simplest method of achieving this is to use a simple 1:1 mapping from the emulated block device to the flash chip, and to simulate the smaller sector size for write requests by reading the whole erase block, modifying the appropriate part of the buffer, erasing and rewriting the entire block. This approach provides no wear levelling, and is extremely unsafe because of the potential for power loss between the erase and subsequent rewrite of the data. However, it is acceptable for use during development of a file system which is intended for read-only operation in production models. The mtdblock Linux driver provides this functionality, slightly optimised to prevent excessive erase cycles by gathering writes to a single erase block and only performing the erase/modify/writeback procedure when a write to a different erase block is requested.
To emulate a block device in a fashion suitable for use with a writable file system, a more sophisticated approach is required.
To provide wear levelling and reliable operation, sectors of the emulated block device are stored in varying locations on the physical medium, and a ``Translation Layer'' is used to keep track of the current location of each sector in the emulated block device. This translation layer is effectively a form of journalling file system.
The most common such translation layer is a component of the PCMCIA specification, the ``Flash Translation Layer'' [FTL]. More recently, a variant designed for use with NAND flash chips has been in widespread use in the popular DiskOnChip devices produced by M-Systems.
Unfortunately, both FTL and the newer NFTL are encumbered by patents -- not only in the United States but also, unusually, in much of Europe and Australia. M-Systems have granted a licence for FTL to be used on all PCMCIA devices, and allow NFTL to be used only on DiskOnChip devices.
Linux supports both of these translation layers, but their use is deprecated and intended for backwards compatibility only. Not only are there patent issues, but the practice of using a form of journalling file system to emulate a block device, on which a ``standard'' journalling file system is then used, is unnecessarily inefficient.
A far more efficient use of flash technology would be permitted by the use of a file system designed specifically for use on such devices, with no extra layers of translation in between. It is precisely such a filesystem which Axis Communications AB released in late 1999 under the GNU General Public License.