2440+NAND Flash(K9F1208UOM)總結 收藏

2440+NAND Flash(K9F1208UOM)總結 收藏 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. …… 本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/dhdahai/archive/2009/04/07/4053795.aspx
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章