SlideShare una empresa de Scribd logo
1 de 16
Nand Flash InterfaceNand Flash Interface
Represented by Sneeker Yeh
2010 March.
OutlineOutline
• Introduction
•
Nandflash operation
•
WinCE image layout
•
Case study 1
•
Case study 2
IntroductionIntroduction
•
下圖為下圖為 nand flashnand flash 的範例的範例 (K9F2G08X0A)(K9F2G08X0A)
•
I/OI/O 腳位不只可將資料腳位不只可將資料 input or output,input or output, 也可以也可以 inputinput 命令與位址命令與位址 ..
•
若若 flashflash 結構為結構為 1616 位元位元 (16(16 支支 I/OI/O 腳)腳) ,, 資料的運輸則以資料的運輸則以 1616 位元為位元為
單位單位 ,, 命令與位址則仍然維持八位元的形式命令與位址則仍然維持八位元的形式 (( 似乎是約定俗成的規則似乎是約定俗成的規則
))
IntroductionIntroduction
•
將一筆資料寫入將一筆資料寫入 nand flashnand flash 的時序圖的時序圖
•
信號的信號的 pulse widthpulse width 由由 controllercontroller 來管理來管理 , programmer, programmer 只需準備只需準備
命令命令 ,, 位址資訊位址資訊 ,, 資料資料 , controller, controller 會將這些訊息有條不紊地輸入到會將這些訊息有條不紊地輸入到
nand flash.nand flash.
•
programmerprogrammer 只需注意每個命令與定址資訊的間隔只需注意每個命令與定址資訊的間隔 ,, 會由專屬的會由專屬的
status regstatus reg 或發出中斷兩種方法來表示或發出中斷兩種方法來表示 ,, 等到該等到該 operationoperation 完成後完成後
,, 才能繼續操作才能繼續操作 controllercontroller 執行下一步動作執行下一步動作
IntroductionIntroduction
控制器會在 I/O 上寫
”入 00h ”讀取命令 並控制
CLE, WE, CE, ALE, RE 來
”表示該操作為 input
command”
Programmer 要注意該
操作是否結束 ( 輪詢狀態
暫存器或中斷發生 ), 才
能進行下個操作
Nandflash operationNandflash operation
Buffer[0]Buffer[0]
(512 bytes)(512 bytes)
Buffer[1]Buffer[1]
(512 bytes)(512 bytes)
Buffer[2]Buffer[2]
(512 bytes)(512 bytes)
Buffer[3]Buffer[3]
(512 bytes)(512 bytes)
Spare_buf[0]Spare_buf[0]
(16 bytes)(16 bytes)
Spare_buf[1]Spare_buf[1]
(16 bytes)(16 bytes)
Spare_buf[2]Spare_buf[2]
(16 bytes)(16 bytes)
Spare_buf[3]Spare_buf[3]
(16 bytes)(16 bytes)
Page 4Page 4
Page 5Page 5
Nand flash
iMX31 controller buffer
Page read
Nandflash operationNandflash operation
•
Nand flashNand flash 的寫入與讀取規則皆必須以一個的寫入與讀取規則皆必須以一個 pagepage 為為
單位單位
•
然而寫入動作必須有額外的遊戲規則然而寫入動作必須有額外的遊戲規則 ,, 要寫入的區域要寫入的區域
其內容必須皆為其內容必須皆為 0xff.0xff.
•
Write 1 on 1 -> 1Write 1 on 1 -> 1
•
Write 0 on 1 -> 0Write 0 on 1 -> 0
•
Write 1 on 0 -> 0Write 1 on 0 -> 0
•
Write 0 on 0 -> 0Write 0 on 0 -> 0
•
Nand flashNand flash 提供了提供了 erase commanderase command 讓讓
programmerprogrammer 可以將內容轉變為可以將內容轉變為 0xff, erase0xff, erase 的單位的單位
0xffffffff0xffffffff
0xffffffff0xffffffff
0xffffffff0xffffffff
0xffffffff0xffffffff
0xffffffff0xffffffff
0xffffffff0xffffffff
0xffffffff0xffffffff
0xffffffff0xffffffff
Nandflash operationNandflash operation
Buffer[0]Buffer[0]
(512 bytes)(512 bytes)
Buffer[1]Buffer[1]
(512 bytes)(512 bytes)
Buffer[2]Buffer[2]
(512 bytes)(512 bytes)
Buffer[3]Buffer[3]
(512 bytes)(512 bytes)
Spare_buf[0]Spare_buf[0]
(16 bytes)(16 bytes)
Spare_buf[1]Spare_buf[1]
(16 bytes)(16 bytes)
Spare_buf[2]Spare_buf[2]
(16 bytes)(16 bytes)
Spare_buf[3]Spare_buf[3]
(16 bytes)(16 bytes)
0xaaaaaaaa0xaaaaaaaa
Nand flash
iMX31 controller buffer
Page 的寫入前
如果不確定是不
是 0xff, 要記得
先操除 (erase)
喔
Block 0
Case study 1 : GarbageCase study 1 : Garbage
Collection – 1/3Collection – 1/3
File 1
File 1
File 3
File 3
File 3
File 2
File 3 (new)
File 3 (new)
File 3 (new)
Invalid
Invalid
Invalid
File 4
Invalid
Invalid
Invalid
Block 0 Block 1 Block 2 Block 3
•
原由原由 :read/write:read/write 與與 eraseerase 的單位是不一樣的的單位是不一樣的 ..
•
因此在資料讀寫的操作上會有因此在資料讀寫的操作上會有 invalid pageinvalid page 的觀念的觀念 ,, 若要將一筆資料刪除若要將一筆資料刪除 ,, 只只
要在記憶體準備一個要在記憶體準備一個 tabletable 並將資料所佔用的並將資料所佔用的 page markpage mark 成成 invalidinvalid 即可即可 ..
•
若要將一筆資料如若要將一筆資料如 file 3file 3 更新更新 flash,flash, 只要尋找足夠的只要尋找足夠的 free pagefree page 寫入寫入 ,, 再將舊再將舊
的的 file 3file 3 區域區域 markmark 成成 invalidinvalid 即可即可 ,, 過程只需耗費過程只需耗費 33 個個 page writepage write 動作動作 ..
•
若沒有若沒有 tabletable 機制機制 ,, 則必須先搬移出則必須先搬移出 file2(1*read),file2(1*read), 將將 block2block2 擦除擦除 (1*erase),(1*erase),
將將 file2file2 及新的及新的 file3file3 寫入寫入 (4*write):(4*write):
•
WriteWrite 操作比原先的機制還多了一次操作比原先的機制還多了一次 (write(write 是最耗時間的動作是最耗時間的動作 ))
File 5
File 5
File 5
File 5Invalid
Case study 1 : GarbageCase study 1 : Garbage
Collection – 2/3Collection – 2/3
•
接續上一個接續上一個 scenario,scenario, 若要寫入一個若要寫入一個 4page4page 大小的大小的 file5:file5:
•
執行執行 garbage collection:garbage collection: 搬移搬移 file4file4 到到 block3(1*read,1*write),block3(1*read,1*write),
擦除擦除 block0(1*erase).block0(1*erase).
•
將將 file5file5 寫入寫入 block0(4*write).block0(4*write).
File 1
File 1
File 2
File 3 (new)
File 3 (new)
File 3 (new)
Invalid
Invalid
Invalid
File 4
Invalid
Invalid
Invalid
Block 0 Block 1 Block 2 Block 3
File 4
Case study 1 : GarbageCase study 1 : Garbage
Collection - 3/3Collection - 3/3
•
Garbage collectionGarbage collection 的演算法的演算法 issue:issue:
•
garbage collectiongarbage collection 是很耗費時間是很耗費時間 ..
•
如何如何 mergemerge 出一個出一個 total freetotal free 的的 block(block( 盡量要有效率且不要有太盡量要有效率且不要有太
多的碎裂情形多的碎裂情形 , for ex,, for ex, 將將 file4file4 搬至搬至 block1block1 碎裂情形較嚴重碎裂情形較嚴重 ).).
File 1
File 1
File 2
File 3 (new)
File 3 (new)
File 3 (new)
Invalid
Invalid
Invalid
File 4
Invalid
Invalid
Invalid
Block 0 Block 1 Block 2 Block 3
Case study 2 :Case study 2 : 模擬燒錄器模擬燒錄器
–的寫入與讀取 –的寫入與讀取 1/51/5
•
模擬燒錄器的寫入與讀取模擬燒錄器的寫入與讀取 ::
•
在在 iMX31 controlleriMX31 controller 具備硬體具備硬體 eccecc 產生產生 ,, 硬體硬體 eccecc 偵錯偵錯 ,, 硬體硬體
eccecc 更正能力更正能力 ,, 因此在操作上會帶來一些限制:因此在操作上會帶來一些限制:
•
在在 spare area bufferspare area buffer 有預留一塊有預留一塊 ecc codeecc code 區域區域 ,,
programmerprogrammer 所寫入的值將會被硬體忽略所寫入的值將會被硬體忽略 ,, 因為硬體會自動產生因為硬體會自動產生
偵錯所需的偵錯所需的 ecc codeecc code 寫入對應的寫入對應的 spare area.spare area.
•
當硬體讀取一個當硬體讀取一個 pagepage 時時 ,, 並不會將並不會將 ecc codeecc code 放置對應的放置對應的
spare area buffer,spare area buffer, 而且讀入其他邏輯電路並且執行錯誤偵測與而且讀入其他邏輯電路並且執行錯誤偵測與
更正更正 ..
–模擬燒錄器的寫入 –模擬燒錄器的寫入 2/52/5
•
因此在預設情況下因此在預設情況下 ,, 一個一個 pagepage 的的 2112 bytes2112 bytes 中中 ,, 有少許作為有少許作為 eccecc 存存
放的區域是無法讓放的區域是無法讓 programmerprogrammer 寫值進去的寫值進去的 ::
•
然而然而 ,, 若我們擁有若我們擁有 raw image (raw image ( 包含所有包含所有 spare area, include ecc),spare area, include ecc),
並且我們想要將模擬燒錄器燒錄並且我們想要將模擬燒錄器燒錄 nandflashnandflash 行為行為 ,, 將整個將整個 imageimage 燒入燒入
flash:flash:
•
我們可以設定我們可以設定 controllercontroller 為為 ecc disable,ecc disable, 則此時則此時 spare areaspare area
bufferbuffer 的的 eccecc 區域則可以讓區域則可以讓 programmerprogrammer 自由運用自由運用 ,, 並進而寫值並進而寫值 ..
•
此時我們可以完全對此時我們可以完全對 pagepage 中所有的中所有的 2112 bytes2112 bytes 寫進所需要的值寫進所需要的值 ..
–模擬燒錄器的讀取 –模擬燒錄器的讀取 3/53/5
•
iMX31 controlleriMX31 controller 的缺陷的缺陷 ::
•
即使即使 disable ecc,disable ecc, 則硬體在讀取則硬體在讀取 pagepage 時時 ,, 仍會將仍會將 ecc codeecc code 讀入讀入
其他邏輯電路並且執行錯誤偵測其他邏輯電路並且執行錯誤偵測 ,, 並不會將並不會將 ecc codeecc code 放置對應的放置對應的
spare area buffer(spare area buffer( 此時此時 disabledisable 的是更正能力的是更正能力 ).).
•
所以我們必須要有額外的策略將所以我們必須要有額外的策略將 pagepage 中所有的中所有的 2112byte2112byte 讀取出來讀取出來
,, 否則我們無法製作出燒錄器所需要的否則我們無法製作出燒錄器所需要的 raw data.raw data.
–模擬燒錄器的讀取 –模擬燒錄器的讀取 4/54/5
•
ControllerController 對對 nand flashnand flash 上上 pagepage 的觀點的觀點 ,, 每每 512byte512byte 伴隨一段伴隨一段 64byte64byte 的的
spare area(ecc, and other metadata).spare area(ecc, and other metadata).
•
controllercontroller 會進行四次會進行四次 get dataget data 的動作的動作 (( 每次抓取每次抓取 528bytes),528bytes), 才可以完成一次才可以完成一次
pagepage 的讀取的讀取 Buffer[0]Buffer[0]
(512 bytes)(512 bytes)
Buffer[1]Buffer[1]
(512 bytes)(512 bytes)
Buffer[2]Buffer[2]
(512 bytes)(512 bytes)
Buffer[3]Buffer[3]
(512 bytes)(512 bytes)
Spare_buf[0]Spare_buf[0]
(16 bytes)(16 bytes)
Spare_buf[1]Spare_buf[1]
(16 bytes)(16 bytes)
Spare_buf[2]Spare_buf[2]
(16 bytes)(16 bytes)
Spare_buf[3]Spare_buf[3]
(16 bytes)(16 bytes)
Buffer[0]Buffer[0]
(512 bytes)(512 bytes)
Buffer[1]Buffer[1]
(512 bytes)(512 bytes)
Buffer[2]Buffer[2]
(512 bytes)(512 bytes)
Buffer[3]Buffer[3]
(512 bytes)(512 bytes)
Spare_buf[0]Spare_buf[0]
(16 bytes)(16 bytes)
Spare_buf[1]Spare_buf[1]
(16 bytes)(16 bytes)
Spare_buf[2]Spare_buf[2]
(16 bytes)(16 bytes)
Spare_buf[3]Spare_buf[3]
(16 bytes)(16 bytes)
Controller
buffer
Nand
flash
structure
–模擬燒錄器的讀取 –模擬燒錄器的讀取 5/55/5
•
我們可以將四次我們可以將四次 get dataget data ” ”的動作之間加入 定址 操作” ”的動作之間加入 定址 操作 ,,
在加上最後一次在加上最後一次 get data(get data( 只有只有 64bytes,64bytes, 其餘忽略其餘忽略 ))
Buffer[0]Buffer[0]
(512 bytes)(512 bytes)
Spare_buf[0]Spare_buf[0]
(16 bytes)(16 bytes)
Buffer[0]Buffer[0]
(512 bytes)(512 bytes)
Buffer[1]Buffer[1]
(512 bytes)(512 bytes)
Buffer[2]Buffer[2]
(512 bytes)(512 bytes)
Buffer[3]Buffer[3]
(512 bytes)(512 bytes)
Spare_buf[0]Spare_buf[0]
(16 bytes)(16 bytes)
Spare_buf[1]Spare_buf[1]
(16 bytes)(16 bytes)
Spare_buf[2]Spare_buf[2]
(16 bytes)(16 bytes)
Spare_buf[3]Spare_buf[3]
(16 bytes)(16 bytes)
Controller
buffer
Nand
flash
structure
Operation1:
1.Disable ecc
2.Column=0
3.Get 528 byte
Operation2:
1.Column=51
2
2.Get 528
byte
Operation3:
1.Column=1024
2.Get 528 byte
Operation4:
1.Column=15
36
2.Get 528
byteOperation5:
1.Column=2048
2.Get 528 byte
3.Ignore bytes
after 64th
byte in
main buffer

