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 ...
随机推荐
- 重新学习CSS,认识CSS3中的属性
之前学css,觉得会改个样式就不错了,直到现在,在做前端开发的时候,才发现自己的前端页面是有多垃圾,而且还不知道该怎么适应各个浏览器,总是很“词穷”,最近是想着好久没去慕课上面了,于是就报着逛一逛的心 ...
- 杭电2014 (第一次用vector ac题目)
早就想用容器类来实现一些编程,今天也算是学了一点吧. vector的使用方法参考了某位博主的一篇文章,感觉写得还是不错的:http://blog.csdn.net/always2015/article ...
- 使用myeclipse搭建简单的maven工程
请点击或者复制以下链接 http://opiece.me/2016/03/17/maven-and-ssmframework/
- 「BOI2007」Mokia
「BOI2007」Mokia 传送门 把查询拆成四部分然后容斥计算答案(二维前缀和) 然后 \(\text{CDQ}\) 分治算答案. 参考代码: #include <algorithm> ...
- Lamda表达式学习笔记一
Lamda表达式学习笔记一 一.Lamda语法诠释 三傻大闹宝莱坞的主人公兰彻说的一句话让我映像深刻:用简单的语言来表达同样的意 我并不是说书上的定义怎么怎么不对,而是应该理解书本上的定义,并用简单的 ...
- java实现经典排序算法
前言 博主最近在恶补基础知识,算法必然是必不可少的,那么就从经典排序算法开始吧!(图源网络,侵删),没有列出全部,因为在期末考试囧 代码太多,就只显示了最关键的部分 1. 冒泡排序 实现思路: (1) ...
- 洛谷 P3320 [SDOI2015]寻宝游戏
因为寻宝路径是一个环,所以寻宝花费的最小时间与起点无关.宝应当按照所有宝藏所在位置的 dfs 序进行才能够使得花费的时间最短.设 \(dist_i\) 表示 \(i\) 到树根的最短距离,那么树上任意 ...
- 【剑指Offer面试编程题】题目1389:变态跳台阶--九度OJ
题目描述: 一只青蛙一次可以跳上1级台阶,也可以跳上2级--它也可以跳上n级.求该青蛙跳上一个n级的台阶总共有多少种跳法. 输入: 输入可能包含多个测试样例,对于每个测试案例, 输入包括一个整数n(1 ...
- 图片IO域 旋转画面的组态 图片是4个静止的风扇 PLC的MW6为风扇指针..
图片IO域 旋转画面的组态 图片是4个静止的风扇 PLC的MW6为风扇指针.. Plc在循环中断组织块 OB35 中 将MW6 每100ms 加1 加到4 清0 图片[MW6] MW6 是图片指针 对 ...
- CH8 IO库
8.1 #include <iostream> #include <string> #include <sstream> #include <fstream& ...