读者应当具备一些nand flash基础知识。
首先bootrom会配置一个safe NAND timings(这个最开始的safe timing在ONFI文档中有介绍,简单来说就是nand flash命令,数据写入时都能符合时序hold,set要求的时序参数。)在nand flash块里面搜索 Firmware Configuration Block(FCB)(搜索方法和zynq的bootrom找FSBL类似,应该都是寻找对应字符)。
先让我们来介绍一下,FCB,这个名字可能看到后面就忘了具体代指什么了,从这开始,就直接叫固件配置块了。
固件配置块,里面有什么呢?1,最优的nand timing。最好的nand读写配置时序。2,Discover Bad Block Table page address(DBBT).是的你没看错,nxp在烧录nand的数据里面有坏块表(或者说系统启动时能直接得到坏块表)。3,start page address of primary and secondary firmware.(两份后续固件的地址,其实两份内容是一样的,冗余的作用)。
固件配置块的信息当然也是受到ecc保护的。并且用软件ecc算法确定固件配置块是有效的还是无效的。
如果ecc出错 或者 没找到匹配的固件配置块。将会跳转Search Stride number of pages去接着找。直到SearchCount pages 。
如果一直失败,bootrom将会返回an error,并且boot ROM enters the serial download mode.
The DBBT is searched in the DBBT Search Area,
just like the FCB is searched.
This figure shows the state diagram of the FCB search:
When the FCB is found, the boot ROM searches for the Discovered Bad Blocks Table
(DBBT). If the DBBT Search Area is 0 in the FCB, the ROM assumes that there are no
bad blocks on the NAND device boot area.
See this figure for the DBBT search flow:
If there is a page with a number of errors higher than ECC can correct during the primary image read, the boot ROM turns on the PERSIST_SECONDARY_BOOT bit and
performs the software reset (After the software reset, the secondary image is used)
If there is a page with number of errors higher than ECC can correct during secondary image read, the boot ROM goes to the serial loader
This table shows the flash control block structure:
接下来是DBBT
让我们看点有意思的。
To preserve the BI (bad block information), the flash updater or gang programmer
applications must swap the Bad Block Information (BI) data to byte 0 of the metadata
area for every page before programming the NAND flash.
在写入之前,需要将spare区域存储的坏块mask swap到metadata area。也就是首地址,依此来判断是不是坏块?这个操作我似乎没在onfi,或者其他nand datasheet手册里面见过。
接下来就是read-retry。
Read-retry handling in the ROM
The read-retry is used to recover the bit errors beyond the ECC correction threshold from
NAND. If reading of a page failed and the read_retry_enable field in FCB is set to 1, the
ROM issues a read-retry command sequence to shift the read level before reading the
page again. If the previous reading failed, the ROM continues to shift the read level until
the reading succeeds or all levels were tried. The state diagram of the read-retry is shown
in this figure:
这部分内容看起来是在ONFI比较高版本中的内容。没接触过,看起来挺有趣的。
接下来就是一种和其他文档不同的数据分配方式的说明。
参考: IMX6ULL参考手册