内核不能加载模块
我是在写字符设备驱动时,遇到了这个问题,当 我第一次把模块添加到内核后,在根文件系统下测试模块加载和运行都正常,我也是按照网上提供的入门级的例程编写的,hello_module 和 leds 字符设备驱动,这两个经过测试能正常工作,可是当我把 buttons 字符设备驱动也加进去时,在根文件系统下测试该设备不能正常工作,无耐之下,我又回头测试HELLO_MODULE 和leds 时,也不能正常运行了,不知道是什么问题,请大家帮忙看下,不胜感激!!
出错信息如下,供参考:
insmod: cannot open module `fs2410_hello_module.ko': No such file or directory
可是我已经在内核中添加了该模块,还出来这个问题。
open leds device: No such file or directory
上面的是LEDS的驱动测试产生的错误信息,我在dev 下也看到了leds ,
# pwd
/dev/misc
# ls
apm_biosleds psaux
可是为什么还提示找不到文件呢??
在线等 !! 向成名求救了呀 刚才对内核进行了make clean后,重新编译,可问题依然存在 1)你看看你的内核支持不支持动态加载功能?
2)你这个ko文件放在那里呢?insmod的本目录下?
查看内核模块用lsmod,看看内核有吗? 我使用的是devfs设备文件系统,并且在根文件系统下的/dev/misc/leds 找到该设备,
那个KO文件,我是在内核的CHAR目录存放,第一次用的时候加载成功,
我在移植BUSYBOX时没有添加lsmod命令,赶快加上,
还有为什么我的/proc目录为空呢, 那个ko文件加载成功,但leds 不能加载 再问,为什么我的没有/proc//module/sys//module这两个文件,只是个空的目录,在动行模块测试程序时仍然
提示 no file or directoty ,请达人帮下忙!! 怎么没有人解答呢??:( /proc 目录是内存镜像。就是里边的文件实际上是内存。。。(文件系统的文件包含很多东西)。
你用cat看下 /proc//module还应该是有东西的。(即使是0byte,因为它不占存储空间,就是个链接,可以这么理解)
/sys目录也是个生成目录。具体啥我忘了,懒的查了。
至于说为什么加载不上模块,你得看看更多的信息。
比如:
#ls -al
看看权限,等对不对。
把你所有的操作和回显复制上来也可。 出现这种奇怪的问题多半是在不理解概念的情况下有一步错误操作造成的。 我的也是遇到了这个问题
#insmod s3c24xx_hello_module
insmod: cannot insert 's3c24xx_hello_module': unknown symbol in module, or unknown parameter
奇怪,一直都是按照教程做的啊,不知道哪里出问题了? 我想起来一个事:这么模块命名似乎是有规定的,不符合规定的不能加载。
大家再反复看看ldd。(千万别看翻译完的。。。。) 再问,为什么我的没有/proc//module/sys//module这两个文件,只是个空的目录,在动行模块测试程序时仍然
提示 no file or directoty ,请达人帮下忙!!
fang_zi 发表于 2009-8-29 12:21 https://bbs.21ic.com/images/common/back.gif
/proc/sys都是内核支持并由驱动生成具体的子文件。看下内核选项里是否支持 /proc 和 /sys 虚拟文件系统 那些选项我都选了,我又看了下我的的根文件启动信息,挂载时的输出为
VFS: Mounted root (nfs filesystem).
Mounted devfs on /dev
Freeing init memory: 96K
Bummer, could not run '/etc/init.d/rcS': No such
BusyBox v1.1.3 (2009.08.31-07:10+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
set search library path init /etc/profile
set user path in /etc/profile
出现了那个rcS找不到错误信息,那不就说明我的脚本初始化没有执行,虚拟文件系统也没有挂载,导致了
/proc/sys 目录为空的原因,
用GOOGLE也没有找到解决的办法,我用的是BUSYBOX-1.。1
GCC-3.3.2 , 并且用的是ASH,该如何解决这个问题呀 Starting kernel ...
Uncompressing Linux.............................................................
Linux version 2.6.14.1 (fangzi@localhost.localdomain) (gcc version 3.4.5) #13 S9
CPU: ARM920Tid(wb) revision 0 (ARMv4T)
Machine: SMDK2410
Memory policy: ECC disabled, Data cache writeback
CPU S3C2410A (id 0x32410002)
S3C2410: core 200.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz
S3C2410 Clocks, (c) 2004 Simtec Electronics
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
Built 1 zonelists
Kernel command line: root=/dev/nfs rw nfsroot=192.168.1.112:/home/fangzi/nfs ip0
irq: clearing subpending status 00000002
PID hash table entries: 512 (order: 9, 8192 bytes)
timer tcon=00500000, tcnt a2c1, tcfg 00000200,00000000, usec 00001eb8
Console: colour dummy device 80x30
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 64MB = 64MB total
Memory: 62336KB available (1913K code, 438K data, 96K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
softlockup thread 0 started up.
NET: Registered protocol family 16
S3C2410: Initialising architecture
usbcore: registered new driver usbfs
usbcore: registered new driver hub
S3C2410 DMA Driver, (c) 2003-2004 Simtec Electronics
DMA channel 0 at c4800000, irq 33
DMA channel 1 at c4800040, irq 34
DMA channel 2 at c4800080, irq 35
DMA channel 3 at c48000c0, irq 36
NetWinder Floating Point Emulator V0.97 (double precision)
devfs: 2004-01-31 Richard Gooch (rgooch@atnf.csiro.au)
devfs: boot_options: 0x1
Initializing Cryptographic API
Console: switching to colour frame buffer device 80x25
fb0: Virtual frame buffer device, using 1024K of video memory
S3C2410 RTC, (c) 2004 Simtec Electronics
s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2410
s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2410
s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2410
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
Cirrus Logic CS8900A driver for Linux (Modified for SMDK2410)
eth0: CS8900A rev E at 0xe0000300 irq=53, no eeprom , addr: 08: 0:3E:26:0A:5B
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c2410-nand: mapped registers at c4980000
s3c2410-nand: timing: Tacls 10ns, Twrph0 40ns, Twrph1 10ns
NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bi)
NAND_ECC_NONE selected by board driver. This is not recommended !!
Scanning device for bad blocks
Creating 4 MTD partitions on "NAND 64MiB 3,3V 8-bit":
0x00000000-0x00100000 : "bootloader"
0x00100000-0x00400000 : "kernel"
0x00400000-0x02c00000 : "root"
0x02d00000-0x03c00000 : "user"
usbmon: debugfs is not available
mice: PS/2 mouse device common for all mice
oprofile: using timer interrupt.
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 2, 16384 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
TCP bic registered
NET: Registered protocol family 1
IP-Config: Complete:
device=eth0, addr=192.168.1.108, mask=255.255.255.0, gw=192.168.1.1,
host=192.168.1.108, domain=, nis-domain=(none),
bootserver=192.168.1.112, rootserver=192.168.1.112, rootpath=
Looking up port of RPC 100003/2 on 192.168.1.112
Looking up port of RPC 100005/1 on 192.168.1.112
VFS: Mounted root (nfs filesystem).
Mounted devfs on /dev
Freeing init memory: 96K
mount all
mount: Mounting tmpfs on /dev/shm failed: No such file or directory
Please press Enter to activate this console.
BusyBox v1.1.3 (2009.09.01-01:40+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
set search library path init /etc/profile
set user path in /etc/profile
#
#
老大们,这是我的启动信息,不知道我的根文件系统做的对不?
# ls
bin home linuxrc.bakroot tmp
dev lib mnt sbin usr
etc linuxrc proc sys
# cd usr
# ls
all fs2410_hello_module.kolib
bin fs2410_leds.ko sbin
# insmod fs2410_leds.ko
ledsinitialize !
# all 2 0
open leds device: No such file or directory
# cat /proc/modules
fs2410_leds 2208 0 - Live 0xbf000000
# cat /sys/module
cat: Read Error: Is a directory
# rmmod fs2410_leds
# cat /proc/modules
# pwd
/usr
#
这是我加载模块的信息,在/proc/modules下找到了加载的模块 ,为什么在执行的时候提示
open leds device: No such file or directory
这个模块也能卸掉的,请指点下,
谢谢了 需在/dev下建立设备节点
然后才可open设备进行操作、测试等 需在/dev下建立设备节点
然后才可open设备进行操作、测试等
goosen 发表于 2009-9-2 19:51 https://bbs.21ic.com/images/common/back.gif
正解。
除非内核支持udev,否则要自己在文件系统里/dev下建立设备节点。 我用的是devfs ,加载模块后再/dev目录也能找到,可就 是运行测试程序进找不到,郁闷!
另外还有一个紧急的问题,我在动态编译模块时,出现了错误,
# make
make -C /lib/modules/2.6.14.1/build M= /home/fangzi/buttons modules
make: Entering directory `/home/fangzi/linux-2.6.14.1'
make: Nothing to be done for `/home/fangzi/buttons'.
CHK include/linux/version.h
make: “include/asm-arm/mach-types.h”是最新的。
CHK include/linux/compile.h
SKIPPED include/linux/compile.h
CHK usr/initramfs_list
Building modules, stage 2.
MODPOST
make: Leaving directory `/home/fangzi/linux-2.6.14.1'
# ll
总计 36
-rwxr--r-- 1 fangzi fangzi 1027 09-03 17:45 buttons_test.c
-rwxr--r-- 1 fangzi fangzi 4826 09-03 17:45 fs2410_buttons.c
-rwxr--r-- 1 fangzi fangzi382 09-03 17:45 Makefile
-rwxr--r-- 1 fangzi fangzi154 09-03 17:45 Makefile.C
#
执行了MAKE后没有生成.ko文件和其它文件,我的makefile文件是
#ifneq ($(KERNELRELEASE),)
obj-m += fs2410_buttons.o
#else
KERNELDIR := /lib/modules/2.6.14.1/build
PWD := $(shell pwd)
all:
make -C $(KERNELDIR) M= $(PWD) modules
#modules_install:
# $(MAKE) -C $(KERNELDIR) M= $(PWD) modules_intall
clean:
-rm-rf *.ko *.o *.symvers *.mod.c *.cmd .tmp_versions *~core.depend.
#endif
也看了很多makefile文件格式,就是不能正确编译,如果makefile文件没有错误的话,是不是还有可能别的地方出错??
页:
[1]