Uclinux 内核编译傻瓜教程
插曲:SDT 下程序调适经验
在 SDT 工程下面的.alf 文件都是库文件,有了这些库文件后与之相对应的.c
原文件就不需要加载进入工程,否则会导致工程调试时出现程序跑飞的情况。
比方说如果已经加入了 44blib.alf 文件,则不需要再加入 44blib.c 文件,如果加
入程序通过 jtag 调试必然跑飞,去掉则没有问题!
当然在 ADS 中是没有.alf 库文件的,那么就需要加入相应的.c 文件!!
内核的编译过程我想大家都知道了,就是
make menuconfig
进入内核配置菜单进行删改,结束保存后进行
make dep
make clean
make lib_only
make user_only
make romfs
make image
make
基本上按照立宇泰给的 uclinux 内核文件和交叉编译器就能够完成整个编译内核
的工作,只不过也许由于内核版本不同会产生一些不同的结果,主要还是功能
方面的!此次编译内核需要完成的功能包括文件系统 ext2 的挂载,网络驱动,
基本的 cash 命令,lcd frambuffer 功能,串口功能。当然你也可以实现更多的文
件系统的挂载识别和更多驱动功能,但是内核及文件系统必然增大,这里只是
实现基本的一些驱动功能,希望借此给各位一些帮助!
1. 编译 armsys-c 的 uclinux 内核及文件系统。
原先 armsys-c 的 uclinux 内核文件说明如下:
没有经过压缩的内核文件大小为 1.8M;经过压缩的内核为 0.9M,其经过解
压后进入 SDRAM 区后应该还是具有 1.8M 大小;文件系统大小为 0.8M 左右。
这里要注意的是必须按照手册上说的地址下载,否则 uclinux 无法启动,原
因应该是其编译生成的内核文件及文件系统文件在编译过程中已经加入了
ro-base 及 rm-base,所以程序启动的时候会相应寻找其地址,如果不对则无法
启动。不过我会通过重新编译内核时更改其值,验证设想!
以下是下载 imageram.bin 的过程,内核下载后再下载 romfsimag.bin 即完成
整个下载过程,并让程序 Pc 指向内核起始地址启动 uclinux!
启动好了的内核及文件系统:
对内核进行删改,并于原内核进行比对,发现一些问题。
and
shared
lib
XIP
patches
以下是原版的内核启动过程,作为对比标准!
Plese wait a moment to start running...Linux version 2.4.24-uc0 (root@xujing) (g
cc version 2.95.3 20010315 (release)(ColdFire patches - 20010318 from http://fid
des.net/coldfire/)(uClinux
from
http://www.snapgear.c
om/)) #355 五 11 月 26 03:10:23 CST 2004
Processor: Samsung S3C44B0X revision 0
Architecture: S3C44B0X
On node 0 totalpages: 2048
zone(0): 0 pages.
zone(1): 2048 pages.
zone(2): 0 pages.
Kernel command line: root=/dev/rom0 init=/linuxrc
Console: colour dummy device 80x30
Calibrating delay loop... 31.84 BogoMIPS
Memory: 8MB = 8MB total
Memory: 6072KB available (1715K code, 206K data, 60K init)
Dentry cache hash table entries: 1024 (order: 1, 8192 bytes)
Inode cache hash table entries: 512 (order: 0, 4096 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: 2048 (order: 1, 8192 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
ttyS0 at I/O 0x1d00000 (irq = 3) is a S3C44B0
ttyS1 at I/O 0x1d04000 (irq = 2) is a S3C44B0
LCD buffer : 0c260000
ne.c:v1.10 9/23/94 Donald Becker (becker@scyld.com)
Last modified Nov 1, 2000 by Paul Gortmaker
NE*000 ethercard probe at 0x8000000: 52 54 ab 12 34 56
eth0: NE1000 found at 0x8000000, using IRQ 22
Blkmem copyright 1998,1999 D. Jeff Dionne
Blkmem copyright 1998 Kenneth Albanowski
Blkmem 1 disk images:
0: C500000-C5B3FFF [VIRTUAL C500000-C5B3FFF] (RO)
RAMDISK driver initialized: 16 RAM disks of 1024K size 1024 blocksize
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 512 bind 512)
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
VFS: Mounted root (romfs filesystem) readonly.
Freeing init memory: 60K
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: cat /etc/motd
Welcome to
____ _ _
/ __| ||_|
_ _| | | | _ ____ _ _ _ _
| | | | | | || | _ \| | | |\ \/ /
| |_| | |__| || | | | | |_| |/ \
| ___\____|_||_|_| |_|\____|\_/\_/
| |
|_|
For further information check:
http://www.uclinux.org/
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.253.2 netmask 255.255.255.0 up
Command:
Execution Finished, Exiting
Sash command shell (version 1.1.1)
2. 在 menuconfig 的选项中添加 tcp/ip,内核及文件系统下载后结果如下:
其中在 CORE MENU 中添加的选项为
该部分内核及根文件为*1.bin
A:
B:-
C:
shared
lib
and
patches
在 MAIN MENU 选项中未添加。
编译后的下载的结果如下:
Plese wait a moment to start running...Linux version 2.4.24-uc0 (root@localhost)
(gcc version 2.95.3 20010315 (release)(ColdFire patches - 20010318 from http://
fiddes.net/coldfire/)(uClinux XIP
from
http://www.snapgea
r.com/)) #365 Thu Jan 27 16:18:15 EST 2005
Processor: Samsung S3C44B0X revision 0
Architecture: S3C44B0X
On node 0 totalpages: 2048
zone(0): 0 pages.
zone(1): 2048 pages.
zone(2): 0 pages.
Kernel command line: root=/dev/rom0 init=/linuxrc
Calibrating delay loop... 31.84 BogoMIPS
Memory: 8MB = 8MB total
Memory: 6144KB available (1714K code, 156K data, 44K init)
Dentry cache hash table entries: 1024 (order: 1, 8192 bytes)
Inode cache hash table entries: 512 (order: 0, 4096 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: 2048 (order: 1, 8192 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
ttyS0 at I/O 0x1d00000 (irq = 3) is a S3C44B0
ttyS1 at I/O 0x1d04000 (irq = 2) is a S3C44B0
ne.c:v1.10 9/23/94 Donald Becker (becker@scyld.com)
Last modified Nov 1, 2000 by Paul Gortmaker
NE*000 ethercard probe at 0x8000000: 52 54 ab 12 34 56
eth0: NE1000 found at 0x8000000, using IRQ 22
Blkmem copyright 1998,1999 D. Jeff Dionne
Blkmem copyright 1998 Kenneth Albanowski
Blkmem 1 disk images:
0: C500000-C5F93FF [VIRTUAL C500000-C5F93FF] (RO)
RAMDISK driver initialized: 16 RAM disks of 1024K size 1024 blocksize
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 512 bind 512)
IP-Config: Incomplete network configuration information.
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
VFS: Mounted root (romfs filesystem) readonly.
Freeing init memory: 44K
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
mount: Mounting /dev/ram0 on /var failed: No such device
pid 12: failed 256
Command: mount -t ext2 /dev/ram1 /ramdisk
mount: Mounting /dev/ram1 on /ramdisk failed: No such device
pid 13: failed 256
Command: chmod 777 /ramdisk
/ramdisk: Read-only file system
Command: mkdir /var/config
/var/config: Read-only file system
Command: mkdir /var/tmp
/var/tmp: Read-only file system
Command: mkdir /var/log
/var/log: Read-only file system
Command: mkdir /var/run
/var/run: Read-only file system
Command: mkdir /var/lock
/var/lock: Read-only file system
Command: cat /etc/motd
Welcome to
____ _ _
/ __| ||_|
_ _| | | | _ ____ _ _ _ _
| | | | | | || | _ \| | | |\ \/ /
| |_| | |__| || | | | | |_| |/ \
| ___\____|_||_|_| |_|\____|\_/\_/
| |
|_|
For further information check:
http://www.uclinux.org/
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.253.2 netmask 255.255.255.0 up
Command:
Execution Finished, Exiting
Sash command shell (version 1.1.1)
/>
3. 第三次变编译内核,加入以下选项:
编译文件为*2.bin
编译选项更改如下:
A--