NAND Flash驱动
硬件原理及分析
管脚说明
Pin Name |
Pin Function |
R/B(RnB) |
The R/B output indicates the status of the device operation. When low, it indicates that a program, erase or random read operation is in process and returns to high state upon completion. It is an open drain output and does not float to high-z condition when the chip is deselected or when outputs are disabled. |
CLE(CLE) |
The CLE input controls the activating path for commands sent to the command register. When active high, commands are latched into the command register through the I/O ports on the rising edge of the WE signal. |
CE(nFCE) |
The CE input is the device selection control. When the device is in the Busy state, CE high is ignored, and the device does not return to standby mode in program or erase operation. |
ALE(ALE) |
The ALE input controls the activating path for address to the internal address registers. Addresses are latched on the rising edge of WE with ALE high. |
WE(nFWE) |
The WE input controls writes to the I/O port. Commands, address and data are latched on the rising edge of the WE pulse. |
RE(nFRE) |
The RE input is the serial data-out control, and when active drives the data onto the I/O bus. Data is valid tREA after the falling edge of RE which also increments the internal column address counter by one. |
I/O(LDATA0-LDATA7) |
The I/O pins are used to input command, address and data, and to output data during read operations. The I/O pins float to high-z when the chip is deselected or when the outputs are disabled. |
在U-BOOT上操作Nand Flash
NAND FLASH
S3C2440
发命令 选中芯片
CLE设为高电平 NFCMMD=命令值
在DATA0~DATA7上输出命令值
发出一个写脉冲
发地址 选中芯片 NFADDR=地址值
ALE设为高电平
在DATA0~DATA7上输出地址值
发出一个写脉冲
发数据 选中芯片 NFDATA=数据值
ALE,CLE设为低电平
在DATA0~DATA7上输出数据值
发出一个写脉冲
读数据 选中芯片 val=NFDATA
发出读脉冲
读DATA0~DATA7的数据
OpenJTAG> help md
md [.b, .w, .l] address [# of objects]
- memory display
OpenJTAG> help mw
mw [.b, .w, .l] address value [count]
- write memory
•b 1字节
•W 2字节
•l 4字节
1. 读ID
S3C2440 |
u-boot |
选中 NFCONT的bit1设为0 |
md.l 0x4E000004 1; mw.l 0x4E000004 1 |
发出命令0x90 NFCMMD=0x90 |
mw.b 0x4E000008 0x90 |
发出地址0x00 NFADDR=0x00 |
mw.b 0x4E00000C 0x00 |
读数据得到0xEC val=NFDATA |
md.b 0x4E000010 1 |
读数据得到device code val=NFDATA |
md.b 0x4E000010 1 |
退出读ID的状态 NFCMMD=0xff |
mw.b 0x4E000008 0xff |
2. 读内容: 读0地址的数据
使用UBOOT命令:
nand dump 0
Page 00000000 dump:
17 00 00 ea 14 f0 9f e5 14 f0 9f e5 14 f0 9f e5
S3C2440 |
u-boot |
选中 NFCONT的bit1设为0 |
md.l 0x4E000004 1; mw.l 0x4E000004 1 |
发出命令0x00 NFCMMD=0x00 |
mw.b 0x4E000008 0x00 |
发出地址0x00 NFADDR=0x00 |
mw.b 0x4E00000C 0x00 |
发出地址0x00 NFADDR=0x00 |
mw.b 0x4E00000C 0x00 |
发出地址0x00 NFADDR=0x00 |
mw.b 0x4E00000C 0x00 |
发出地址0x00 NFADDR=0x00 |
mw.b 0x4E00000C 0x00 |
发出地址0x00 NFADDR=0x00 |
mw.b 0x4E00000C 0x00 |
发出命令0x30 NFCMMD=0x30 |
mw.b 0x4E000008 0x30 |
读数据得到0x17 val=NFDATA |
md.b 0x4E000010 1 |
读数据得到0x00 val=NFDATA |
md.b 0x4E000010 1 |
读数据得到0x00 val=NFDATA |
md.b 0x4E000010 1 |
读数据得到0xea val=NFDATA |
md.b 0x4E000010 1 |
退出读状态 NFCMMD=0xff |
mw.b 0x4E000008 0xff |
ECC的作用
S3C2440-Nand Flash Controller Register
S3C2440-Nand Flash Memory Timing
K9F2G08U0C-Key Characteristic
K9F2G08U0C-Operation Timing
驱动程序
driver.c
1
19
24
26
29 };
47
48
52 [] .name .size .offset },
59
60 [] .name .offset .size },
65
66 [] .name .offset .size },
71
72 [] .name .offset .size },
77 };
78
79 {
81 {
83 regs_nand }
86 regs_nand }
90 }
92
93 {
95 {
97 regs_nand }
100 {
102 regs_nand }
105 }
107
108 {
110 }
112
113
114 {
117
119 nand
123 regs_nand
125 nand nand nand nand nand nand
135 clk clk_enable(clk);
139
140 regs_nand
146 regs_nand
150
151 mtd mtd mtd
156 nand_scan(mtd, );
159
160 add_mtd_partitions(mtd, nand_parts, );
162
163
167 ;
168 }
169
170 {
172 del_mtd_partitions(mtd);
173 kfree(nand);
174 kfree(mtd);
175 iounmap(regs_nand);
176 }
178
179 module_init(nand_init);
180 module_exit(nand_exit);
181 MODULE_LICENSE("GPL");
182 /******** 1 end ********/
Makefile
1
3 make -C
6 make -C rm -rf modules.order
9
10 obj-m += nand_drv.o
调试
pc-linux:
//格式化工具
tar xjf mtd-utils-05.07.23.tar.bz2
cd mtd-utils-05.07.23/util
修改Makefile:
#CROSS=arm-linux-
改为
CROSS=arm-linux-
make
cp flash_erase flash_eraseall /work/nfs_root/fs_mini/bin/
//格式化工具-----end
board-uboot:
nfs 30000000 192.168.0.103:/work/nfs_root/uImage_f
//使用NFS作为根文件系统
set bootargs console=ttySAC0 root=/dev/nfs nfsroot=192.168.0.103:/work/nfs_root/fs_mini ip=192.168.0.33:192.168.0.103:192.168.0.1:255.255.255.0::eth0:off
bootm 30000000
board-linux:
insmod nand_drv.ko
flash_eraseall /dev/mtd3 // yaffs //格式化
mount -t yaffs /dev/mtdblock3 /mnt
//挂接
NAND Flash驱动的更多相关文章
- Smart210学习记录----nand flash驱动
[详解]如何编写Linux下Nand Flash驱动 :http://www.cnblogs.com/linux-rookie/articles/3016990.html 当读写文件请求到来的时候, ...
- Nand Flash驱动(实现初始化以及读操作)
简单制作一个Nand Flash驱动(只需要初始化Flash以及读Flash) 打开2440芯片手册,K9F2G08U0M芯片手册(因为2440中Nand Flash是用的256MB(2Gb)内存,8 ...
- linux2.6.30.4内核移植(2)——Nand Flash驱动移植
内核源码:linux2.6.30.4 交叉编译工具:3.4.5 移植linux内核至:TQ2440 工作基础:http://www.cnblogs.com/nufangrensheng/p/36696 ...
- linux下Pl353 NAND Flash驱动分析
linux的NAND Flash驱动位于drivers/mtd/nand子文件夹下: nand_base.c-->定义通用的nand flash基本操作函数,如读写page,可自己重写这些函数 ...
- NAND FLASH 驱动分析
NAND FLASH是一个存储芯片 那么: 这样的操作很合理"读地址A的数据,把数据B写到地址A" 问1. 原理图上NAND FLASH和S3C2440之间只有数据线, ...
- 如何编写linux下nand flash驱动-2
[Nand Flash引脚(Pin)的说明] 图3.Nand Flash引脚功能说明 上图是常见的Nand Flash所拥有的引脚(Pin)所对应的功能,简单翻译如下: 1. I/O0 ~ ...
- 如何编写linux下nand flash驱动-4
2. 软件方面 如果想要在Linux下编写Nand Flash驱动,那么就先要搞清楚Linux下,关于此部分的整个框架.弄明白,系统是如何管理你的nand flash的,以及,系统都帮你做 ...
- 15.1 linux操作系统下nand flash驱动框架2
当我们需要在操作系统上读写普通文件的时候,总是需要一层层往下,最终到达硬件相关操作,当然底层设备大多数都是块设备 NAND FLASH就作为一个最底层的块设备. 而写驱动,就是要构建硬件与操作系统之间 ...
- 十八、Nand Flash驱动和Nor Flash驱动
在读者学习本章之前,最好了解Nand Flash读写过程和操作,可以参考:Nand Flash裸机操作. 一开始想在本章写eMMC框架和设备驱动,但是没有找到关于eMMC设备驱动具体写法,所以本章仍继 ...
- Linux 下 Nand Flash 驱动说明
注册 driver_register 通过 module_init(s3c2410_nand_init);注册 Nand Flash 驱动. 在 s3c2410_nand_init ()中通过 dri ...
随机推荐
- xcode app 在iOS13.3.1上崩掉
问题背景: 以前搞的一个项目,昨天测试还好的,今天就无法在iphone上运行了,对比了一下昨天是13.3,今天是13.3.1 其它的没有区别,只要运行就崩,根本没有办法启动. 报错提示: dyld: ...
- Springboot + redis + 注解 + 拦截器来实现接口幂等性校验
Springboot + redis + 注解 + 拦截器来实现接口幂等性校验 1. SpringBoot 整合篇 2. 手写一套迷你版HTTP服务器 3. 记住:永远不要在MySQL中使用UTF ...
- node.js是什么,node.js创建应用
简单的说 Node.js 就是运行在服务端的 JavaScript.Node.js 是一个基于Chrome JavaScript 运行时建立的一个平台.Node.js是一个事件驱动I/O服务端Java ...
- mkvirtualenv: 未找到命令的解决方法
1.升级python包管理工具pip pip install --upgrade pip 备注:当你想升级一个包的时候 `pip install --upgrade 包名` 2.python虚拟环境安 ...
- Spring @Async之一:实现异步调用示例
什么是“异步调用”? “异步调用”对应的是“同步调用”,同步调用指程序按照定义顺序依次执行,每一行程序都必须等待上一行程序执行完成之后才能执行:异步调用指程序在顺序执行时,不等待异步调用的语句返回结果 ...
- 112、Java中String类之字符串文本拆分为指定的个数
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public ...
- 你需要知道的 JavaScript 类(class)的这些知识
作者: Dmitri Pavlutin译者:前端小智来源:dmitripavlutin 点赞再看,养成习惯 本文 GitHub https://github.com/qq44924588... 上已经 ...
- 怎么样运行jar
一.制作jar文件 在制作.jar 文件之前你必须先编译好你的.java文件.假设我们的文件目录是c:javamyJavahelloHello.java 现在假设Hello.java的文件内容为: / ...
- Springboot 项目启动设置
//配置默认访问路径 并且自动打开浏览器 需要创建独立文件 @Controller public class HomeController { @RequestMapping("/ ...
- 吴裕雄--天生自然HADOOP操作实验学习笔记:单节点伪分布式安装
实验目的 了解java的安装配置 学习配置对自己节点的免密码登陆 了解hdfs的配置和相关命令 了解yarn的配置 实验原理 1.Hadoop安装 Hadoop的安装对一个初学者来说是一个很头疼的事情 ...