Más contenido relacionado

La actualidad más candente

MySQL源码分析.01.代码结构与基本流程
MySQL源码分析.01.代码结构与基本流程MySQL源码分析.01.代码结构与基本流程
MySQL源码分析.01.代码结构与基本流程Lixun Peng
 
Virtual file system (VFS)
Virtual file system (VFS)Virtual file system (VFS)
Virtual file system (VFS)Waylin Ch
 
Altibase管理培训 安装篇
Altibase管理培训 安装篇Altibase管理培训 安装篇
Altibase管理培训 安装篇小新 制造
 
4, files & folders
4, files & folders4, files & folders
4, files & foldersted-xu
 
DNS IPv6
DNS IPv6DNS IPv6
DNS IPv6csklho
 
5, system admin
5, system admin5, system admin
5, system adminted-xu
 
我的 Windows 平台自動化經驗:基礎批次檔撰寫實務
我的 Windows 平台自動化經驗:基礎批次檔撰寫實務我的 Windows 平台自動化經驗:基礎批次檔撰寫實務
我的 Windows 平台自動化經驗:基礎批次檔撰寫實務Will Huang
 
Oda安装 恢复步骤
Oda安装 恢复步骤Oda安装 恢复步骤
Oda安装 恢复步骤n-lauren
 
