您的位置:首页 > 运维架构 > Linux

linux 2.6.24.4在S3C2410上的移植(内核配置)(基于GEC2410)

2010-05-17 11:13 519 查看
移植完u-boot后,接下来就是linux内核了.以下记录我移植的步骤,如有问题,欢迎指正.
1.下载linux kernel源代码
http://www.kernel.org/下载linux内核源代码,这里我们使用2.6.24.4的内核.
解压linux-2.6.24.4.tar.bz2
[matt@localhost GEC2410]$ tar -xvjf linux-2.6.24.4.tar.bz2
[matt@localhost GEC2410]$ cd linux-2.6.24.4

2.修改顶层Makefile,设置交叉编译器
ARCH ?= arm
CROSS_COMPILE ?= /home/GEC2410/toolchain/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-

3. 复制编译配置文件到linux-2.6.24.4下为默认配置文件.config,移植过程以sdmk2410开发板为模板.
同时将复制一个新的配置文件gec2410.defconfig放到configs目录下,最近的配置都保存到这个这个文件,这样就可以直接用make gec2410_defconfig进行配置了.
[matt@localhostlinux-2.6.24.4]$cp arch/arm/configs/s3c2410_defconfig arch/arm/configs/gec2410.defconfig
[matt@localhostlinux-2.6.24.4]$cp arch/arm/configs/s3c2410_defconfig .config

3.设置Nand分区
我们将nand(64M)分成4个区,分别为u-boot 1MB, Linux Kernel 3MB, Root 40MB, User 20MB.
修改arch/arm/plat-s3c24xx/common-smdk.c中108行的smdk_default_nand_part[]如下:
[matt@localhost linux-2.6.24.4]$ vim arch/arm/plat-s3c24xx/common-smdk.c
static struct mtd_partition smdk_default_nand_part[] = {
#if 0
[0] = {
.name	= "Boot Agent",
.size	= SZ_16K,
.offset	= 0,
},
[1] = {
.name	= "S3C2410 flash partition 1",
.offset = 0,
.size	= SZ_2M,
},
[2] = {
.name	= "S3C2410 flash partition 2",
.offset = SZ_4M,
.size	= SZ_4M,
},
[3] = {
.name	= "S3C2410 flash partition 3",
.offset	= SZ_8M,
.size	= SZ_2M,
},
[4] = {
.name	= "S3C2410 flash partition 4",
.offset = SZ_1M * 10,
.size	= 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,
}
#endif

[0] = {
.name	= "U-Boot",
.size	= SZ_1M,
.offset	= 0,
},
[1] = {
.name	= "Linux Kernel",
.offset   = SZ_1M,
.size	= SZ_1M*3,
},
[2] = {
.name	= "Root",
.offset   = SZ_4M,
.size	= SZ_4M*10,
},
[3] = {
.name	= "User",
.offset	= SZ_4M*11,
.size	= SZ_4M*5,
}
};


4. 禁止Flash ECC校验
由于uboot通过软件ECC,而内核是硬件ECC,所以这里将内核ECC禁止.
修改drivers/mtd/nand/s3c2410.c中的s3c2410_nand_init_chip()函数,在该函数体最后加上一句:
chip->eccmode = NAND_ECC_NONE;

5 配置内核
(1) 支持启动时挂载devfs
为了我们的内核支持devfs以及在启动时并在/sbin/init运行之前能自动挂载/dev为devfs文件系统,修改fs/Kconfig文件
vi fs/Kconfig
找到menu "Pseudo filesystems"
添加如下语句:
config DEVFS_FS
bool "/dev file system support (OBSOLETE)"
default y
config DEVFS_MOUNT
bool "Automatically mount at boot"
default y
depends on DEVFS_FS
(2)内核配置
首先加载SMDK2410的内核配置
[matt@localhost linux-2.6.24.4]$make smdk2410_defconfig
[matt@localhost linux-2.6.24.4]$ make menuconfig
增加MTD,Nand支持,选中
Device Drivers-Memory Technology Device (MTD) support
选中使用默认配置即可,其中包括以下等支持:
<*>MTD partitioning support
<*>Command line partition table parsing
<*>Direct char device access to MTD devices
<*>Caching block device access to MTD devices
<*>NAND Device Support
<*>NAND Flash support for S3C2410/S3C2440 SoC
增加FS支持(NFS,cramfs):
File System:
<*>Network File Systems
Miscellaneous filesystems -->
<*>Compressed ROM file system support (cramfs)
Pseudo filesystems -->
<*>/dev file system support (OBSOLETE)
可以看到上面设置的devfs已经被支持了.
保存配置文件,下次就可以用make gec2410_defconfig来加载配置信息了.
[matt@localhostlinux-2.6.24.4]$cp .config arch/arm/configs/gec2410_defconfig

