Home |
The ISO 9660 File System Structure The exFAT File System Structure RTFiles-32 in Embedded Applications Linear Flash Driver |
Linear Flash DriverThe linear flash disk driver implements a block device driver on directly addressable NOR flash chips. The driver consists of two layers: The flash chip independent flash driver and the MTD (Memory Technology Driver), which is responsible for handling the flash memory (e.g., erasing, programming, mapping, etc.) The linear flash disk driver maps 512 byte sectors onto flash blocks (also called erase units). Each block has a header, which is followed by the actual storage used for data sectors. The driver can handle flash devices with the following characteristics:
The linear flash disk driver performs active wear leveling and minimizes the number of erase and write operations. The driver records the number of erase cycles in the header of each block and it will not allow the difference between the highest and lowest erase count to become larger than 1000. The number of sectors the driver can handle is limited to 224 (16777216 sectors or 8 GB). The number of erase cycles the driver can record is also 224. Once all blocks of a volume have been erased 224 times, no further wear leveling takes place, but the disk continues to function normally. The driver has been designed to recover from interrupted write operations. For example, if the device is powered off while a sector is written to the flash, the previous sector's content is restored the next time the device is switched on. Every operation on the flash device can be rolled back to a consistent state. Note, however, that higher level FAT data structures might still be corrupted (e.g., a FAT update was completed successfully, but the respective directory entry was not written). RTFCheckDisk may be able to recover from such errors. The data structures written to the flash memory by this driver are proprietary. Flash disks formatted with this driver cannot be used with any other operating system. RTFDevice.DeviceTypeRTFDevice.DeviceType may be set to either RTF_DEVICE_FDISK (recommended) or RTF_DEVICE_FLOPPY. However, once the flash disk has been formatted, this value must not be changed. If it is changed, the disk must be repartitioned and reformatted. RTFDevice.DeviceNumberThe device number is ignored and should be set to 0. RTFDevice.DeviceFlagsApart from the device independent flags documented in section Device List, this driver defines the following device dependent flags: RTF_FLASH_NO_SECTOR_MAPBy default, the driver will allocate a sector map at program initialization using malloc. This sector map allows the driver to locate the physical location of a logical sector very quickly, but it does require 4 bytes of RAM per sector. For example, for a flash disk with a capacity of 4M, the sector map would require 4M/512*4 = 32k of RAM. If low memory overhead is more important than disk I/O performance, specify this flag. RTF_FLASH_NO_LOW_FMTBy default, the driver will automatically low-level format flash memory which contains no or invalid block headers. Use this flag to prevent such formatting. RTF_FLASH_NO_HIGH_FMTBy default, the driver will automatically high-level format flash memory which contains no valid boot sector. Use this flag to prevent such formatting. The default formatting uses format flags RTF_FMT_SINGLE_FAT and RTF_FMT_NO_FAT_32 with a default cluster size. As long as no two flash disks share the same MTD or the MTDs used are reentrant, the flash disk driver is reentrant and supports device flag RTF_DEVICE_NEW_LOCK for every device entry. RTFDevice.DriverThis field must point to RTFDrvFlash. RTFDevice.DriverDataThis field must point to a unique structure of type RTFDrvFlashData: typedef struct { RTF_MTD * MTDDriver; void * MTDData; ... } RTFDrvFlashData; Member RTFDrvFlashData.MTDDriver must point to an MTD driver for the flash memory to be used. MTDData points to the MTD driver's data. All other fields of this structure should be initialized to 0 or left uninitialized. More Information about MTDs is available in section Advanced Topics, Custom Flash MTD Drivers. The following section has a complete flash disk driver configuration example.
|