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 ...
随机推荐
- spring boot 整合 Camunda
官网:https://camunda.com/ 论坛:https://forum.camunda.org/ 一. 创建 spring boot 项目,添加项目依赖 <?xml version=& ...
- cin和cout输⼊输出
写再最前面:摘录于柳神的笔记: 就如同 scanf 和 printf 在 stdio.h 头⽂件中⼀样, cin 和 cout 在头⽂件 iostream ⾥⾯,看名字就知 道, io 是输⼊输出 ...
- 2月送书福利:ASP.NET Core开发实战
大家都知道我有一个公众号“恰童鞋骚年”,在公众号2020年第一天发布的推文<2020年,请让我重新介绍我自己>中,我曾说到我会在2020年中每个月为所有关注“恰童鞋骚年”公众号的童鞋们送一 ...
- MyEclipse和Eclipse中常用的快捷键
##########################快捷键分类速查########################## *******常用类********[Ctrl+O] 显示类中方法和 ...
- The way get information from mssql by using excel vba and special port
Yes, we can get information from mssql by using excel vba. But the default port of MSSQL is 1433. ...
- redis 初识与安装
一.redis介绍 redis是一个key-value存储系统.和Memcached类似,它支持存储的values类型相对更多,包括字符串.列表.哈希散列表.集合,有序集合. 这些数据类型都支持pus ...
- 用C语言写一个Helloworld_实现第一步编译运行
编写第一个hello world 创建helloworld.c // 程序头文件 #include <stdio.h> // 主入口函数 int main(int arc, char* a ...
- Python - Mro
参考 https://stackoverflow.com/questions/2010692/what-does-mro-do http://python.jobbole.com/85685/ 问题: ...
- 2020-2-18 restful的学习
1-1 restful简介及资源的介绍 restful 是什么? 本质:一种软件架构风格 核心:面向资源 解决的问题: 1. 降低开发的复杂性 2. 提高系统的可伸缩性 设计概念和 ...
- B树 VS B+树
参考:https://www.cnblogs.com/vincently/p/4526560.html