PC ubuntu添加yaffs2支持+nandflash模拟

来源:互联网 发布:短篇小说 知乎 编辑:程序博客网 时间:2024/06/08 06:57

http://comments.gmane.org/gmane.linux.file-systems.yaffs/3522


Setup environment

1 . Install mtd tools

sudo apt-get install mtd-utils

 

2. Install “git” tool for download

sudo apt-get install git-core

 

3. Download newest yaffs2 filesystem code

sudo git clone git://www.aleph1.co.uk/yaffs2

 

Config yaffs2 filesystem

1. Generate yaffs.ko

cd xxx/yaffs2

cp ./ yportenv_multi.h ./yportenv.h

sudo make modules

These commands will generate yaffs2multi.ko

 

2. Insmod needed ko files

sudo modprobe mtd

sudo modprobe mtdchar

sudo modprobe mtdblock

cd xxx/yaffs2

insmod ./yaffs2multi.ko

Then, use “cat /proc/filesystem “, you will see that “yaffs2” file system is listed in the supported filesystem.

 

3. Use nandsim to generate a simulated nand flash device

sudo modprobe nandsim first_id_byte=0x20 second_id_byte=0xa2 third_id_byte=0x00 fourth_id_byte=0x15

 

Generate a yaffs2image using mkyaffs2image

1. Create rootfs

Create  “rootfs” dir anywhere, and add bin/, etc/, lib/, root/, tmp/  subdirectory,  “hello.txt” file.

2. Generate

xxx/mkyaffs2image xxx/rootfs rootfs.image

The rootfs.image is needed to write to nand flash.

 

Mount yaffs2 image to nand flash

1. Erase flash

sudo flash_eraseall /dev/mtd0

 

2. Write image to flash

nandwrite -a -o /dev/mtd0 rootfs.image

 

3. Mount

Create xxx/yaffs2_mount

mount -t yaffs2 /dev/mtdblock0 xxx/yaffs2

cd xxx/yaffs2

You will see bin/, etc/, lib/, root/, tmp, and hello.txt, which are created when generating yaffs2 image file.