红联Linux门户
Linux帮助

在FS2410开发板上移植linux2.6.24初步成功

发布时间:2008-04-05 00:19:56来源:红联作者:ginceo
说是移植,也不太准确,因为linux2.6.24内核已经将s3c2410纳入。在移植的时候只是需要做几个小的改动以及几个注意的地方。

一. 前言
使用的内核:linux2.6.24,http://www.kernel.org/pub/linux/kernel/v2.6/
使用的arm交叉编译工具(4.2.0):http://www.codesourcery.com/gnu_toolchains/arm/download.html
环境:VMware中的Ubuntu 7.10

二. 移植
1. 修改MakeFile文件,确定arm平台以及使用的交叉编译工具:
修改的文件:
linux-2.6.24/Makefile

修改的内容:

#ARCH ?= $(SUBARCH)
ARCH ?= arm
#CROSS_COMPILE ?=
CROSS_COMPILE ?= /usr/local/arm/arm-2007q3/bin/arm-none-linux-gnueabi-

2. 根据开发板修改NAND Flash初始化代码:
修改的文件:
linux-2.6.24/arch/arm/plat-s3c24xx/common-smdk.c
说明:这一部分的修改与具体的开发板电路有关系

修改的内容:
/* NAND parititon from 2.4.18-swl5 */

static struct mtd_partition smdk_default_nand_part[] = {
[0] = {
.name = "boot", //= "Boot Agent",
.size = SZ_256K, //= SZ_16K,
.offset = 0,
},
[1] = {
.name = "kernel", //= "S3C2410 flash partition 1",
.offset = SZ_256K, //= 0,
.size = SZ_2M-SZ_256K, //= SZ_2M,
},
[2] = {
.name = "rootfs", //= "S3C2410 flash partition 2",
.offset = SZ_2M, //= SZ_4M,
.size = 30 * SZ_1M, //= SZ_4M,
},
[3] = {
.name = "ext-fs1", //= "S3C2410 flash partition 3",
.offset = SZ_32M, //= SZ_8M,
.size = SZ_16M, //= SZ_2M,
},
[4] = {
.name = "ext-fs2", //= "S3C2410 flash partition 4",
.offset = SZ_32M+SZ_16M, //= SZ_1M * 10,
.size = SZ_16M, //= SZ_4M,
},
/* [5] = {
.name = "S3C2410 flash partition 5",
.offset = SZ_1M * 14,
.size = SZ_1M * 10,
},
[6] = {
.name = "S3C2410 flash partition 6",
.offset = SZ_1M * 24,
.size = SZ_1M * 24,
},
[7] = {
.name = "S3C2410 flash partition 7",
.offset = SZ_1M * 48,
.size = SZ_16M,
}*/
};
参考资料:
yl2.6.8.1提供的内核源代码
linux-2.6.8.1-zzm/drivers/mtd/nand/s3c2410_nand.c

static struct mtd_partition partition_info[] = {
{ name: "boot",
offset: 0,
size: SZ_256K },
{ name: "kernel",
offset: SZ_256K,
size: SZ_2M - SZ_256K },
{ name: "rootfs",
offset: SZ_2M,
size: 30 * SZ_1M },
{ name: "ext-fs1",
offset: SZ_32M,
size: SZ_16M },
{ name: "ext-fs2",
offset: SZ_32M + SZ_16M,
size: SZ_16M },
};

3. 增加devfs文件系统支持
linux2.6.24已经去掉devfs,为了内核支持devfs以及在启动时并在/sbin/init运行之前能自动挂载/dev为devfs文件系统,修改fs的Kconfig文件。
linux-2.6.24/fs/Kconfig

修改的内容:
找到menu "Pseudo filesystems"
添加如下语句:
config DEVFS_FS
bool "/dev file system support (OBSOLETE)"
depends on EXPERIMENTAL
help
This is support for devfs, a virtual file system (like /proc) which
provides the file system interface to device drivers, normally found
in /dev. Devfs does not depend on major and minor number
allocations. Device drivers register entries in /dev which then
appear automatically, which means that the system administrator does
not have to create character and block special device files in the
/dev directory using the mknod command (or MAKEDEV script) anymore.