6.制作uImage
zImage是ARM Linux常用的一种压缩映像文件,uImage是U-boot专用的映像文件,它是在zImage之前加上一个长度为0x40的“头”,说明这个映像文件的类型、加载位置、生成时间、大小等信息。
可以使用mkimage来生成uImage,该工具位于u-boot下的tools目录,编译完u-boot就可以找到这个工具.我们拷到/linux2.6.24/arm/arm/boot/,用来将zImage生成uImage.
其参数含义为
-A ==> set architecture to 'arch' //用于指定CPU类型,比如ARM
-O ==> set operating system to 'os' //用于指定操作系统,比如Linux
-T ==> set image type to 'type' //用于指定image类型,比如Kernel
-C ==> set compression type 'comp' //指定压缩类型
-a ==> set load address to 'addr' (hex) //指定image的载入地址
-e ==> set entry point to 'ep' (hex) //内核的入口地址,一般是:image的载入地址+0x40(信息头的大小)
-n ==> set image name to 'name' //image在头结构中的命名
-d ==> use image data from 'datafile' //无头信息的image文件名
-x ==> set XIP (execute in place) //设置执行位置

[matt@localhost boot]$ ./mkimage -A arm -O linux -T kernel -C none -a 30008000 -e 30008040 -n linux-2.6.24 -d zImage uImage
为了方便起见,我们将这个命令写入到一个mkuimage.sh的批处理文件中,这样只要运行这个文件就不必输入这么长的命令了.
mkuimage.sh:
echo "making uImage..."
./mkimage -A arm -O linux -T kernel -C none -a 30008000 -e 30008040 -n linux-2.6.24 -d zImage uImage

echo "making uImage finished..."
然后运行:
[matt@localhost linux-2.6.24.4]$ cd arch/arm/boot
[matt@localhost boot]$ chmod 777 mkuImage.sh
[matt@localhost boot]$ sh mkuImage.sh(或者./mkuImage.sh)
making uImage...
Image Name: linux-2.6.24
Created: Mon May 24 10:06:09 2010
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1567656 Bytes = 1530.91 kB = 1.50 MB
Load Address: 0x30008000
Entry Point: 0x30008040
making uImage finished...
就可以看到uImage生成了.

使用u-boot烧写uImage到nand,设置启动参数让u-boot自动加载uImage运行内核.
GEC2410#tftp 30008000 uImage
GEC2410#nand erase 100000 200000
GEC2410#nand write 30008000 100000 200000
GEC2410#setenv bootcmd nand read 30008000 100000 200000/;bootm

GEC2410#saveenv
GEC2410#bootm

## Booting image at 30008000 ...
Image Name: linux-2.6.24
Created: 2010-05-21 8:35:34 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1567720 Bytes = 1.5 MB
Load Address: 30008000
Entry Point: 30008040
Verifying Checksum ... OK
XIP Kernel Image ... OK

Starting kernel ...

Uncompressing Linux.............................................................
......................................... done, booting the kernel.
......
这时linux就启动了,但这时cs8900网卡驱动还没有,根文件系统还没有.系统会停在.
No filesystem could mount root, tried: ext3 ext2 cramfs msdos vfat romfs
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)
下一步先移植cs8900网卡驱动,然后是根文件系统.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: