how to compile uClinux kernel

来源:互联网 发布:杭州人工智能小镇地址 编辑:程序博客网 时间:2024/05/15 16:49
说明: 本小节内容是关于如何编译一个可以运行的 uClinux Kernel

-------------------------------------------------------------------------

Step 1 :
1. 下载 uClinux-dist-20030522.tar.gz 到当前工作目录下
http://159.226.40.150/lumit/resources/uClinux/uClinux-dist-20030522.tar.gz

2. 解压 uClinux-dist-20030522.tar.gz 文件到 uClinux-dist 目录
tar zxvf uClinux-dist-20030522.tar.gz
此时当前工作目录下增加了一个名为 uClinux-dist 的目录。

3. 下载 patch 文件 uClinux-20030522-lom_arm7-patch.rar 到 uClinux-dist 目录
http://159.226.40.150/lumit/resources/uClinux/uClinux-20030522-lom_arm7-patch.rar
用 winrar 解压 该文件后得到 uClinux-20030522-dailzh.patch

4. 复制 patch 文件到 uClinux-dist 目录下
cp uClinux-20030522-dailzh.patch uClinux-dist

4. 进入 uClinux-dist 目录
cd uClinux-dist

5. 打 patch 补丁
patch -p1 < uClinux-20030522-dailzh.patch
此时得到如下输出:
patching file config/.menuconfig.log
patching file linux-2.4.x/arch/armnommu/boot/compressed/linux.lds.in
patching file linux-2.4.x/arch/armnommu/boot/compressed/Makefile
patching file linux-2.4.x/arch/armnommu/config.in
patching file linux-2.4.x/arch/armnommu/vmlinux-armv.lds.in
patching file linux-2.4.x/include/asm-armnommu/arch-snds100/hardware.h
patching file linux-2.4.x/include/asm-armnommu/arch-snds100/memory.h
patching file Makefile
patching file mklinux
patching file user/busybox/docs/busybox.pod
patching file user/ntp/config.log
Hunk #1 succeeded at 1569 with fuzz 1 (offset -28 lines).
patching file user/tinylogin/applet_source_list
patching file user/tinylogin/config.h
patching file vendors/Samsung/4510B/config.linux-2.4.x
patching file vendors/Samsung/4510B/config.vendor-2.4.x
patching file vendors/Samsung/4510B/index.html
patching file vendors/Samsung/4510B/inittab
patching file vendors/Samsung/4510B/logo.jpg
patching file vendors/Samsung/4510B/Makefile
patching file vendors/Samsung/4510B/rc


Step 2 :
6. make menuconfig 配置内核
--- Choose a Vendor/Product combination.
(Samsung/4510B) Vendor/Product
(linux-2.4.x) Kernel Version
(uClibc) Libc Version

7. make dep 建立依赖关系

8. make lib_only 编译库文件

9. make user_only 编译用户应用程序文件

这里似乎会遇到有一个关于 boa 的应用有错,
uClinux-dist/user/boa/src/auth.c:194: undefined reference to `crypt_old'
可以重新 make menuconfig 后暂时不选择 boa 应用,就可以编译通过
Network Applications --->
[ ] boa
还有一个 /login/login.c :162: undefined reference to `crypt_old' 的错误,
也可以将 login 应用暂时去掉就可以编译通过
Core Applications --->
[ ] login

暂时不选择 boa 应用的具体操作方法如下:
make menuconfig 的时候:
Target Platform Selection --->
选中
[*] Customize Vendor/User Settings
然后 Exit
Do you wish to save your new kernel configuration? 选择 Yes 退出
进入 Main Menu 后 , 选择
Network Applications --->
清除 [ ] boa 选项,就可以不再编译 boa 这个应用程序。

同理: login 应用程序是通过
Core Applications --->
清除 [ ] login 选项即可。

10. make romfs 生成romfs文件系统

11. make image 编译内核
arm-elf-ld -r -o /home/liming/testuc/uClinux-dist/linux-2.4.x/romfs.o /
-b binary /home/liming/testuc/uClinux-dist/images/romfs.img
arm-elf-objcopy -O binary -R .note -R .comment /
-S /home/liming/testuc/uClinux-dist/linux-2.4.x/linux /home/liming/testuc/uClinux-dist/images/image.ram
cp /home/liming/testuc/uClinux-dist/linux-2.4.x/arch/armnommu/boot/zImage /
/home/liming/testuc/uClinux-dist/images/image.rom
make[1]: Leaving directory `/home/liming/testuc/uClinux-dist/vendors/Samsung/4510B'

可以看到成功编译后的最后几行输出,表示了 romfs.img, image.ram, image.rom 这几个文件和 linux 内核之间的关系。

Step 3 :
12. 查看 images 目录下的相关文件,可以看到:
[liming@hpclab uClinux-dist]$ ls images/* -l
-rwxrwxr-x 1 liming liming 801516 Aug 25 21:16 images/image.ram
-rwxrwxr-x 1 liming liming 372600 Aug 25 21:16 images/image.rom
-rw-rw-r-- 1 liming liming 814080 Aug 25 21:16 images/romfs.img

其中 image.ram 就是我们需要的,可以下载到 ram 中的 uclinux kernel (内含 romfs)

13. 按照 uclinux 启动说明,下载执行 image.ram 文件
http://www.lumit.org/download/document/lumit-uclinux-readme.txt

14. 可以看到开发板有如下输出显示:
/*************************************************************/
Bios for download and program.
Author Jerry
Build date : Jun 16 2004 Time : 17:11:45
Type help for help.
/*************************************************************/
/>
/>load
No begin address for download, use default address 0x8000
Mini TFTP Server 1.0 (IP : 192.168.168.101 PORT: 69)
Load image file from host
Type tftp -i 192.168.168.101 put filename at the host PC
Press ESC key to exit
Starting the TFTP download...
...............................................
Received 185aec Bytes, END...
Boot Image? (y/n) yLinux version 2.4.20-uc0 (liming@hpclab.cs.tsinghua.edu.cn) (gcc version 2.95.3 20010315 (release)(ColdFire patches - 20010318 from http://fiddes.net/coldfire/)(uClinux XIP and shared lib patches from http://www.snapgear.com/)) #7 Wed Aug 25 10:12:00 HKT 2004
Processor: Samsung S3C4510B revision 6
Architecture: SNDS100
On node 0 totalpages: 4096
zone(0): 0 pages.
zone(1): 4096 pages.
zone(2): 0 pages.
Kernel command line: root=/dev/rom0
Calibrating delay loop... 49.86 BogoMIPS
Memory: 16MB = 16MB total
Memory: 14476KB available (1484K code, 159K data, 40K init)
Dentry cache hash table entries: 2048 (order: 2, 16384 bytes)
Inode cache hash table entries: 1024 (order: 1, 8192 bytes)
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer-cache hash table entries: 1024 (order: 0, 4096 bytes)
Page-cache hash table entries: 4096 (order: 2, 16384 bytes)
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Samsung S3C4510 Serial driver version 0.9 (2001-12-27) with no serial options enabled
ttyS00 at 0x3ffd000 (irq = 5) is a S3C4510B
ttyS01 at 0x3ffe000 (irq = 7) is a S3C4510B
Blkmem copyright 1998,1999 D. Jeff Dionne
Blkmem copyright 1998 Kenneth Albanowski
Blkmem 1 disk images:
0: BE7E8-1853E7 [VIRTUAL BE7E8-1853E7] (RO)
RAMDISK driver initialized: 16 RAM disks of 1024K size 1024 blocksize
Samsung S3C4510 Ethernet driver version 0.1 (2002-02-20)
eth0: 00:40:95:36:35:34
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 1024 bind 1024)
VFS: Mounted root (romfs filesystem) readonly.
Freeing init memory: 40K
Shell invoked to run file: /etc/rc
Command: hostname Samsung
Command: /bin/expand /etc/ramfs.img /dev/ram0
Command: /bin/expand /etc/ramfs2048.img /dev/ram1
Command: mount -t proc proc /proc
Command: mount -t ext2 /dev/ram0 /var
Command: mount -t ext2 /dev/ram1 /ramdisk
Command: chmod 777 /ramdisk
Command: mkdir /var/config
Command: mkdir /var/tmp
Command: mkdir /var/log
Command: mkdir /var/run
Command: mkdir /var/lock
Command: ifconfig lo 127.0.0.1
Command: route add -net 127.0.0.0 netmask 255.255.255.0 lo
Command: ifconfig eth0 192.168.168.101 netmask 255.255.255.0 up
Command: cat /etc/motd
Welcome to
____ _ _
/ __| ||_|
_ _| | | | _ ____ _ _ _ _
| | | | | | || | _ /| | | |/ // /
| |_| | |__| || | | | | |_| |/ /
| ___/____|_||_|_| |_|/____|/_//_/
| |
|_|

For further information check:
http://www.uclinux.org/

Execution Finished, Exiting

Sash command shell (version 1.1.1)
/> ls
bin
dev
etc
home
lib
mnt
proc
ramdisk
sbin
tmp
usr
var
/> cd bin
/bin> ls
arp
basename
busybox
date
dmesg
du
expand
ftp
hostname
ifconfig
inetd
init
mount
ping
route
sh
telnet
telnetd
tftp
tftpd
umount
uptime
/bin>

 from:  http://v1.bbs.zol.com.cn/frmView.php?u2=http://bbs.zol.com.cn/index20060621/index_86_110770.html 

原创粉丝点击