linux 内核nandsim的使用

 

If you wish to use the mtd nandsim device as a simulator for testing
yaffs, you can follow these steps:

1) Make sure you have a recent 2.6 kernel with a recent MTD tree. (If
you ask the MTD folk, they'll tell you to run the mtd patchin script
from the latest cvs version of MTD.)

2) Configure your kernel to enable the mtd nand support and nandsim
driver. Make sure that the following are set in .config:

CONFIG_MTD=m
CONFIG_MTD_CHAR=m
CONFIG_MTD_BLOCK=m
CONFIG_MTD_NAND=m
CONFIG_MTD_NAND_NANDSIM=m

You can set them to 'y' rather than 'm' if you don't want the modules
form.

3) make and install your kernel and modules in the usual way, then boot.

4) To use the nandsim, you need to load some MTD modules, unless you've
configured MTD into the kernel:

modprobe mtdblock
modprobe mtdchar
modprobe nandsim

5) Verify that the nandsim device has loaded properly:

cat /proc/mtd

You will see something like

dev: size erasesize name
mtd0: 00800000 00002000 "NAND simulator partition"

If everything went well.

6) what the nand device is called will depend on your Linux distro, and
whether you are using devfs or udev, but the '0', or whatever mtd
reports as the device associated with the simulator, in the above will
show up in the name. On my ubuntu system, if /proc/mtd reports 'mtd0'
then the block device is /dev/mtdblock0 and the char device is
/dev/mtd0.

7) You can mount yaffs on the nandsim in the usual way. I have
/mnt/nand as the directory I mount on, so I would mount using

mount -t yaffs /dev/mtdblock0 /mnt/nand
-------------------------------------


[root@urbetter /]# cd /lib/modules/2.6.28.6/extra/
[root@urbetter extra]# ls
chr_dev.ko  nandsim.ko  test.ko     text        usr_app
[root@urbetter extra]# insmod nandsim.ko
NAND device: Manufacturer ID: 0x98, Chip ID: 0x39 (Toshiba NAND 128MiB 1,8V 8-bit)
flash size: 128 MiB
page size: 512 bytes
OOB area size: 16 bytes
sector size: 16 KiB
pages number: 262144
pages per sector: 32
bus width: 8
bits in sector size: 14
bits in page size: 9
bits in OOB size: 4
flash size with OOB: 135168 KiB
page address bytes: 4
sector address bytes: 3
options: 0x62
Scanning device for bad blocks
Creating 1 MTD partitions on "NAND 128MiB 1,8V 8-bit":
0x00000000-0x08000000 : "NAND simulator partition 0"
[root@urbetter extra]# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00040000 00020000 "Bootloader"
mtd1: 003c0000 00020000 "Kernel"
mtd2: 05000000 00020000 "Rootfs"
mtd3: 0ac00000 00020000 "File System"
mtd4: 08000000 00004000 "NAND simulator partition 0"
[root@urbetter extra]# ls /dev/mtd
/dev/mtd0       /dev/mtd1ro     /dev/mtd3       /dev/mtd4ro     /dev/mtdblock2
/dev/mtd0ro     /dev/mtd2       /dev/mtd3ro     /dev/mtdblock0  /dev/mtdblock3
/dev/mtd1       /dev/mtd2ro     /dev/mtd4       /dev/mtdblock1  /dev/mtdblock4
[root@urbetter extra]# ls /dev/mtd4 /dev/mtdblock4 -l
crw-rw----    1 root     root      90,   8 Jan  2 06:39 /dev/mtd4
brw-rw----    1 root     root      31,   4 Jan  2 06:39 /dev/mtdblock4

[root@urbetter extra]# ls
chr_dev.ko  nandsim.ko  test.ko     text        usr_app
[root@urbetter extra]# mkdir test

[root@urbetter extra]# mount /dev/mtdblock4 test
yaffs: dev is 32505860 name is "mtdblock4"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.4, "mtdblock4"
yaffs_read_super: isCheckpointed 0

[root@urbetter extra]# cd test
[root@urbetter test]# ls
lost+found
[root@urbetter test]# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 9.4G      6.6G      2.3G  74% /
tmpfs                    34.8M         0     34.8M   0% /dev/shm
/dev/mtdblock3          172.0M      1.1M    170.9M   1% /mnt/disk
/dev/mtdblock4          128.0M     96.0K    127.9M   0% /lib/modules/2.6.28.6/extra/test

转载于:https://www.cnblogs.com/jiffies/archive/2012/11/01/2749818.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值