Linux 教育訓練
Linux 教育訓練Linux 教育訓練
Linux 教育訓練Bo-Yi Wu
 
20030623 linuxbasic and-security
20030623 linuxbasic and-security20030623 linuxbasic and-security
20030623 linuxbasic and-security建融 黃
 
Return to dlresolve
Return to dlresolveReturn to dlresolve
Return to dlresolveAngel Boy
 
Bypat博客出品-利用cent os快速构建自己的发行版
Bypat博客出品-利用cent os快速构建自己的发行版Bypat博客出品-利用cent os快速构建自己的发行版
Bypat博客出品-利用cent os快速构建自己的发行版redhat9
 
排队论及其应用浅析
排队论及其应用浅析排队论及其应用浅析
排队论及其应用浅析frogd
 
MySQL源码分析.03.InnoDB 物理文件格式与数据恢复
MySQL源码分析.03.InnoDB 物理文件格式与数据恢复MySQL源码分析.03.InnoDB 物理文件格式与数据恢复
MySQL源码分析.03.InnoDB 物理文件格式与数据恢复Lixun Peng
 
Linux安全配置终极指南
Linux安全配置终极指南Linux安全配置终极指南
Linux安全配置终极指南wensheng wei
 
Linux network monitoring hands-on pratice
Linux network monitoring hands-on praticeLinux network monitoring hands-on pratice
Linux network monitoring hands-on praticeKenny (netman)
 
