µC/FS NOR Flash Driver
You are here : Micrium
: Products : µC/FS :
NOR Flash Driver
µC/FS NOR Flash driver contains all hardware access functions required. We supply code that can handle most of the standard 29x or 28x flash chips. It may also be adapted to your specific memory chip. You can also implement your own driver by covering the required access functions listed in section 3. Because not every chip supports single byte access, every access to flash memory is 4 bytes or a multiple of 4 bytes.
Supported hardware
The NOR flash driver can be used with any CFI compliant 16-bit chip. The Common Flash Memory Interface (CFI) is an open specification which may be implemented freely by flash memory vendors in their devices. It was developed jointly by Intel, AMD, Sharp, and Fujitsu. The idea behind CFI was the interchangeability of current and future flash memory devices offered by different vendors. If you use only CFI compliant flash memory chips, you are able to use one driver for different flash products by reading identifying information out of the flash chip itself. The identifying information for the device, such as memory size, byte/word configuration, block configuration, necessary voltages, and timing information, is stored directly on the chip.
Theory of operation
Differentiating between "logical sectors" or "blocks" and "physical sectors" is very essential to understand this driver. A logical ector/block is the base unit of any file system, its usual size is 512 bytes. A physical sector is an array of bytes on the flash chip that are erased together (typically between 2 Kbytes - 128 Kbytes).
The flash chip driver is an abstraction layer between these two types of sectors. Every time a logical sector is being updated, it is marked as invalid and the new content of this sector is written into another area of the flash. The physical address and the order of physical sectors can change with every write access. Hence, there cannot exist a direct relation between the sector number and its physical location.
The flash driver manages the logical sector numbers by writing it into special headers. It does not matter to the upper layer were the logical sector is stored or how much flash memory is used as a buffer. All logical sectors (starting with Sector #0) do always exist and are always available for user access.
Using the same NOR flash for code and data:
Most NOR flashes cannot be read out during a program, erase or identify operation. This means that code cannot be read from the NOR flash during a program or erase operation. If code which resides in the same NOR flash used for data storage is executed during program or erase, a program crash is almost certain. There are multiple options to solve this:
- Use multiple NOR flashes. Use one flash for code and one for data.
- Use a NOR flash with multiple banks, which allows reading Bank A while BANK B is being programmed.
- Make sure the hardware routines which program, erase or identify the NOR flash are located in RAM and interrupts are disabled.
Fail-safe operation
The µC/FS NOR driver is fail-safe. That means that the driver makes only atomic actions and takes the responsibility that the data managed by the file system is always valid. In case of power loss or power reset during a write operation it is always assured that only valid data is stored in the flash. If the power loss interrupts the write operation, the old data will be kept and not corrupted.
Wear leveling
Wear leveling is supported by the driver. Wear leveling makes sure that the number of erase cycles remains approximately equal for each sector. Maximum erase count difference is set to 5. This value specifies a maximum difference of erase counts for different physical sectors before the wear leveling uses the sector with the lowest erase count. s
|