参考:毛德操的《嵌入式系统》和CFI标准协议
1、闪存的特点:
1、不挥发,即在断电是不会失去已经写入的内容。
2、随机可读,就像RAM和ROM一样,可以从任意地址读出,读出的速度与地址无关。
3、对于已经写入的内容可以成片擦除,不过只能成片地擦除,而不能随机擦除,并且必须遵循一定的步骤。
4、对于空白,或已经擦除内容的区间可以按一定规则随机写入,但是一经写入,便不能向相同的地址再写入,除非先擦除。
5、内容的写入和擦除一般不需要特殊的电压条件,不像EEPROM那样一定要有较高的电压。闪存的集成度较高,所以闪存芯片的容量也比ROM大。
2、CFI
(1)、Purpose
The Common Flash Interface (CFI) specification outlines device and host system software interrogation
handshake that allows specific vendor-specified software algorithms to be used for entire families of devices.整个闪存家族
This allows device-independent, JEDEC ID-independent, and forward- and backward-compatible software
support for the specified flash device families. It allows flash vendors to standardize their existing interfaces
for long-term compatibility.
主要为了统一各种闪存芯片的接口,使软件能够通过统一的查询方式,得到此闪存芯片的操作规程和标准。
CFI规定,各厂商可以使用自己的操作规程和命令集,但是必须有一个统一的编号,并且在软件的查询下提供这个编号。而且,闪存芯片也可以同时支持两套操作规程和命令集,让软件选择使用。而且有规定闪存芯片必须提供更多的信息。
(2)、The CFI Query data structure contains a 16-bit Command Set and Control
Interface ID code that specifies a vendor-specific control interface for a family of Flash devices. Query also
contains general, common flash memory parameters and vendor-specified data areas. These provide all the
necessary information for controlling Read/Write/Erase operations of a particular family of Flash devices
according to a vendor-specified interface. Any additional information not covered in the common CFI Query
data structure is located in vendor-specific extended Query tables, the address location(s) of which is (are)
contained in the general CFI Query structure.
为了表示出闪存芯片中读出的信息,为此还定义了一个用来提供详细信息的标准数据结构,凡支持CFI的闪存芯片在受到查询时都应按这个数据结构的格式提供信息,即CFI信息块。
(3)、CFI Hardware Interface
The Query addressing is always relative to the device word (largest supported) with data always presented on the lowest order byte (D7 - D0 outputs).
注:在CFI查询过程中使用的地址是以具体芯片的存储单元为单位的。以地址0x55为例,8位芯片的存储单元是字节,所以这就是字节地址,而16位芯片的存储单元是字,所以这就是字地址,换算成字节地址就成了0xaa,而32就变成了0x154。这里的地址变化很烦,具体的可以查看协议,可以看一下这个表:
Notes:
1. The system must drive the lowest order addresses to access all the device’s array data when the device is configured in x8 mode.
Therefore, word or double addressing where the lower addresses are not toggled by the system is “Not Applicable” for x8-Configured
devices.
2. Flash devices may or may not have address sensitive query commands. Device drivers should always supply 55h on the address bus
(55h, AAh, and 154h respectively for command address location in bytes on x8, x16 and x32 data bus configured devices) and 98h on the
data bus to enter query mode, however Flash devices may choose to ignore the address bus and enter query mode if 98h is seen on the
data bus only.
3. Same as note 1 above but change x8 references to x16.
4. Devices with word addressing (16 bit or 32 bit) connected to systems with byte addressing, will have the address bus offset from the byte
address bus. For example on a 16-bit device, A0 of the device is connected to A1 of the system. To correctly address the Flash device,
the system must multiply the address by factors of 2. For a 16-bit device, the system address is twice the device address. For a 32-bit
device, the system address is 4 times the device address.
主要和芯片的类型和工作的模式有关,当然,也和几块芯片一起使用也有关系,比如用4块8位的组成32为总线。