Linux Jffs2 & Linux MTD Device
Linux Jffs2 & Linux  MTD DeviceLinux Jffs2 & Linux  MTD Device
Linux Jffs2 & Linux MTD Device艾鍗科技
 

La actualidad más candente (20)

MySQL源码分析.01.代码结构与基本流程
MySQL源码分析.01.代码结构与基本流程MySQL源码分析.01.代码结构与基本流程
MySQL源码分析.01.代码结构与基本流程
 
Virtual file system (VFS)
Virtual file system (VFS)Virtual file system (VFS)
Virtual file system (VFS)
 
Altibase管理培训 安装篇
Altibase管理培训 安装篇Altibase管理培训 安装篇
Altibase管理培训 安装篇
 
4, files & folders
4, files & folders4, files & folders
4, files & folders
 
DNS IPv6
DNS IPv6DNS IPv6
DNS IPv6
 
Linux File system
Linux File systemLinux File system
Linux File system
 
5, system admin
5, system admin5, system admin
5, system admin
 
我的 Windows 平台自動化經驗:基礎批次檔撰寫實務
我的 Windows 平台自動化經驗:基礎批次檔撰寫實務我的 Windows 平台自動化經驗:基礎批次檔撰寫實務
我的 Windows 平台自動化經驗:基礎批次檔撰寫實務
 
Oda安装 恢复步骤
Oda安装 恢复步骤Oda安装 恢复步骤
Oda安装 恢复步骤
 
Linux 教育訓練
Linux 教育訓練Linux 教育訓練
Linux 教育訓練
 
20030623 linuxbasic and-security
20030623 linuxbasic and-security20030623 linuxbasic and-security
20030623 linuxbasic and-security
 
Return to dlresolve
Return to dlresolveReturn to dlresolve
Return to dlresolve
 
Bypat博客出品-利用cent os快速构建自己的发行版
Bypat博客出品-利用cent os快速构建自己的发行版Bypat博客出品-利用cent os快速构建自己的发行版
Bypat博客出品-利用cent os快速构建自己的发行版
 
排队论及其应用浅析
排队论及其应用浅析排队论及其应用浅析
排队论及其应用浅析
 
MySQL源码分析.03.InnoDB 物理文件格式与数据恢复
MySQL源码分析.03.InnoDB 物理文件格式与数据恢复MySQL源码分析.03.InnoDB 物理文件格式与数据恢复
MySQL源码分析.03.InnoDB 物理文件格式与数据恢复
 
Overlayfs and VFS
Overlayfs and VFSOverlayfs and VFS
Overlayfs and VFS
 
Linux安全配置终极指南
Linux安全配置终极指南Linux安全配置终极指南
Linux安全配置终极指南
 
Linux network monitoring hands-on pratice
Linux network monitoring hands-on praticeLinux network monitoring hands-on pratice
Linux network monitoring hands-on pratice
 
Linux Jffs2 & Linux MTD Device
Linux Jffs2 & Linux  MTD DeviceLinux Jffs2 & Linux  MTD Device
Linux Jffs2 & Linux MTD Device
 
09 存储系统01
09 存储系统0109 存储系统01
09 存储系统01
 

Destacado

Introduction to SPI and PMIC with SPI interface (chinese)
Introduction to SPI and PMIC with SPI interface (chinese)Introduction to SPI and PMIC with SPI interface (chinese)
Introduction to SPI and PMIC with SPI interface (chinese)Sneeker Yeh
 
Concurrency bug identification through kernel panic log (english)
Concurrency bug identification through kernel panic log (english)Concurrency bug identification through kernel panic log (english)
Concurrency bug identification through kernel panic log (english)Sneeker Yeh
 
Basic Concept of Pixel and MPEG data structure (english)
Basic Concept of Pixel and MPEG data structure (english)Basic Concept of Pixel and MPEG data structure (english)
Basic Concept of Pixel and MPEG data structure (english)Sneeker Yeh
 
Introduction to netlink in linux kernel (english)
Introduction to netlink in linux kernel (english)Introduction to netlink in linux kernel (english)
Introduction to netlink in linux kernel (english)Sneeker Yeh
 
Dead Lock Analysis of spin_lock() in Linux Kernel (english)
Dead Lock Analysis of spin_lock() in Linux Kernel (english)Dead Lock Analysis of spin_lock() in Linux Kernel (english)
Dead Lock Analysis of spin_lock() in Linux Kernel (english)Sneeker Yeh
 
Introduction to synchronous display controller (chinese)
Introduction to synchronous display controller (chinese)Introduction to synchronous display controller (chinese)
Introduction to synchronous display controller (chinese)Sneeker Yeh
 
Bootloader and MMU (english)
Bootloader and MMU (english)Bootloader and MMU (english)
Bootloader and MMU (english)Sneeker Yeh
 
The Next Generation of Flash User Experience
The Next Generation of Flash User ExperienceThe Next Generation of Flash User Experience
The Next Generation of Flash User ExperienceKevin Suttle
 
Economic impact of tourism
Economic impact of tourismEconomic impact of tourism
Economic impact of tourismEman Abbas
 

Destacado (10)

Introduction to SPI and PMIC with SPI interface (chinese)
Introduction to SPI and PMIC with SPI interface (chinese)Introduction to SPI and PMIC with SPI interface (chinese)
Introduction to SPI and PMIC with SPI interface (chinese)
 
Concurrency bug identification through kernel panic log (english)
Concurrency bug identification through kernel panic log (english)Concurrency bug identification through kernel panic log (english)
Concurrency bug identification through kernel panic log (english)
 
Basic Concept of Pixel and MPEG data structure (english)
Basic Concept of Pixel and MPEG data structure (english)Basic Concept of Pixel and MPEG data structure (english)
Basic Concept of Pixel and MPEG data structure (english)
 
Introduction to netlink in linux kernel (english)
Introduction to netlink in linux kernel (english)Introduction to netlink in linux kernel (english)
Introduction to netlink in linux kernel (english)
 
Dead Lock Analysis of spin_lock() in Linux Kernel (english)
Dead Lock Analysis of spin_lock() in Linux Kernel (english)Dead Lock Analysis of spin_lock() in Linux Kernel (english)
Dead Lock Analysis of spin_lock() in Linux Kernel (english)
 
Srdf Vs Dataguard
Srdf Vs DataguardSrdf Vs Dataguard
Srdf Vs Dataguard
 
Introduction to synchronous display controller (chinese)
Introduction to synchronous display controller (chinese)Introduction to synchronous display controller (chinese)
Introduction to synchronous display controller (chinese)
 
Bootloader and MMU (english)
Bootloader and MMU (english)Bootloader and MMU (english)
Bootloader and MMU (english)
 
The Next Generation of Flash User Experience
The Next Generation of Flash User ExperienceThe Next Generation of Flash User Experience
The Next Generation of Flash User Experience
 
Economic impact of tourism
Economic impact of tourismEconomic impact of tourism
Economic impact of tourism
 

Similar a Introduction to Nand Flash interface (chinese)

S1: InnoDB AIO原理及相关bug分析
S1: InnoDB AIO原理及相关bug分析S1: InnoDB AIO原理及相关bug分析
S1: InnoDB AIO原理及相关bug分析Hui Liu
 
高性能队列Fqueue的设计和使用实践
高性能队列Fqueue的设计和使用实践高性能队列Fqueue的设计和使用实践
高性能队列Fqueue的设计和使用实践孙立
 
鳥哥三到六章
鳥哥三到六章鳥哥三到六章
鳥哥三到六章Edward Yi
 
Install Oracle11g For Aix 5 L
Install Oracle11g For Aix 5 LInstall Oracle11g For Aix 5 L
Install Oracle11g For Aix 5 Lheima911
 
为啥别读HotSpot VM的源码(2012-03-03)
为啥别读HotSpot VM的源码(2012-03-03)为啥别读HotSpot VM的源码(2012-03-03)
为啥别读HotSpot VM的源码(2012-03-03)Kris Mok
 
嵌入式平台移植技巧概說
嵌入式平台移植技巧概說嵌入式平台移植技巧概說
嵌入式平台移植技巧概說Joseph Lu
 
2, OCP - installing and creating a database
2, OCP - installing and creating a database2, OCP - installing and creating a database
2, OCP - installing and creating a databaseted-xu
 
Linux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeLinux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeAngel Boy
 
系統程式 -- 第 11 章 嵌入式系統
系統程式 -- 第 11 章 嵌入式系統系統程式 -- 第 11 章 嵌入式系統
系統程式 -- 第 11 章 嵌入式系統鍾誠 陳鍾誠
 
基于Symfony框架下的快速企业级应用开发
基于Symfony框架下的快速企业级应用开发基于Symfony框架下的快速企业级应用开发
基于Symfony框架下的快速企业级应用开发mysqlops
 
优酷 Web网站架构案例分析
优酷   Web网站架构案例分析优酷   Web网站架构案例分析
优酷 Web网站架构案例分析George Ang
 
Youku arch qcon2009_beijing
Youku arch qcon2009_beijingYouku arch qcon2009_beijing
Youku arch qcon2009_beijingdrewz lin
 
Key value store
Key value storeKey value store
Key value storexuanhan863
 
Au698 x mp user's manual chinese
Au698 x mp user's manual chineseAu698 x mp user's manual chinese
Au698 x mp user's manual chineseod1ner
 
诗檀软件 Oracle开发优化基础
诗檀软件 Oracle开发优化基础 诗檀软件 Oracle开发优化基础
诗檀软件 Oracle开发优化基础 maclean liu
 
分布式系统缓存设计
分布式系统缓存设计分布式系统缓存设计
分布式系统缓存设计zhujiadun
 

Similar a Introduction to Nand Flash interface (chinese) (20)

S1: InnoDB AIO原理及相关bug分析
S1: InnoDB AIO原理及相关bug分析S1: InnoDB AIO原理及相关bug分析
S1: InnoDB AIO原理及相关bug分析
 
高性能队列Fqueue的设计和使用实践
高性能队列Fqueue的设计和使用实践高性能队列Fqueue的设计和使用实践
高性能队列Fqueue的设计和使用实践
 
鳥哥三到六章
鳥哥三到六章鳥哥三到六章
鳥哥三到六章
 
Install Oracle11g For Aix 5 L
Install Oracle11g For Aix 5 LInstall Oracle11g For Aix 5 L
Install Oracle11g For Aix 5 L
 
为啥别读HotSpot VM的源码(2012-03-03)
为啥别读HotSpot VM的源码(2012-03-03)为啥别读HotSpot VM的源码(2012-03-03)
为啥别读HotSpot VM的源码(2012-03-03)
 
