码迷,mamicode.com
首页 > 其他好文 > 详细

About Flash

时间:2015-05-11 17:40:15      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:

Take SAMSUNG K9F1G08U0E for example, and use S3C2416, Windows CE5.0 platform.

 

要让Flash工作起来,包括两部分: Flash器件控制和CPU端的Flash控制器。Flash端一般只要把相应的脚位和CPU端连起来就可以通过CPU端的相应控制寄存器对Flash设备进行控制读写数据了。当然也有一部分CPU是不带Flash控制器的,这种情况下就要根据Flash的操作时序等进行控制了。  

技术分享

 技术分享

 

[1]Flash工作准备

  1.确认硬件连接正常

  2.确认供电正常

  3.根据Flash手册的时序要求进行控制。控制都是通过对CPU的Flash控制寄存器设置实现的,所以控制Flash实际都是操作S3C2416的Flash寄存器。

  4.配置CPU的Flash控制寄存器,特别要注意的是CPU里面有几个寄存器位对Flash的运行时序是有很大关联的,分别是TACLS,TWRPH0,TWRPH1。

 

 

 

 

 

[2]Flash的结构组织:

  技术分享

   由Figure2可以知道,一个K9F1G08U0E设备有1024个Block(块),1024*64个page(页),1024*64*(2048+64)Byte。

  其中每页里面有分2048Byte的数据存储main区和64Byte额外信息spare区,额外的信息包括保留区/系统分区信息/ECC校验/坏块标识等,这个spare区的信息是自定义排列的,但是读写的时候一定要对应,三星里面一般会如下定义:

  技术分享

  column address:称列地址,也称页内偏移地址, flash通过 8 bit I/O进行传输,一个地址位传输1个Byte数据, 一页有 (2K+64)Byte=2112Byte,2112(D)Byte=1000‘ 0100‘ 0000(B)Byte,这需要12 bit的地址位. 见上图的A0~A11。

  row address:行地址,也称页地址,1个设备=1024 block=1024*64 page=65536(D) page=1‘ 0000‘ 0000‘ 000‘ 0000(B)page,这需要16 bit的地址位,见上图的A12~A27。

  

  一个擦除的块数据:  

技术分享
Enter Block #: 1023
Enter Page # : 
 rlst : 0xffc0
FMD::FMD_LB_ReadSector 0xffc0 
============================================
 0x000 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x010 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x020 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x030 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x040 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x050 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x060 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x070 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x080 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x090 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x0a0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x0b0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x0c0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x0d0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x0e0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x0f0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x100 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x110 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x120 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x130 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x140 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x150 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x160 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x170 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x180 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x190 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x1a0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x1b0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x1c0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x1d0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x1e0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x1f0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ------------------------------------------------------- 
 0x200 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x210 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x220 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x230 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x240 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x250 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x260 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x270 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x280 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x290 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x2a0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x2b0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x2c0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x2d0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x2e0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x2f0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x300 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x310 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x320 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x330 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x340 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x350 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x360 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x370 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x380 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x390 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x3a0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x3b0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x3c0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x3d0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x3e0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x3f0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ------------------------------------------------------- 
 0x400 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x410 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x420 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x430 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x440 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x450 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x460 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x470 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x480 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x490 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x4a0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x4b0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x4c0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x4d0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x4e0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x4f0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x500 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x510 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x520 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x530 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x540 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x550 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x560 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x570 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x580 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x590 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x5a0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x5b0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x5c0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x5d0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x5e0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x5f0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ------------------------------------------------------- 
 0x600 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x610 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x620 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x630 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x640 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x650 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x660 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x670 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x680 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x690 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x6a0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x6b0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x6c0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x6d0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x6e0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x6f0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x700 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x710 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x720 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x730 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x740 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x750 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x760 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x770 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x780 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x790 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x7a0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x7b0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x7c0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x7d0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x7e0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 0x7f0 | ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ------------------------------------------------------- 
 0x000 | ff ff ff ff ff ff ff ff 00 00 00 00 00 00 00 00
 0x010 | 00 00 00 00 00 00 00 00 e2 63 01 ea 00 00 00 00
 0x020 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0x030 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
============================================

//前面的0x000~0x7ff地址为0~2047,大小为2048Byte,是main区数据,擦除完之后全部为0xff,因为Flash只能从1变化0,不能从0变为1

//后面的0x000~0x03f数据为别为:
[1Byte] BadBlock
[4Byte] Reserved1
[1Byte] OEMReserved
[2Byte] Reserved2

[4Byte] MECC0
[4Byte] MECC1
[4Byte] MECC2
[4Byte] MECC3

[4Byte] SECC
View Code

 

 

[3] 硬件连接:

  技术分享

   技术分享

 

[4]Flash操作流程

  Flash的操作命令:

  技术分享

  1.

 

 

[5]S3C2416CPU的Flash控制寄存器的操作

  1.关于TACLS,TWRPH0,TWRPH1,直接上图:

    技术分享

技术分享

    TACLS是Flash写命令使能和写地址使能的建立时间(setup time),TWRPH0是读/写使能的建立时间,TWRPH1是读/写的有效时间(hold time).设置的寄存器NFCONF如下:

    技术分享

    本系统所用的HCLK=FCLK/3=400M/3,HCLK=1/(400M/3)=7.5ns而K9F1G08U0E对这三个时间的要求如下图,

    所以TACLS为2,2*7.5ns=15>12ns,TWRPH0为1,(1+1)*7.5=15>12ns,TWRPH1为1,(1+1)*7.5=15>12ns。

    技术分享

     技术分享

 

  2.要设置的CPU寄存器:

    技术分享

 

 附录:

「1」三星Flash命名规则:

Part number description:

K 9 X XX X X X X X - X X X X X XX
  Move the cursor over the box to highlight particular section

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

About Flash

标签:

原文地址:http://www.cnblogs.com/COpener/p/3674330.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!