硬件原理及分析

管脚说明

 
 

 
 

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驱动的更多相关文章

  1. Smart210学习记录----nand flash驱动

    [详解]如何编写Linux下Nand Flash驱动  :http://www.cnblogs.com/linux-rookie/articles/3016990.html 当读写文件请求到来的时候, ...

  2. Nand Flash驱动(实现初始化以及读操作)

    简单制作一个Nand Flash驱动(只需要初始化Flash以及读Flash) 打开2440芯片手册,K9F2G08U0M芯片手册(因为2440中Nand Flash是用的256MB(2Gb)内存,8 ...

  3. linux2.6.30.4内核移植(2)——Nand Flash驱动移植

    内核源码:linux2.6.30.4 交叉编译工具:3.4.5 移植linux内核至:TQ2440 工作基础:http://www.cnblogs.com/nufangrensheng/p/36696 ...

  4. linux下Pl353 NAND Flash驱动分析

    linux的NAND Flash驱动位于drivers/mtd/nand子文件夹下: nand_base.c-->定义通用的nand flash基本操作函数,如读写page,可自己重写这些函数 ...

  5. NAND FLASH 驱动分析

    NAND FLASH是一个存储芯片 那么: 这样的操作很合理"读地址A的数据,把数据B写到地址A" 问1. 原理图上NAND FLASH和S3C2440之间只有数据线,       ...

  6. 如何编写linux下nand flash驱动-2

    [Nand Flash引脚(Pin)的说明] 图3.Nand Flash引脚功能说明 上图是常见的Nand Flash所拥有的引脚(Pin)所对应的功能,简单翻译如下: 1.       I/O0 ~ ...

  7. 如何编写linux下nand flash驱动-4

    2.       软件方面 如果想要在Linux下编写Nand Flash驱动,那么就先要搞清楚Linux下,关于此部分的整个框架.弄明白,系统是如何管理你的nand flash的,以及,系统都帮你做 ...

  8. 15.1 linux操作系统下nand flash驱动框架2

    当我们需要在操作系统上读写普通文件的时候,总是需要一层层往下,最终到达硬件相关操作,当然底层设备大多数都是块设备 NAND FLASH就作为一个最底层的块设备. 而写驱动,就是要构建硬件与操作系统之间 ...

  9. 十八、Nand Flash驱动和Nor Flash驱动

    在读者学习本章之前,最好了解Nand Flash读写过程和操作,可以参考:Nand Flash裸机操作. 一开始想在本章写eMMC框架和设备驱动,但是没有找到关于eMMC设备驱动具体写法,所以本章仍继 ...

  10. Linux 下 Nand Flash 驱动说明

    注册 driver_register 通过 module_init(s3c2410_nand_init);注册 Nand Flash 驱动. 在 s3c2410_nand_init ()中通过 dri ...

随机推荐

  1. 三大JavaScript框架对比——AngularJS、BackboneJS和EmberJS

    <三大JavaScript框架对比——AngularJS.BackboneJS和EmberJS> 本文转载自  作者:chszs,博客主页:http://blog.csdn.net/chs ...

  2. Python 基础之字符串操作,函数及格式化format

    一.字符串的相关操作 1.字符串的拼接 + strvar1 = "我爱你,"strvar2 = "亲爱的姑凉"res = strvar1 + strvar2pr ...

  3. 141、Java内部类之实例化外部类对象

    01. 代码如下: package TIANPAN; class Outer { // 外部类 private static String msg = "Hello World !" ...

  4. Pytorch model saving and loading 模型保存和读取

    It is really useful to save and reload the model and its parameters during or after training in deep ...

  5. .net设计模式

    1.单例模式 public sealed class Singleton { static intance=null; static readonly object padlock=new objec ...

  6. easyui 加载本地json 文件的方法

    easyui 加载本地json 文件的方法 2017年12月15日 17:18:07 vivian_hnd 阅读数 2155 https://blog.csdn.net/vivian_wang07/a ...

  7. AndroidQ强势来袭,国产自研系统还有未来吗?

    我的小米8在重启时,屏幕上总会出现那句让人印象深刻的话--"Powered by android".事实上,几乎所有Android手机都会出现这几个单词--国产智能手机也不例外.这 ...

  8. JS截取腾讯视频和去除视频广告

    一:腾讯视频截取 H5视频播放除了video标签以外,还有iframe嵌套视频 项目需求是用户输入腾讯视频的html链接,如 https://v.qq.com/x/page/y0116k2vspw.h ...

  9. Day9 - G - Doing Homework HDU - 1074

    有n个任务,每个任务有一个截止时间,超过截止时间一天,要扣一个分.求如何安排任务,使得扣的分数最少.Input有多组测试数据.第一行一个整数表示测试数据的组数第一行一个整数n(1<=n<= ...

  10. Day3-B-Round Marriage CodeForces-981F

    It's marriage season in Ringland! Ringland has a form of a circle's boundary of length LL. There are ...