Unist.h在64位linux,Linux-2.6.32内核在mini2440上的移植 yaffs2文件系统移植

移植环境(红色粗字体字为修改后内容,蓝色粗体字为特别注意内容)

1.yaffs2文件系统移植

【1】获取yaffs2 源代码

现在大部分开发板都可以支持 yaffs2 文件系统,它是专门针对嵌入式设备,特别是使用nand

flash 作为存储器的嵌入式设备而创建的一种文件系统,早先的yaffs 仅支持小页(512byte/page)的nand

flash,现在的开发板大都配备了更大容量的nand

flash,它们一般是大页模式的(2K/page),使用yaffs2 就可以支持大页的nand

flash,下面是yaffs2 的移植详细步骤。在可以下载到最新的yaffs2 源代码,需要使用git工具( 安装方法见,在命令行输入:[root@localhost ~]# cd ./linux-test

[root@localhost linux-test]# git clone

git://www.aleph1.co.uk/yaffs2Cloning into

yaffs2...

remote: Counting objects: 6592, done.

remote: Compressing objects: 100% (3881/3881), done.

remote: Total 6592 (delta 5237), reused 3396 (delta 2642)

Receiving objects: 100% (6592/6592), 3.34 MiB | 166 KiB/s,

done.

Resolving deltas: 100% (5237/5237), done.

[root@localhost linux-test]# ls

linux-2.6.32.2 linux-2.6.39 yaffs2[root@localhost

linux-test]#片刻时间之后,可以看到下载的最新的yaffs2 的源代码目录。

【2】为内核打上yaffs2 补丁

(1)将yaffs2代码加入内核

这可以通过yaffs2目录下的脚本文件patch-ker.sh来给内核打补丁,用法如下:

[root@localhost yaffs2]# ./patch-ker.sh c

/root/linux-test/linux-2.6.32.2

usage: ./patch-ker.sh c/l m/s

kernelpath

if c/l is c, then copy. If l then link

if m/s is m, then use

multi version code. If s then use single version

code[root@localhost yaffs2]# ./patch-ker.sh c

m

/root/linux-test/linux-2.6.32.2

注意第二个参数m/s,要特别注意如果不是最新的linux内核就要使用参数m而不是s,否则内核编译时就会发生错误。所以

我在这里强烈建议用m。可能产生的YAFFS2文件错误如下:

fs/yaffs2/yaffs_vfs.c:66:26: error:

yaffs_mtdif1.h: No such file or directory

fs/yaffs2/yaffs_vfs.c:67:26: error:

yaffs_mtdif2.h: No such file or directory

fs/yaffs2/yaffs_vfs.c: In function

'yaffs_link':

fs/yaffs2/yaffs_vfs.c:309: error: implicit

declaration of function 'set_nlink'

fs/yaffs2/yaffs_vfs.c: In function

'yaffs_setattr':

fs/yaffs2/yaffs_vfs.c:527: error: implicit

declaration of function 'setattr_copy'

fs/yaffs2/yaffs_vfs.c:530: error: implicit

declaration of function 'truncate_setsize'

fs/yaffs2/yaffs_vfs.c: At top

level:

fs/yaffs2/yaffs_vfs.c:876: warning: initialization

from incompatible pointer type

fs/yaffs2/yaffs_vfs.c:907: warning: initialization

from incompatible pointer type

fs/yaffs2/yaffs_vfs.c: In function

'yaffs_evict_inode':

fs/yaffs2/yaffs_vfs.c:1067: error: implicit

declaration of function 'end_writeback'

fs/yaffs2/yaffs_vfs.c: In function

'yaffs_put_super':

fs/yaffs2/yaffs_vfs.c:1929: error: 'struct

yaffs_linux_context' has no member named

'put_super_fn'

fs/yaffs2/yaffs_vfs.c:1930: error: 'struct

yaffs_linux_context' has no member named

'put_super_fn'

fs/yaffs2/yaffs_vfs.c: At top

level:

fs/yaffs2/yaffs_vfs.c:1958: error: unknown field

'evict_inode' specified in initializer

fs/yaffs2/yaffs_vfs.c:1958: warning:

initialization from incompatible pointer type

fs/yaffs2/yaffs_vfs.c: In function

'yaffs_internal_read_super':

fs/yaffs2/yaffs_vfs.c:2187: error: 'struct

yaffs_param' has no member named

'write_chunk_tags_fn'

fs/yaffs2/yaffs_vfs.c:2187: error:

'nandmtd2_write_chunk_tags' undeclared (first use in this

function)

fs/yaffs2/yaffs_vfs.c:2187: error: (Each

undeclared identifier is reported only once

fs/yaffs2/yaffs_vfs.c:2187: error: for each

function it appears in.)

fs/yaffs2/yaffs_vfs.c:2188: error: 'struct

yaffs_param' has no member named

'read_chunk_tags_fn'

fs/yaffs2/yaffs_vfs.c:2188: error:

'nandmtd2_read_chunk_tags' undeclared (first use in this

function)

fs/yaffs2/yaffs_vfs.c:2189: error: 'struct

yaffs_param' has no member named 'bad_block_fn'

fs/yaffs2/yaffs_vfs.c:2189: error:

'nandmtd2_mark_block_bad' undeclared (first use in this

function)

fs/yaffs2/yaffs_vfs.c:2190: error: 'struct

yaffs_param' has no member named 'query_block_fn'

fs/yaffs2/yaffs_vfs.c:2190: error:

'nandmtd2_query_block' undeclared (first use in this

function)

fs/yaffs2/yaffs_vfs.c:2202: error: 'struct

yaffs_param' has no member named

'write_chunk_tags_fn'

fs/yaffs2/yaffs_vfs.c:2202: error:

'nandmtd1_write_chunk_tags' undeclared (first use in this

function)

fs/yaffs2/yaffs_vfs.c:2203: error: 'struct

yaffs_param' has no member named

'read_chunk_tags_fn'

fs/yaffs2/yaffs_vfs.c:2203: error:

'nandmtd1_read_chunk_tags' undeclared (first use in this

function)

fs/yaffs2/yaffs_vfs.c:2204: error: 'struct

yaffs_param' has no member named 'bad_block_fn'

fs/yaffs2/yaffs_vfs.c:2204: error:

'nandmtd1_mark_block_bad' undeclared (first use in this

function)

fs/yaffs2/yaffs_vfs.c:2205: error: 'struct

yaffs_param' has no member named 'query_block_fn'

fs/yaffs2/yaffs_vfs.c:2205: error:

'nandmtd1_query_block' undeclared (first use in this

function)

fs/yaffs2/yaffs_vfs.c:2209: error: 'struct

yaffs_param' has no member named 'erase_fn'

fs/yaffs2/yaffs_vfs.c:2209: error:

'nandmtd_erase_block' undeclared (first use in this

function)

fs/yaffs2/yaffs_vfs.c:2210: error: 'struct

yaffs_param' has no member named

'initialise_flash_fn'

fs/yaffs2/yaffs_vfs.c:2210: error:

'nandmtd_initialise' undeclared (first use in this

function)

fs/yaffs2/yaffs_vfs.c:2212: error: 'struct

yaffs_linux_context' has no member named

'put_super_fn'

fs/yaffs2/yaffs_vfs.c:2212: error:

'yaffs_mtd_put_super' undeclared (first use in this

function)

fs/yaffs2/yaffs_vfs.c: In function

'yaffs_mount':

fs/yaffs2/yaffs_vfs.c:2307: error: implicit

declaration of function 'mount_bdev'

fs/yaffs2/yaffs_vfs.c:2308: warning: return makes

pointer from integer without a cast

fs/yaffs2/yaffs_vfs.c: At top

level:

fs/yaffs2/yaffs_vfs.c:2314: error: unknown field

'mount' specified in initializer

fs/yaffs2/yaffs_vfs.c:2314: warning:

initialization makes integer from pointer without a

cast

fs/yaffs2/yaffs_vfs.c: In function

'yaffs2_mount':

fs/yaffs2/yaffs_vfs.c:2329: warning: return makes

pointer from integer without a cast

fs/yaffs2/yaffs_vfs.c: At top

level:

fs/yaffs2/yaffs_vfs.c:2335: error: unknown field

'mount' specified in initializer

fs/yaffs2/yaffs_vfs.c:2335: warning:

initialization makes integer from pointer without a

cast

make[2]: *** [fs/yaffs2/yaffs_vfs.o]

错误 1

make[1]: *** [fs/yaffs2]

错误 2

make: *** [fs] 错误 2

Updating

/root/linux-test/linux-2.6.32.2/fs/Kconfig

Updating /root/linux-test/linux-2.6.32.2/fs/Makefile

上述命令完成下面三件事:

<1>修改内核文件/fs/Kconfig,增加下面两行(在177行附近):

if MISC_FILESYSTEMS

source "fs/adfs/Kconfig"

source "fs/affs/Kconfig"

source "fs/ecryptfs/Kconfig"

source "fs/hfs/Kconfig"

source "fs/hfsplus/Kconfig"

source "fs/befs/Kconfig"

source "fs/bfs/Kconfig"

source "fs/efs/Kconfig"

source

"fs/yaffs2/Kconfig"source "fs/jffs2/Kconfig"

# UBIFS File system configuration

<2>修改内核文件/fs/Makefile,增加下面两行(在129行附近):

obj-$(CONFIG_GFS2_FS) += gfs2/

obj-$(CONFIG_EXOFS_FS) += exofs/

obj-$(CONFIG_YAFFS_FS) +=

yaffs2/

<3>在内核文件的fs目录下创建yaffs2子目录,然后复制如下文件:

将yaffs2源码目录下的Makefile.kernel文件复制为内核fs/yaffs2/Makefile文件。

将yaffs2源码目录下的Kconfig文件复制为内核fs/yaffs2/目录下。

将yaffs2源码目录下的*.c、*.h文件(不包括子目录下的文件)复制为内核fs/yaffs2/目录下。

(2)配置内核选项

阅读内核fs/Kconfig文件可以了解各配置选项的作用。

以下是用到的几个选项:

<1>CONFIG_YAFFS_FS:支持yaffs文件系统。

<2>CONFIG_YAFFS_YAFFS2:支持yaffs2文件系统,对于每页大小为2k字节nand

flash,需要选中这个选项。

<3>CONFIG_YAFFS_AUTO_YAFFS2:自动选择yaffs2文件格式,如果不配置这个选项,必须使用yaffs2字样来表示yaffs2文件系统格式,如果配置这个选项,则可以使用yaffs字样来统一表示yaffs1和yaffs2文件系统格式,驱动程序会根据nand

flash的页大小自动分辨是yaffs1还是yaffs2。

2.修改内核

(1)修改顶层Makefile

[root@localhost linux-2.6.32]# vi

Makefile

加上我们的编译环境

ARCH

?= arm

CROSS_COMPILE  ?=

arm-linux-

(2)在arch/arm/mach-s3c2440/mach-smdk2440.c中做如下修改:

修改前 s3c24xx_init_clocks(16934400);

修改后s3c24xx_init_clocks(12000000);

3.修改分区

本实验将NAND

flash划分为三个分区,前2MB用于存放内核,接下来8MB用来存放JFFS2文件系统,剩下来的用来存放YAFFS2文件系统。

[root@localhost linux-2.6.32]# vi

arch/arm/plat-s3c24xx/common-smdk.c

static struct mtd_partition

smdk_default_nand_part[] = {

[0] = {

.name =

"kernel",

.size = SZ_2M,

.offset = 0,

},

[1] = {

.name = "jffs2",

.offset = MTDPART_OFS_APPEND,

.size = SZ_8M,

},

[2] = {

.name = "yaffs",

.offset = MTDPART_OFS_APPEND,

.size =

MTDPART_SIZ_FULL,

}

};

4.机器码的确定

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值