QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1428|回复: 1

高手救命:linux-2.6.14内核的奇怪问题

[复制链接]
发表于 2006-7-6 11:00:20 | 显示全部楼层 |阅读模式
高手救命:linux-2.6.14内核的奇怪问题
(由于问题严重,google也搜索不到有价值的参考信息,所以此处描述繁多,目的在于方便各位高手帮我确定问题所在)

请问各位友人:

一        我制作的ramdisk与在开发板上可以正常工作的linux-2.6.7内核配合使用时,可以正常工作,并进入到shell提示,其启动信息如表1。我在内核的linux-2.6.7/fs/exec.c文件的do_execve()函数开头加入了打印信息“printk("do_execve(%s)\n", filename);”,并在busybox/applets/applets.c文件的run_applet_by_name ()函数开头加入了打印信息“printf("run_applet_by_name()\n\n");”。当我在命令行下输入"ls"命令时,其输出信息如下,并且系统全部运行正常,ramdisk的lib,以及busybox都没任何问题,这点已经通过实际使用得到了验证。

/ # ls
do_execve(/bin/ls)
busybox run_applet_by_name()
bin         etc         linuxrc     proc        tmp         var
dev         lib         lost+found  sbin        usr
/ #

二        问题来了,当这个ramdisk与我自己针对开发板移植的linux-2.6.14内核配合使用时就不正常工作,不能直接进入shell提示,其启动信息如表2。问题应该出在我的内核里,这点我也明白,但我不知道究竟是内核什么地方引起了这个现象,望高手给我指点一二。

表2:        不正常工作的linux-2.6.14系统启动信息
============================================================================================================================
Uncompressing Linux............................................. done, booting the kernel.
              Linux version 2.6.14 ([email protected]) (gcc version 3.3.4) #223 Wed Jul 5 19:27:34 CST 2006