嵌入式平台移植技巧概說
嵌入式平台移植技巧概說嵌入式平台移植技巧概說
嵌入式平台移植技巧概說
 
2, OCP - installing and creating a database
2, OCP - installing and creating a database2, OCP - installing and creating a database
2, OCP - installing and creating a database
 
SCJP ch16
SCJP ch16SCJP ch16
SCJP ch16
 
Something about Kafka - Why Kafka is so fast
Something about Kafka - Why Kafka is so fastSomething about Kafka - Why Kafka is so fast
Something about Kafka - Why Kafka is so fast
 
Linux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeLinux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledge
 
系統程式 -- 第 11 章 嵌入式系統
系統程式 -- 第 11 章 嵌入式系統系統程式 -- 第 11 章 嵌入式系統
系統程式 -- 第 11 章 嵌入式系統
 
基于Symfony框架下的快速企业级应用开发
基于Symfony框架下的快速企业级应用开发基于Symfony框架下的快速企业级应用开发
基于Symfony框架下的快速企业级应用开发
 
优酷 Web网站架构案例分析
优酷   Web网站架构案例分析优酷   Web网站架构案例分析
优酷 Web网站架构案例分析
 
Youku arch qcon2009_beijing
Youku arch qcon2009_beijingYouku arch qcon2009_beijing
Youku arch qcon2009_beijing
 
Key value store
Key value storeKey value store
Key value store
 
Au698 x mp user's manual chinese
Au698 x mp user's manual chineseAu698 x mp user's manual chinese
Au698 x mp user's manual chinese
 
诗檀软件 Oracle开发优化基础
诗檀软件 Oracle开发优化基础 诗檀软件 Oracle开发优化基础
诗檀软件 Oracle开发优化基础
 
分布式系统缓存设计
分布式系统缓存设计分布式系统缓存设计
分布式系统缓存设计
 
SMACK Dev Experience
SMACK Dev ExperienceSMACK Dev Experience
SMACK Dev Experience
 
2016 nas 年會簡報
2016 nas 年會簡報2016 nas 年會簡報
2016 nas 年會簡報
 

Introduction to Nand Flash interface (chinese)

  • 1. Nand Flash InterfaceNand Flash Interface Represented by Sneeker Yeh 2010 March.
  • 2. OutlineOutline • Introduction • Nandflash operation • WinCE image layout • Case study 1 • Case study 2
  • 3. IntroductionIntroduction • 下圖為下圖為 nand flashnand flash 的範例的範例 (K9F2G08X0A)(K9F2G08X0A) • I/OI/O 腳位不只可將資料腳位不只可將資料 input or output,input or output, 也可以也可以 inputinput 命令與位址命令與位址 .. • 若若 flashflash 結構為結構為 1616 位元位元 (16(16 支支 I/OI/O 腳)腳) ,, 資料的運輸則以資料的運輸則以 1616 位元為位元為 單位單位 ,, 命令與位址則仍然維持八位元的形式命令與位址則仍然維持八位元的形式 (( 似乎是約定俗成的規則似乎是約定俗成的規則 ))
  • 4. IntroductionIntroduction • 將一筆資料寫入將一筆資料寫入 nand flashnand flash 的時序圖的時序圖 • 信號的信號的 pulse widthpulse width 由由 controllercontroller 來管理來管理 , programmer, programmer 只需準備只需準備 命令命令 ,, 位址資訊位址資訊 ,, 資料資料 , controller, controller 會將這些訊息有條不紊地輸入到會將這些訊息有條不紊地輸入到 nand flash.nand flash. • programmerprogrammer 只需注意每個命令與定址資訊的間隔只需注意每個命令與定址資訊的間隔 ,, 會由專屬的會由專屬的 status regstatus reg 或發出中斷兩種方法來表示或發出中斷兩種方法來表示 ,, 等到該等到該 operationoperation 完成後完成後 ,, 才能繼續操作才能繼續操作 controllercontroller 執行下一步動作執行下一步動作
  • 5. IntroductionIntroduction 控制器會在 I/O 上寫 ”入 00h ”讀取命令 並控制 CLE, WE, CE, ALE, RE 來 ”表示該操作為 input command” Programmer 要注意該 操作是否結束 ( 輪詢狀態 暫存器或中斷發生 ), 才 能進行下個操作
  • 6. Nandflash operationNandflash operation Buffer[0]Buffer[0] (512 bytes)(512 bytes) Buffer[1]Buffer[1] (512 bytes)(512 bytes) Buffer[2]Buffer[2] (512 bytes)(512 bytes) Buffer[3]Buffer[3] (512 bytes)(512 bytes) Spare_buf[0]Spare_buf[0] (16 bytes)(16 bytes) Spare_buf[1]Spare_buf[1] (16 bytes)(16 bytes) Spare_buf[2]Spare_buf[2] (16 bytes)(16 bytes) Spare_buf[3]Spare_buf[3] (16 bytes)(16 bytes) Page 4Page 4 Page 5Page 5 Nand flash iMX31 controller buffer Page read
  • 7. Nandflash operationNandflash operation • Nand flashNand flash 的寫入與讀取規則皆必須以一個的寫入與讀取規則皆必須以一個 pagepage 為為 單位單位 • 然而寫入動作必須有額外的遊戲規則然而寫入動作必須有額外的遊戲規則 ,, 要寫入的區域要寫入的區域 其內容必須皆為其內容必須皆為 0xff.0xff. • Write 1 on 1 -> 1Write 1 on 1 -> 1 • Write 0 on 1 -> 0Write 0 on 1 -> 0 • Write 1 on 0 -> 0Write 1 on 0 -> 0 • Write 0 on 0 -> 0Write 0 on 0 -> 0 • Nand flashNand flash 提供了提供了 erase commanderase command 讓讓 programmerprogrammer 可以將內容轉變為可以將內容轉變為 0xff, erase0xff, erase 的單位的單位
  • 8. 0xffffffff0xffffffff 0xffffffff0xffffffff 0xffffffff0xffffffff 0xffffffff0xffffffff 0xffffffff0xffffffff 0xffffffff0xffffffff 0xffffffff0xffffffff 0xffffffff0xffffffff Nandflash operationNandflash operation Buffer[0]Buffer[0] (512 bytes)(512 bytes) Buffer[1]Buffer[1] (512 bytes)(512 bytes) Buffer[2]Buffer[2] (512 bytes)(512 bytes) Buffer[3]Buffer[3] (512 bytes)(512 bytes) Spare_buf[0]Spare_buf[0] (16 bytes)(16 bytes) Spare_buf[1]Spare_buf[1] (16 bytes)(16 bytes) Spare_buf[2]Spare_buf[2] (16 bytes)(16 bytes) Spare_buf[3]Spare_buf[3] (16 bytes)(16 bytes) 0xaaaaaaaa0xaaaaaaaa Nand flash iMX31 controller buffer Page 的寫入前 如果不確定是不 是 0xff, 要記得 先操除 (erase) 喔 Block 0
  • 9. Case study 1 : GarbageCase study 1 : Garbage Collection – 1/3Collection – 1/3 File 1 File 1 File 3 File 3 File 3 File 2 File 3 (new) File 3 (new) File 3 (new) Invalid Invalid Invalid File 4 Invalid Invalid Invalid Block 0 Block 1 Block 2 Block 3 • 原由原由 :read/write:read/write 與與 eraseerase 的單位是不一樣的的單位是不一樣的 .. • 因此在資料讀寫的操作上會有因此在資料讀寫的操作上會有 invalid pageinvalid page 的觀念的觀念 ,, 若要將一筆資料刪除若要將一筆資料刪除 ,, 只只 要在記憶體準備一個要在記憶體準備一個 tabletable 並將資料所佔用的並將資料所佔用的 page markpage mark 成成 invalidinvalid 即可即可 .. • 若要將一筆資料如若要將一筆資料如 file 3file 3 更新更新 flash,flash, 只要尋找足夠的只要尋找足夠的 free pagefree page 寫入寫入 ,, 再將舊再將舊 的的 file 3file 3 區域區域 markmark 成成 invalidinvalid 即可即可 ,, 過程只需耗費過程只需耗費 33 個個 page writepage write 動作動作 .. • 若沒有若沒有 tabletable 機制機制 ,, 則必須先搬移出則必須先搬移出 file2(1*read),file2(1*read), 將將 block2block2 擦除擦除 (1*erase),(1*erase), 將將 file2file2 及新的及新的 file3file3 寫入寫入 (4*write):(4*write): • WriteWrite 操作比原先的機制還多了一次操作比原先的機制還多了一次 (write(write 是最耗時間的動作是最耗時間的動作 ))
  • 10. File 5 File 5 File 5 File 5Invalid Case study 1 : GarbageCase study 1 : Garbage Collection – 2/3Collection – 2/3 • 接續上一個接續上一個 scenario,scenario, 若要寫入一個若要寫入一個 4page4page 大小的大小的 file5:file5: • 執行執行 garbage collection:garbage collection: 搬移搬移 file4file4 到到 block3(1*read,1*write),block3(1*read,1*write), 擦除擦除 block0(1*erase).block0(1*erase). • 將將 file5file5 寫入寫入 block0(4*write).block0(4*write). File 1 File 1 File 2 File 3 (new) File 3 (new) File 3 (new) Invalid Invalid Invalid File 4 Invalid Invalid Invalid Block 0 Block 1 Block 2 Block 3 File 4
  • 11. Case study 1 : GarbageCase study 1 : Garbage Collection - 3/3Collection - 3/3 • Garbage collectionGarbage collection 的演算法的演算法 issue:issue: • garbage collectiongarbage collection 是很耗費時間是很耗費時間 .. • 如何如何 mergemerge 出一個出一個 total freetotal free 的的 block(block( 盡量要有效率且不要有太盡量要有效率且不要有太 多的碎裂情形多的碎裂情形 , for ex,, for ex, 將將 file4file4 搬至搬至 block1block1 碎裂情形較嚴重碎裂情形較嚴重 ).). File 1 File 1 File 2 File 3 (new) File 3 (new) File 3 (new) Invalid Invalid Invalid File 4 Invalid Invalid Invalid Block 0 Block 1 Block 2 Block 3
  • 12. Case study 2 :Case study 2 : 模擬燒錄器模擬燒錄器 –的寫入與讀取 –的寫入與讀取 1/51/5 • 模擬燒錄器的寫入與讀取模擬燒錄器的寫入與讀取 :: • 在在 iMX31 controlleriMX31 controller 具備硬體具備硬體 eccecc 產生產生 ,, 硬體硬體 eccecc 偵錯偵錯 ,, 硬體硬體 eccecc 更正能力更正能力 ,, 因此在操作上會帶來一些限制:因此在操作上會帶來一些限制: • 在在 spare area bufferspare area buffer 有預留一塊有預留一塊 ecc codeecc code 區域區域 ,, programmerprogrammer 所寫入的值將會被硬體忽略所寫入的值將會被硬體忽略 ,, 因為硬體會自動產生因為硬體會自動產生 偵錯所需的偵錯所需的 ecc codeecc code 寫入對應的寫入對應的 spare area.spare area. • 當硬體讀取一個當硬體讀取一個 pagepage 時時 ,, 並不會將並不會將 ecc codeecc code 放置對應的放置對應的 spare area buffer,spare area buffer, 而且讀入其他邏輯電路並且執行錯誤偵測與而且讀入其他邏輯電路並且執行錯誤偵測與 更正更正 ..
  • 13. –模擬燒錄器的寫入 –模擬燒錄器的寫入 2/52/5 • 因此在預設情況下因此在預設情況下 ,, 一個一個 pagepage 的的 2112 bytes2112 bytes 中中 ,, 有少許作為有少許作為 eccecc 存存 放的區域是無法讓放的區域是無法讓 programmerprogrammer 寫值進去的寫值進去的 :: • 然而然而 ,, 若我們擁有若我們擁有 raw image (raw image ( 包含所有包含所有 spare area, include ecc),spare area, include ecc), 並且我們想要將模擬燒錄器燒錄並且我們想要將模擬燒錄器燒錄 nandflashnandflash 行為行為 ,, 將整個將整個 imageimage 燒入燒入 flash:flash: • 我們可以設定我們可以設定 controllercontroller 為為 ecc disable,ecc disable, 則此時則此時 spare areaspare area bufferbuffer 的的 eccecc 區域則可以讓區域則可以讓 programmerprogrammer 自由運用自由運用 ,, 並進而寫值並進而寫值 .. • 此時我們可以完全對此時我們可以完全對 pagepage 中所有的中所有的 2112 bytes2112 bytes 寫進所需要的值寫進所需要的值 ..
  • 14. –模擬燒錄器的讀取 –模擬燒錄器的讀取 3/53/5 • iMX31 controlleriMX31 controller 的缺陷的缺陷 :: • 即使即使 disable ecc,disable ecc, 則硬體在讀取則硬體在讀取 pagepage 時時 ,, 仍會將仍會將 ecc codeecc code 讀入讀入 其他邏輯電路並且執行錯誤偵測其他邏輯電路並且執行錯誤偵測 ,, 並不會將並不會將 ecc codeecc code 放置對應的放置對應的 spare area buffer(spare area buffer( 此時此時 disabledisable 的是更正能力的是更正能力 ).). • 所以我們必須要有額外的策略將所以我們必須要有額外的策略將 pagepage 中所有的中所有的 2112byte2112byte 讀取出來讀取出來 ,, 否則我們無法製作出燒錄器所需要的否則我們無法製作出燒錄器所需要的 raw data.raw data.
  • 15. –模擬燒錄器的讀取 –模擬燒錄器的讀取 4/54/5 • ControllerController 對對 nand flashnand flash 上上 pagepage 的觀點的觀點 ,, 每每 512byte512byte 伴隨一段伴隨一段 64byte64byte 的的 spare area(ecc, and other metadata).spare area(ecc, and other metadata). • controllercontroller 會進行四次會進行四次 get dataget data 的動作的動作 (( 每次抓取每次抓取 528bytes),528bytes), 才可以完成一次才可以完成一次 pagepage 的讀取的讀取 Buffer[0]Buffer[0] (512 bytes)(512 bytes) Buffer[1]Buffer[1] (512 bytes)(512 bytes) Buffer[2]Buffer[2] (512 bytes)(512 bytes) Buffer[3]Buffer[3] (512 bytes)(512 bytes) Spare_buf[0]Spare_buf[0] (16 bytes)(16 bytes) Spare_buf[1]Spare_buf[1] (16 bytes)(16 bytes) Spare_buf[2]Spare_buf[2] (16 bytes)(16 bytes) Spare_buf[3]Spare_buf[3] (16 bytes)(16 bytes) Buffer[0]Buffer[0] (512 bytes)(512 bytes) Buffer[1]Buffer[1] (512 bytes)(512 bytes) Buffer[2]Buffer[2] (512 bytes)(512 bytes) Buffer[3]Buffer[3] (512 bytes)(512 bytes) Spare_buf[0]Spare_buf[0] (16 bytes)(16 bytes) Spare_buf[1]Spare_buf[1] (16 bytes)(16 bytes) Spare_buf[2]Spare_buf[2] (16 bytes)(16 bytes) Spare_buf[3]Spare_buf[3] (16 bytes)(16 bytes) Controller buffer Nand flash structure
  • 16. –模擬燒錄器的讀取 –模擬燒錄器的讀取 5/55/5 • 我們可以將四次我們可以將四次 get dataget data ” ”的動作之間加入 定址 操作” ”的動作之間加入 定址 操作 ,, 在加上最後一次在加上最後一次 get data(get data( 只有只有 64bytes,64bytes, 其餘忽略其餘忽略 )) Buffer[0]Buffer[0] (512 bytes)(512 bytes) Spare_buf[0]Spare_buf[0] (16 bytes)(16 bytes) Buffer[0]Buffer[0] (512 bytes)(512 bytes) Buffer[1]Buffer[1] (512 bytes)(512 bytes) Buffer[2]Buffer[2] (512 bytes)(512 bytes) Buffer[3]Buffer[3] (512 bytes)(512 bytes) Spare_buf[0]Spare_buf[0] (16 bytes)(16 bytes) Spare_buf[1]Spare_buf[1] (16 bytes)(16 bytes) Spare_buf[2]Spare_buf[2] (16 bytes)(16 bytes) Spare_buf[3]Spare_buf[3] (16 bytes)(16 bytes) Controller buffer Nand flash structure Operation1: 1.Disable ecc 2.Column=0 3.Get 528 byte Operation2: 1.Column=51 2 2.Get 528 byte Operation3: 1.Column=1024 2.Get 528 byte Operation4: 1.Column=15 36 2.Get 528 byteOperation5: 1.Column=2048 2.Get 528 byte 3.Ignore bytes after 64th byte in main buffer