typhoonzb | | |
等级:论坛游民
威望:5
文章:169
积分:1245
注册:2009-2-10
鲜花(0) 鸡蛋(0) | NOR FLASH挂载jfss2文件系统
前段时间忙着找工作。项目的事情又拖了好一阵子,今天正好趁着ZTE面试的间隙把挂载JFFS2可写文件系统的事情解决一下,其实挺快的,半天时间理清了思路,实践成功了呵呵
具体步骤如下:
1.内核配置:根据官网上面的两篇帖子
http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:mtd
http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:jffs
Device Drivers --->
Memory Technology Devices (MTD) --->
<*> Memory Technology Device (MTD) support
Direct char device access to MTD devices
Caching block device access to MTD devices
RAM/ROM/Flash chip drivers --->
<*> Detect flash chips by Common Flash Interface (CFI) probe
<*> Support for Intel/Sharp flash chips
<*> Support for RAM chips in bus mapping
<*> Support for ROM chips in bus mapping
Mapping drivers for chip access --->
<*> CFI Flash device in physical memory map
(the address/length options are ignored)
File systems --->
Miscellaneous filesystems --->
<*> Journalling Flash File System v2 (JFFS2) support
(sub-options are up to you)
以上4个子步骤完成了内核对MTD配置以及JFSS2支持的配置
2.user下面的MTD utils配置
Flash Tools --->
mtd-utils
erase
eraseall
mkfs.jff2
3.修改uClinux-dist-2008R1-RC8\linux-2.6.x\arch\blackfin\mach-bf561\boards中对应的板子初始化文件efevm.c
相应的mtd划分改为
static struct mtd_partition ezkit_partitions[] = {
{
.name = "Bootloader",/*uboot 256KB*/
.size = 0x40000,
.offset = 0,
}, {
.name = "Kernel",/*kernel 896KB*/
.size = 0xE0000,
.offset = MTDPART_OFS_APPEND,
}, {
.name = "RootFS",/*rootfs 6MB*/
.size = 0x600000,
.offset = MTDPART_OFS_APPEND,
}, {
.name = "jffs2-njupt",/*jffs2 896KB*/
.size = MTDPART_SIZ_FULL,
.offset = MTDPART_OFS_APPEND,
}
};
4.make生成内核加文件系统的镜像
5.uboot载入刚编译完的内核加文件系统
root:/> cat /proc/mtd
dev: size erasesize name
mtd0: 00040000 00040000 "bootloader"
mtd1: 00100000 00040000 "kernel"
mtd2: 00300000 00040000 "romfs"
mtd3: 00100000 00040000 "jffs2-test"
NOR FLASH分了4块,对应mtd0至mtd3
root:/> eraseall /dev/mtd3 擦除相应的存放jffs2文件系统的块
root:~> mount -t jffs2 /dev/mtdblock3 /mnt/ 把该块以jffs2格式挂载到mnt下
这样在mnt目录下面就能执行任何写操作了。
6.掉电重启,需要重新执行一遍mount -t jffs2 /dev/mtdblock3 /mnt/
把mtd3挂载到mnt下,可以发现原先创建的文件没有丢失!!可以把mount的部分加载到rc中,这样每次自启动的时候直接把mtd3挂载到mnt下面了
至此,NOR FLASH开辟空间完成JFFS2格式写保存的工作全部完成。
|
|