This is work in progress. If you want to use this, you *must* read
the material in , especially
the file README there.

Note that devfs no longer manages /dev/pts! If you are using UNIX98
ptys, you will also need to mount the /dev/pts filesystem (devpts).

Note that devfs has been obsoleted by udev,
<http://www.kernel.org/pub/linux/utils/kernel/hotplug/>.
It has been stripped down to a bare minimum and is only provided for
legacy installations that use its naming scheme which is
unfortunately different from the names normal Linux installations
use.

If unsure, say N.

config DEVFS_MOUNT
bool "Automatically mount at boot"
depends on DEVFS_FS
help
This option appears if you have CONFIG_DEVFS_FS enabled. Setting
this to 'Y' will make the kernel automatically mount devfs onto /dev
when the system is booted, before the init thread is started.
You can override this with the "devfs=nomount" boot option.

If unsure, say N.

config DEVFS_DEBUG
bool "Debug devfs"
depends on DEVFS_FS
help
If you say Y here, then the /dev file system code will generate
debugging messages. See the file
for more
details.

If unsure, say N.

4. 编译内核
make menuconfig(这一部分比较麻烦,要根据自己的需要以及开发板的实际情况设定)
make zImage

5. 修改根文件系统
如不修改根文件系统,启动时会提示“Warning: unable to open an initial console.”的错误信息。修改方法(根据FS2410使用手册整理):
(1) 将yl2410_demo.cramfs 拷贝到任意目录下
(2) 在该目录下建立两个文件:
mkdir chang
mkdir guo
(3) 将yl2410_demo.cramfs 挂接到chang 目录(必须以root 身份登陆系统)
mount chang yl2410_demo.cramfs -o loop
(4) 将chang 目录下的内容压缩
cd chang
tar -cvf /chang 的上一级目录/1.tar ./
这样将在chang 的上一级目录产生一个1.tar 的包
(5) 将包解压到guo 目录下。
umount chang ;卸载挂接
cd .. ;进入上一级目录
mv 1.tar guo ;
cd guo ;
tar -xvf 1.tar ;将打包的根文件系统的里的内容解压
rm 1.tar

(6)转到dev目录
执行mknod console c 5 1
执行mknod null c 1 3

(7)转到usr目录
用刚编译linux2.6.24内核的相应文件替换掉以下文件
|-- ov511.ko #位于linux-2.6.24/drivers/media/video/目录
|-- ov511.o #位于linux-2.6.24/drivers/media/video/目录
|-- sd_mod.ko #位于linux-2.6.24/drivers/scsi/目录
|-- usb-storage.ko #位于linux-2.6.24/drivers/usb/storage/目录
|-- usbvideo.ko #位于linux-2.6.24/drivers/media/video/usbvideo/目录
|-- usbvideo.o #位于linux-2.6.24/drivers/media/video/usbvideo/目录
`-- videodev.o #位于linux-2.6.24/drivers/media/video/目录

说明:以上的文件能否生成根据在开始配置的情况决定。

(8)制作cramfs 根文件系统
先将mkcramfs 文件拷贝到guo 所在的目录
在这个目录下运行命令:
mkcramfs guo fs2410.cramfs
运行成功后,会在该目录下生成fs2410.cramfs 根文件系统

6. 下载,烧录,修改启动参数,启动
根据FS2410使用手册下载、烧录;先修改启动参数为:root=1f02 init=/linuxrc console=ttySAC0,115200 devfs=mount display=sam320,主要是将原来的ttyS0改为ttySAC0(这是由于linux内核对串行口的改动);然后启动即可。

三. 后记
为什么说初步成功?因为在制作根文件系统时使用的是开发板自带的,然后进行了简单的修改。我尝试自己使用BusyBox制作,可是总不能成功,总是提示”Failed to execute /linuxrc. Attempting defaults...“的错误,现在还没有解决。
文章评论

共有 1 条评论

  1. lzllinux 于 2008-07-21 16:24:15发表:

    谢谢!!!!!!!!!