CPU: FA526id(wb) [66015261] revision 1 (ARMv4)
ICache:16KB enabled, DCache:16KB enabled
CPU: FA526id(wb) [66015261] revision 1 (ARMv4)
Machine: source
Memory policy: ECC disabled, Data cache writeback
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 2, 16 byte lines, 512 sets
CPU0: D cache: 16384 bytes, associativity 2, 16 byte lines, 512 sets
Built 1 zonelists
Kernel command line: root=/dev/ram0 mem=32M
PID hash table entries: 256 (order: 8, 4096 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 32MB = 32MB total
Memory: 27204KB available (1118K code, 188K data, 72K init)
52.32 BogoMIPS (lpj=261632)
Mount-cache hash table entries: 512
checking if image is initramfs...it isn't (no cpio magic); looks like an initrd
Freeing initrd memory: 3749K
Linux NoNET1.0 for Linux 2.6
NetWinder Floating Point Emulator V0.97 (extended precision)
source Real Time Clock Driver v1.00
Software Watchdog Timer: 0.07 initialized. soft_noboot=0 soft_margin=60 sec (nowayout= 0)
ipmi message handler version 36.0
ipmi device interface
IPMI Watchdog: driver initialized
Serial: SOURCE driver $Revision: 1.00 $ 2 ports, IRQ sharing disabled
ttyS0: detected caps 00000000 should be 00000003
ttyS0 at I/O 0xf7800000 (irq = 10) is a SOURCE
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered
RAMDISK driver initialized: 16 RAM disks of 16384K size 1024 blocksize
mice: PS/2 mouse device common for all mice
RAMDISK: Compressed image found at block 0
VFS: Mounted root (ext2 filesystem) readonly.
Freeing init memory: 72K
run_init_process(/sbin/init)
execve(/sbin/init)
do_execve(/sbin/init)
do_execve(/etc/init.d/rc.sysinit)
do_execve(/bin/echo)
bedo_execve(/bin/mount)
beuwdo_execve(/bin/echo)
bedo_execve(/bin/mount)
beuedo_execve(/bin/echo)
beunuucdo_execve(/bin/hostname)
besdo_execve(/bin/sh)
============================================================================================================================

我同样在内核的linux-2.6.14/fs/exec.c文件的do_execve()函数开头加入了打印信息“printk("do_execve(%s)\n", filename);”,由于ramdisk不变,所以busybox调试信息同上。然后我进行了以下一些动作:

敲击几个 Enter 后,命令行显示信息如下:

c1  mmm nb[/

在命令行上输入"ls",命令行显示信息如下:

c1  mmm nb[/ls

再次敲击 Enter 后,命令行显示信息如下:

do_execve(/bin/ls)
c1  mmm nb[/

在命令行上输入"ls -l",命令行显示信息如下:

c1  mmm nb[/ls -l

再次敲击 Enter 后,命令行显示信息如下:

do_execve(/bin/ls)
dr 5idr 5edr 5tdr 5ilr 5i1r 1odr 1rdr 5bdr 5mdr 5sdr 5a/
c1  mmm nb[/

在命令行上输入"exit",命令行显示信息如下:

c1  mmm nb[/exit

再次敲击 Enter 后,命令行显示信息如下:

do_execve(/bin/sh)
B00hric/

在命令行上输入"ls -l",命令行显示信息如下:

B00hric/ls

再次敲击 Enter 后,命令行显示信息如下:

do_execve(/bin/ls)
c1  mmm nb[/

由以上现象可知,内核打印函数printk()工作正常,“printk("do_execve(%s)\n", filename);”可以正常打印输出。但busybox中的“printf("run_applet_by_name()\n\n");”没有任何输出信息。shell似乎在解释输入的命令,因为内核printk()打印出了我输入的命令,而且执行"ls -l"还有输出信息,说明busybox接收并执行了命令,好像问题就在于不能正常显示busybox执行命令的输出信息。

请各路神仙快快救命啊,我的苍天呀!

表3:        busybox的init进程执行内容
===================================================================================================================
内核初始化到最后一步就是执行busybox-1.00提供的“/sbin/init”,init进程讲完成以下工作:
1.        为init设置信号处理进程;
2.        初始化控制台;
3.        剖析/etc/inittab文件;
4.        执行/etc/inittab中指定的系统初始化命令行,默认情况下会使用/etc/init.d/rcS命令行;
5.        执行所有会导致init暂停的inittab命令;
6.        执行所有仅执行一次的inittab命令;
一旦完成以上工作,init进程便循环执行以下工作:
1.        执行respawn动作;
2.        执行askfirst动作。


表4:        busybox的init进程使用的/etc/inittab文件信息
===================================================================================================================
# system initialisation
::sysinit:/etc/init.d/rc.sysinit

# run gettys on the serial ports
::respawn:/bin/sh

# stuff to do before rebooting
::ctrlaltdel:/etc/init.d/reboot
::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff -a


表5:        busybox的init进程使用的/etc/init.d/rc.sysinit文件信息
===================================================================================================================
#!/bin/sh

PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH

# mount root filesystem in read-write mode
/bin/echo "Mounting root fs rw ..."
/bin/mount -n -o remount,rw /

# mount all other filesystems
/bin/echo "Mounting other filesystems ..."
/bin/mount -a

/bin/echo "Sysinit done"
/bin/hostname FA520


表1:        正常工作的linux-2.6.7系统启动信息
===================================================================================================================
Uncompressing Linux........................................................................................ done, booting the kernel.
Linux version 2.6.7 ([email protected]) (gcc version 3.3.4) #800 Wed Jul 5 19:35:03 CST 2006
CPU: FA526id(wb) [66015261] revision 1 (ARMv4)
ICache:16KB enabled, DCache:16KB enabled, BTB support
CPU: D VIVT write-back cache
CPU: I cache: 16384 bytes, associativity 2, 16 byte lines, 512 sets
CPU: D cache: 16384 bytes, associativity 2, 16 byte lines, 512 sets
Machine: STAR_STR9100
Memory policy: ECC disabled, Data cache writeback
On node 0 totalpages: 8192
  DMA zone: 1024 pages, LIFO batch:1
  Normal zone: 7168 pages, LIFO batch:1
  HighMem zone: 0 pages, LIFO batch:1
Built 1 zonelists
Kernel command line: root=/dev/ram0 mem=32M
PID hash table entries: 256 (order 8: 2048 bytes)
IRQ Timer1 at interrupt number 0x0 and clock 100000000(Hz)
Memory: 32MB = 32MB total
Memory: 25676KB available (2099K code, 763K data, 76K init)
Calibrating delay loop... 153.60 BogoMIPS
Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
checking if image is initramfs...it isn't (no cpio magic); looks like an initrd
Freeing initrd memory: 3750K
NET: Registered protocol family 16
PCI: bus0: Fast back to back transfers disabled
pci bridge found
AHB to bridge interrupt status : 24200000
SCSI subsystem initialized
usbcore: registered new driver usbfs
usbcore: registered new driver hub
NetWinder Floating Point Emulator V0.97 (extended precision)
NTFS driver 2.1.14 [Flags: R/W].
STR9100 Real Time Clock Driver v1.00
Serial: STR9100 driver $Revision: 1.00 $ 1 ports, IRQ sharing disabled
ttyS0 at I/O 0xf7800000 (irq = 10) is a Star_UART
RAMDISK driver initialized: 16 RAM disks of 16348K size 1024 blocksize
Using anticipatory io scheduler
nbd: registered device at major 43
Star 9100 GSW Driver, (Linux Kernel 2.6) 10/18/04 - by Star Semiconductor
init buffer Tx
init buffer Rx
buffer init                           
Agere ET1011 PHY detected in WAN
Star 9100 GSW supports hardware checksum
Init napt 1 init
Init napt 2 init
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
ide0: Star 9100 generic IDE interface
drivers/usb/core/hcd-pci.c: usb-EHCI, EHCI_HCdriver
drivers/usb/core/hcd-pci.c: ehci_hcd (STR9100) at 0xfcc00000, irq 24
drivers/usb/core/hcd.c: new USB bus registered, assigned bus number 1
drivers/usb/host/ehci-hcd.c: USB 2.0 enabled, EHCI 1.00, driver 2004-May-10
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
drivers/usb/host/ohci-str9100.c: usb-OHCI, OHCI_HCdriver
drivers/usb/host/ohci-str9100.c: ohci_hcd (STR9100) at 0xfc400000, irq 23
drivers/usb/core/hcd.c: new USB bus registered, assigned bus number 2
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
NET: Registered protocol family 2
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 2048 bind 4096)
ip_conntrack version 2.1 (256 buckets, 2048 max) - 304 bytes per conntrack
ip_tables: (C) 2000-2002 Netfilter core team
arp_tables: (C) 2002 David S. Miller
NET: Registered protocol family 1
NET: Registered protocol family 17
RAMDISK: Compressed image found at block 0
RAMDISK: incomplete write (28672 != 3276 16711680
VFS: Mounted root (ext2 filesystem) readonly.
Freeing init memory: 76K
run_init_process(/sbin/init)
execve(/sbin/init)
do_execve(/sbin/init)
busybox run_applet_by_name()
do_execve(/etc/init.d/rc.sysinit)
busybox run_applet_by_name()
do_execve(/bin/echo)
busybox run_applet_by_name()
Mounting root fs rdo_execve(/bin/mount)
w ...
busybox run_applet_by_name()
do_execve(/bin/echo)
busybox run_applet_by_name()
Mounting other fildo_execve(/bin/mount)
esystems ...
busybox run_applet_by_name()
do_execve(/bin/echo)
busybox run_applet_by_name()
Sysinit done
do_execve(/bin/hostname)
busybox run_applet_by_name()
do_execve(/bin/sh)
busybox run_applet_by_name()

BusyBox v1.00 (2006.07.04-06:43+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

/ # ls
do_execve(/bin/ls)
busybox run_applet_by_name()
bin         etc         linuxrc     proc        tmp         var
dev         lib         lost+found  sbin        usr
/ #
===================================================================================================================
 楼主| 发表于 2006-7-12 21:25:32 | 显示全部楼层
天啊,高手们怎么不给我指点一二呢?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-2 14:33 , Processed in 0.067229 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表