2440+NAND Flash(K9F1208UOM)总结

发布时间:2014-10-25 2:20:49
来源:分享查询网

2440+NAND Flash(K9F1208UOM)总结:   1.         以Page为单位读写,此Flash为Small Page Flash,即每页为528Byte(512 Byte +16 Byte) 2.         以Block为单位擦除,每个Block为(16K+512)Byte即为32 Page 3.         整个Flash分为Main area(数据存储)和Spare area(坏块标记、ECC等数据) 4.         Spare area中的坏块标记为第6字节,此为三星推荐值,还是用此值比较好,因为Flash出厂时若有坏块,三星应该也是在此位作标记。 5.         ECC校验是硬件实现的,我们要做的就是在第一次写Flash时从寄存器NFMECC0中读取ECC码,然后将其写入Spare area中的相应位(可以自己定义,只要不是第6位)。在读Flash时,再读寄存器NFMECC0获得此次读取的数据的ECC码和原来存在Flash中的ECC码对比,若相同则证明读取数据正确,不对再进行其它操作。 6.         为了支持从NAND Flash启动,2440内部集成一SRAM buffer即Steppingstone。复位时,NAND Flash前4kByte代码自动拷到Steppingstone中,并执行。这部分代码为Nboot一般进行硬件初始化并将Eboot从NAND Flash拷到SDRAM中,即完成使命。接着就是Eboot进行内核的加载。 7.         NAND Flash分布(我的例子): Block0——Nboot Block1-7——Eboot Block8-9——Reserved Block10——MBR(在最后一个Sector) Block11-X——Wince系统内核及其它<32M BlockX-End——Pocket Store(FAT分区) 8.         MBR(Master Boot Record即为 主引导记录)占512字节即一个sector,其中有4个16字节的分区表项用来记录最多4个分区。每个分区表项对应一个结构体PARTENTRY其定义为: typedef struct _PARTENTRY {     BYTE            Part_BootInd;         // If 80h means this is boot partition     BYTE            Part_FirstHead;        // Partition starting head based 0     BYTE            Part_FirstSector;       // Partition starting sector based 1     BYTE            Part_FirstTrack;       // Partition starting track based 0     BYTE            Part_FileSystem;      // Partition type signature field     BYTE            Part_LastHead;        // Partition ending head based 0     BYTE            Part_LastSector;       // Partition ending sector based 1     BYTE            Part_LastTrack;        // Partition ending track based 0     DWORD          Part_StartSector;       // Logical starting sector based 0     DWORD          Part_TotalSectors;      // Total logical sectors in partition } PARTENTRY; 此结构体成员变量中还有起始和结束的磁头(Head)、扇区(Sector)和磁道(Track),应该是由磁盘分区来的,因为对NAND Flash而言只有Block和Sector。所以在Boot里写MBR时要将LBA(logical block addresses)转化为CHS地址。代码如下: static CHSAddr LBAtoCHS(LBAAddr lba) {     CHSAddr chs;     DWORD tmp = NUM_BLOCKS * SECTOR_PER_BLOCK;       chs.cylinder = (WORD)(lba / tmp);     tmp = lba % tmp;     chs.head = (WORD)(tmp / SECTOR_PER_BLOCK);     chs.sector = (WORD)((tmp % SECTOR_PER_BLOCK) + 1);       return chs; } 其实就是把Block地址赋给磁头(Head),Sector地址赋给扇区(Sector)。为啥非得进行这样的地址转换,否则系统识别不了??       PARTENTRY.Part_BootInd = PART_IND_ACTIVE | PART_IND_READ_ONLY;  //标记分区信息,活动、只读等     PARTENTRY.Part_FileSystem = 0x21;   // 分区类型BINFS     PARTENTRY.Part_StartSector = SECTOR_PER_BLOCK;     PARTENTRY.Part_TotalSectors = u32ImageSize / SECTOR_SIZE; 9.         NANDIMAGE:关于NANDIMAGE PB帮助文档上有一段话: Specifies that RAM should overlap these regions when building a run-time image that uses BINFS. The overlapping regions are stored in NAND but are fixed up to virtually appear as though they do not overlap. When the kernel accesses these regions, BINFS responds by intercepting the request. BINFS accesses NAND and returns the proper data to the kernel. This enables a device with NAND to execute in place out of NAND, freeing up RAM for use by the system. Romimage generates one binary (.bin) file for each NANDIMAGE entry. NANDIMAGE sections must be page aligned. 这段话有点费解,我的理解:虽然被标作NANDIMAGE,此区域实际上是被用作RAM的。真正的IMAGE还在NAND Flash中,可通过BINFS访问。这样看来这个NANDIMAGE好像只是作为一个标记被Romimage.exe用来产生NK.bin文件。 10.     ……  

返回顶部
查看电脑版