linux-2.6.18内核移植及根文件系统的制做(简易)
一、 去 下载内核,下面以 linux-2.6.18.tar.bz2 为例。
[root@Binnary ~ ]# tar –jxvf linux-2.6.18.tar.bz2
[root@Binnary ~ ]# cd linux-2.6.18
二、 修改Makefile 文件
[root@Binnary linux-2.6.18 ]# vi Makefile
ARCH ?= arm
CROSS_COMPILE ?= arm-linux-
三、查看开发板分区信息(以此以GEC2410为例)
vivi>part show
[root@Binnary linux-2.6.18 ]# vi arch/arm/mach-s3c2410/common-smdk.c
static struct mtd_partition smdk_default_nand_part[] = {
[0] = {
.name = "boot",
.size = 0x30000,
.offset = 0,
},
[1] = {
.name = "kernel",
.offset = 0x30000,
.size = 0x1d0000,
},
[2] = {
.name = "rootfs",
.offset = 0x200000,
.size = 0x1f0000,
},
[3] = {
.name = "ext-fs",
.offset = 0x2100000,
.size = 0x1f00000,
}/*,
[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,
}*/
};
三、 去掉ECC交验
[root@Binnary linux-2.6.18 ]# vi drivers/mtd/nand/s3c2410.c
575 chip->ecc.mode = NAND_ECC_NONE;
chip->ecc.mode = NAND_ECC_SOFT ,改为如下 chip->ecc.mode = NAND_ECC_NONE。
四、 devfs的支持
[root@Binnary linux-2.6.18 ]# vi fs/Kconfig
在Pseudo filesystem主菜单添加我们要支持的内容。
904 config DEVFS_FS
905 bool "/dev file system support(OBSOLETE)"
906 depends on EXPERIMENTAL
907 default y
908 help
909 the help from binnary.
910
911 config DEVFS_MOUNT
912 bool "automatically mount at boot"
913 depends on DEVFS_FS
914 default y
915 help
916 The help from Binnary.
917
918 config DEVFS_DEBUG
919 bool "Debug devfs"
920 depends on DEVFS_FS
921 help
922 The help from binnary.
923
924 endmenu
五、 yaffs2补丁
[root@Binnary linux-2.6.18 ]# cd ..
[root@Binnary ~ ]# tar –jxvf yaffs2.tar.bz2
[root@Binnary ~ ]# cd yaffs
[root@Binnary yaffs ]#./patch-ker.sh ../linux-2.6.18
六、 MTD分区的支持
[root@Binnary linux-2.6.18 ]# cd ../linux-2.6.18
[root@Binnary linux-2.6.18 ]# make smdk2410_defconfig
[root@Binnary linux-2.6.18 ]# make menuconfig
System Type --->
ARM system type (Samsung S3C2410, S3C2412, S3C2413, S3C2440, S3C2442) --->
(X) Samsung S3C2410, S3C2412, S3C2413, S3C2440, S3C2442
S3C24XX Implementations --->
[*] SMDK2410/A9M2410
Device Drivers --->
Memory Technology Devices (MTD) --->
[*] 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 Flash Device Drivers --->
[*] NAND Device Support
[*] NAND Flash support for S3C2410/S3C2440 SoC
七、 编译内核
[root@Binnary linux-2.6.18 ]# make
[root@Binnary linux-2.6.18 ]# cp arch/arm/boot/zImage /root
根文件系统的制作
[root@Binnary ~ ]# mkdir rootfs
[root@Binnary ~ ]#cd rootfs
[root@Binnary rootfs ]# mkdir bin dev etc lib proc sbin usr var tmp
[root@Binnary rootfs ]#chmod 1777 tmp
[root@Binnary rootfs ]#mkdir usr/bin usr/lib usr/sbin
[root@Binnary rootfs ]#vi etc/fstab
none /proc proc defaults 0 0
[root@Binnary rootfs ]#chmod 755 etc/fstab
[root@Binnary rootfs ]#vi etc/inittab
::sysinit:/etc/init.d/rcS
::sysinit:/bin/sh
[root@Binnary rootfs ]#chmod 7555 etc/inittab
[root@Binnary rootfs ]#mkdir etc/init.d
[root@Binnary rootfs ]#vi etc/init.d/rcS
/bin/mount –a
[root@Binnary rootfs ]# mknod –m 600 dev/console c 5 1
[root@Binnary rootfs ]# mknod –m 666 dev/null c 1 3
复制链接文件
[root@binnary lib ]# for file in libc libcrypt libdl libm libpthread libresolv libutil
>do
>cp $file-*.so ~/rootfs/lib
>cp –d $file.so.[*0-9] ~/rootfs/lib
>done
[root@binnary lib ]#cp –d ld*.so* ~/rootfs/lib
[root@Binnary ~ ]# tar –jxvf busybox-1.9.2.tar.bz2
[root@binnary ~ ]# cd busybox-1.9.2
[root@binnary busybox-1.9.2 ]# make menuconfig
[root@binnary busybox-1.9.2 ]# make
[root@binnary busybox-1.9.2 ]#make install
[root@binnary busybox-1.9.2 ]#cd _install
[root@binnary _install ]# cp –Rvf * ~/rootfs/
根据实际情况来修改下面的脚本文件:
cd ~
if [ -d ~/rootfs ] ;then #判断家目录下是否有rootfs文件夹,如果话就退出程序
echo "The home is have rootfs directory!!"
echo "Can\`t create rootfs ,program exit. "
else
mkdir rootfs
cd rootfs
for file in bin dev etc lib proc sbin usr var tmp #用for循环来创建文件夹
do
mkdir $file
echo "The $file is create......"
done
chmod 1777 tmp
echo "tmp directory right is 1777"
mkdir usr/bin usr/lib usr/sbin
echo "Create usr/bin,lib,sbin"
mkdir var/lib var/lock var/log var/run var/tmp
chmod 1777 var/tmp
echo "Create var/lib,lock,log,run,tmp"
echo "none /proc proc defaults 0 0" > etc/fstab
chmod 755 etc/fstab
echo "The fstab is create,the right is 755 ."
echo "::sysinit:/etc/init.d/rcS" > etc/inittab
echo "::sysinit:/bin/sh" >> etc/inittab
chmod 755 etc/inittab
echo "The inittab is create,the right is 755 ."
touch etc/busybox.conf
mkdir etc/init.d
echo "#!/bin/sh" > etc/init.d/rcS
echo "/bin/mount -a" >> etc/init.d/rcS
chmod 755 etc/init.d/rcS
echo " rcS is create,the right is 755"
echo "#!/bin/sh" > etc/profile
echo "PS1=[\\w]#" >> etc/profile
echo "alias ll='ls -l'" >> etc/profile
chmod 755 etc/profile
echo "The profile is create.the right is 755."
mknod -m 600 dev/console c 5 1
mknod -m 666 dev/null c 1 3
echo "console driver is create.c 5 1 the right is 600"
echo "null driver is create. c 13 the right is 666"
cd /armtools/arm-linux/lib
for file in libc libcrypt libdl libm libpthread libresolv libutil
do
cp $file-*.so ~/rootfs/lib
cp -d $file.so.[*0-9] ~/rootfs/lib
done
cp -d ld*.so* ~/rootfs/lib
if [ "$1" = "" ] ;then #判断 busybox 的路径
echo ""
echo "You don\`t input the busybox path."
echo "Please copy busybox file for youself."
echo ""
else
if [ -d $1/_install ] ;then #复制busybox产生的文件
echo "copy busybox file ...... "
cd $1/_install
cp -Rvf $1/_install/* ~/rootfs/ > /dev/null
echo "copy busybox file is done."
cd ~
if [ -f ~/root.cramfs ] ;then
echo "the root.cramfs is have.Please input the other name."
read name
echo "makeing file system ......"
mkcramfs rootfs $name.cramfs
echo "The file system is done."
echo ""
echo "The root.cramfs is at ~/$name.cramfs."
echo ""
else
echo "makeing file system ......"
mkcramfs rootfs root.cramfs
echo "The file system is done."
echo ""
echo "The root.cramfs is at ~/root.cramfs."
echo ""
fi
else
echo ""
echo "You input the path is wrong.do not copy busybox file."
echo ""
fi
fi
fi
阅读(687) | 评论(0) | 转发(0) |