分类: LINUX
2009-01-22 09:51:30
主要还是参考tekkaman的文章http://blog.chinaunix.net/u1/34474/showart.php?id=369449自己修改了网卡移植这一部分。交叉编译器用的是arm-linux-
一、将Linux
#tar xzvf linux2.6.22.6.tar.gz
#pwd
/home/work/hzh1024n
# cd linux2.6.22.6
进入内核解压后的目录,以后示例中,只要是相对路径全部是相对于
/home/work/hzh1024n/linux2.6.22.6/此目录
二、修改内核源码根目录下的Makefile文件(CROSS_COMPILE =的值因个人情况而定,其他可以照做。)
#vi Makefile
#ARCH ?= $(SUBARCH)
#CROSS_COMPILE ?=
ARCH = arm
CROSS_COMPILE = /usr/local/arm/
三、修改arch/arm/plat-s
......
/* NAND parititon from
static struct mtd_partition smdk_default_nand_part[] = {
[0] = {
.name = "U-Boot-
.size = SZ_128K,
.offset = 0,
},
[1] = {
.name = "U-Boot-1.2.0 Parameter",
.offset = SZ_128K,
.size = SZ_64K,
},
[2] = {
.name = "Linux2.6.22.2 Kernel",
.offset = SZ_128K+SZ_64K,
.size = SZ_
},
[3] = {
.name = "Root-JFFS2",
.offset = SZ_
.size = SZ_
},
[4] = {
.name = "Boot-Root(cramfs)",
.offset = SZ_
.size = SZ_
},
[5] = {
.name = "YAFFS",
.offset = SZ_
.size = SZ_
}
/*,
[6] = {
.name = "S
.offset = SZ_
.size = SZ_
},
[7] = {
.name = "S
.offset = SZ_
.size = SZ_
}
*/
};
......
static struct s
.tacls = 0,
.twrph0 = 30,
.twrph1 = 0,
.nr_sets = ARRAY_SIZE(smdk_nand_sets),
.sets = smdk_nand_sets,
};
......
四、 修改drivers/mtd/nand/s
我的内核是通过U-BOOT写到Nand Flash的, U-BOOT 通过的软件ECC算法产生ECC校验码, 这与内核校验的ECC码不一样, 内核中的ECC码是由S
(不过我不了解内核中的ECC码生成原理,在查资料的过程中我看到了《成功移植最新的
“第三步:修改ECC校验:
根据kernel官方网站上的说明,从
在driver/mtd/nand/s
chip->ecc.mode=NAND_ECC_SOFT;
改成
chip->ecc.mode=NAND_ECC_NONE; ”
搜索关键字NAND_ECC_SOFT,在s
五、增加Yaffs2文件系统的支持
对于YAFFS文件系统,我在移植时查阅了许多资料。有的博客上说没有必要移植YAFFS2,因为它是为每页大于1024B的NAND Flash设计的。即使移植了YAFFS2,如果你的NAND Flash是每页512+16B的那系统也会自动挂载YAFFS。所以在这里要移植YAFFS2或是YAFFS 随你的便。我移植的是YAFFS2。
1、下载Yaffs2
2、解压Yaffs2并将其加入Linux内核(打补丁的方式)
#cd yaffs2
#./patch-ker.sh c /home/work/hzh1024n/linux-
六、配置内核
在配置内核前,先拷贝s
#pwd
/home/work/hzh1024n/linux-
# cp arch/arm/configs/s
# make menuconfig
以下是在 s
General setup --->
[*] Configure standard kernel features (for small systems) --->
选上这项,否则文件系统中的一些选项不会出现
System Type --->
S
[*] SMDK2410/A
“N”掉 S
Boot options --->
将 (root=/dev/hda1 ro init=/bin/bash console=ttySAC0) Default kernel command string
改成 (noinitrd root=/dev/mtdblock3 rootfstype=jffs2 console=ttySAC0,115200 init=/linuxrc mem=64M) Default kernel command string
#说明:
#mtdblock3代表第4个flash分区,用来作根文件系统rootfs;
# console=ttySAC0,115200使kernel启动期间的信息全部输出到串口0上,波特率为115200;
# 2.6内核对于串口的命名改为ttySAC0,但这不影响用户空间的串口编程。
# 用户空间的串口编程针对的仍是/dev/ttyS0等
# mem=
在实践中,我发现“rootfstype=jffs
Userspace binary formats --->
< > Kernel support for a.out and ECOFF binaries (去除该选项,a.out和ECOFF是两种可执行文件的格式,在ARM-Linux下一般都用ELF,所以这两种基本用不上。)
Networking --->
Networking options --->
<*> Packet socket
[*] Packet socket: mmapped IO
-我移植华硕无限网卡,所以我选了WLAN(802.11)的选项,不需的可以不选-
Wireless --->
--- Improved wireless configuration API
--- Wireless extensions
<*> Generic IEEE 802.11 Networking Stack (mac80211)
[*] Enable LED triggers
[ ] Enable debugging output (NEW)
<*> Generic IEEE 802.11 Networking Stack
[ ] Enable full debugging output (NEW)
--- IEEE 802.11 WEP encryption (802.1x)
< > IEEE 802.11i CCMP support (NEW)
< > IEEE 802.11i TKIP encryption (NEW)
<*> Software MAC add-on to the IEEE 802.11 networking stack
[ ] Enable full debugging output (NEW)
Device Drivers --->
“N”掉 Parallel port support ---> 里的所有选项。
Plug and Play support --->里的所有选项一定要“N”掉,不然编译会出错!!!!!!!!
Network device support --->
Ethernet (10 or 100Mbit) --->
选上<*> DM9000 support和< > Generic Media Independent Interface device support
-------——————————————————------
我用的是DM
-----------------------------
“N”掉 [ ] Ethernet (1000 Mbit) --->和 [ ] Ethernet (10000 Mbit) --->
Wireless LAN --->
[*] Wireless LAN (pre-802.11)
[*] Wireless LAN (IEEE 802.11)
USB Network Adapters --->
<*> Multi-purpose USB Networking Framework
<*> MMC/SD card support --->
Real Time Clock --->
“N”掉 [ ] Set system time from RTC on startup and resume
#接下来做的是针对文件系统的设置!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
(注意:不要试图按照旧内核的方法增加 devfs 的支持,因为在这个内核里已经彻底删除了
devfs的源代码。我曾试图将旧内核的devfs源代码复制过来,不过编译会出错!
补救的办法就是用BusyBox的mdev来代替,在讲根文件系统的建立时我会说明,你也可以到网上找mdev的资料。)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
File systems -->
< > Second extended fs support #去除对ext2的支持
< > Ext3 journalling file system support #去除对ext3的支持
<*> Kernel automounter support
<*> Kernel automounter version 4 support (also supports v3)
<*> Filesystem in Userspace support
Pseudo filesystems -->
[*] Virtual memory file system support (former shm fs)
<*> Userspace-driven configuration filesystem (EXPERIMENTAL)
Miscellaneous filesystems -->
<*> YAFFS2 file system support
“N”掉[ ]Autoselect yaffs2 format 和
[ ]Cache short names in RAM ,因为这是给每页大于1024B的NAND Flash设计的
<*> Journalling Flash File System v2 (JFFS2) support
(0) JFFS2 debugging verbosity (0 = quiet, 2 = noisy)
[*] JFFS2 write-buffering support
[ ] JFFS2 summary support (EXPERIMENTAL)
[ ] JFFS2 XATTR support (EXPERIMENTAL)
[*] Advanced compression options for JFFS2
[*] JFFS2 ZLIB compression support
[*] JFFS2 RTIME compression support
[*] JFFS2 RUBIN compression support
JFFS2 default compression mode (priority) --->
Network File Systems -->
<*> NFS file system support
--以下最好选上,因为在挂载NFS时可能出现protocol不支持的情况--
[*]Provide NFSv3 client support
[*]Provide client support for the NFSv3 ACL protocol extension
[*] Provide NFSv4 client support (EXPERIMENTAL)
[*] Allow direct I/O on NFS files
-------------------------------------------------------------------------
<*> NFS server support
[*] Provide NFSv3 server support
[*]Provide server support for the NFSv3 ACL protocol extension
[*] Provide NFSv4 server support (EXPERIMENTAL)
--- Provide NFS server over TCP support
[*] Root file system on NFS
保存退出,产生.config文件。
七、编译内核
#make zImage
正常来说编译是不会出错的,只有一些警告。