转自:http://blog.csdn.net/xgjianstart/archive/2009/11/06/4777741.aspx
具体步骤如下:
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中对应的板子初始化文件besovideo.c
相应的mtd划分改为(4M的NOR FLASH大小)
#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
static struct mtd_partition ezkit_partitions[] = {
{
.name = "Bootloader",
.size = 0x40000,
.offset = 0,
}, {
.name = "Kernel",
.size = 0xE0000,
.offset = MTDPART_OFS_APPEND,
}, {
.name = "RootFS",
.size = 0x200000,
.offset = MTDPART_OFS_APPEND,
}, {
.name = "jffs2-njupt",
.size = MTDPART_SIZ_FULL,
.offset = MTDPART_OFS_APPEND,
}
};
static struct physmap_flash_data ezkit_flash_data = {
.width = 2,
.parts = ezkit_partitions,
.nr_parts = ARRAY_SIZE(ezkit_partitions),
};
static struct resource ezkit_flash_resource = {
.start = 0x20000000,
.end = 0x203fffff,
.flags = IORESOURCE_MEM,
};
static struct platform_device ezkit_flash_device = {
.name = "physmap-flash",
.id = 0,
.dev = {
.platform_data = &ezkit_flash_data,
},
.num_resources = 1,
.resource = &ezkit_flash_resource,
};
#endif
在该文件后面struct platform_device *besovideo_devices[] __initdata加入
#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
&ezkit_flash_device,
#endif
4.make生成内核加文件系统的镜像
5.uboot载入刚编译完的内核加文件系统
root:/> cat /proc/mtd
dev: size erasesize name
mtd0: 00040000 00020000 "bootloader"
mtd1: 000E0000 00020000 "kernel"
mtd2: 00200000 00020000 "romfs"
mtd3: 000E0000 00020000 "jffs2-njupt"
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格式写保存的工作全部完成。
注意:1。以上为2.6内核的配置;
2。mtd的分区要正确,不要有交叉。