前些日子在 skyeye 上 porting 了 arm-linux,于是迫不及待的写了一个 module 试试,可很不幸,没有成功。小弟最近才搞 linux 的 module 技术,很多地方不是很懂,现将问题贴出,希望大家不吝赐教。
skyeye(version 1.2.4) 的配置文件 skyeye.conf:
===============================================
cpu: arm920t
mach: s3c2410x
# physical memory
mem_bank: map=M, type=RW, addr=0xc0000000, size=0x00800000
mem_bank: map=M, type=RW, addr=0xc0800000, size=0x00800000, file=initrd.img
mem_bank: map=M, type=RW, addr=0xc1000000, size=0x01000000
# all peripherals I/O mapping area
mem_bank: map=I, type=RW, addr=0x48000000, size=0x20000000
mem_bank: map=I, type=RW, addr=0x19000300, size=0x00000020
#net: type=cs8900a, base=0x19000300, size=0x20,int=9, mac=0:4:3:2:1:f, ethmod=tuntap, hostip=10.0.0.1
#lcd: type=s3c2410x, mod=gtk
#dbct:state=on
Module 源代码:
=========================================
/*hello.c*/
#include <linux/module.h>
#include <linux/kernel.h>
MODULE_LICENSE("GPL");
int __init my_init_module(void)
{
printk (KERN_INFO "Hello world\n");
return 0;
}
void __exit my_cleanup_module(void)
{
printk (KERN_INFO "Goodbye world\n");
}
module_init(my_init_module);
module_exit(my_cleanup_module);
Makefile
=========================================
#Makefile
ifeq ($(KERNELRELEASE),)
KERNELDIR ?= /root/kernel/2.6/linux-2.6.14
PWD := $(shell pwd)
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
modules_install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
.PHONY: modules modules_install clean
else
obj-m := hello.o
endif
insmod 出错:
=========================================
# insmod hello.ko
Unable to handle kernel paging request at virtual address bf000000
pgd = c02a8000
[bf000000] *pgd=00000000
Internal error: Oops: 807 [#1]
Modules linked in:
CPU: 0
PC is at __memzero+0x24/0x80
LR is at __init_begin+0x3fff8000/0x2c
pc : [<c00cfc84>] lr : [<00000000>] Not tainted
sp : c0279e68 ip : 00000000 fp : c0279fa4
r10: 00000280 r9 : c0185604 r8 : c29012c8
r7 : 00000004 r6 : c29010e0 r5 : c2901520 r4 : 00000010
r3 : 00000000 r2 : 00000000 r1 : 000003e0 r0 : bf000000
Flags: nzCv IRQs on FIQs on Mode SVC_32 Segment user
Control: 317F Table: C02A8000 DAC: 00000015
Process insmod (pid: 33, stack limit = 0xc0278194)
Stack: (0xc0279e68 to 0xc027a000)
9e60: c004818c c0279ebc c0279e7c c002651c 00000000 00000000
9e80: 00000100 00000000 00000000 c1a744b0 000000fa 000000fa c0206180 c028c05f
9ea0: c0e43f80 0000003c 00000038 00000024 bf000000 00000000 00000000 00000000
9ec0: 00000006 00000000 00000009 00000000 00000000 00000000 0000000f 0000000e
9ee0: c2901768 c2901244 c2901000 c0278000 c005a8c8 c005a2f0 c026dc08 c02a8000
9f00: c0279f20 c0279f10 c00ac9b4 c02a8000 00000000 ffffffeb c0e45080 c0019964
9f20: c001b040 c001b070 00000002 c0e45080 c0279f74 c0279f40 c0026950 c00cc964
9f40: 00000000 c0268040 00000000 00000000 bea47ecc 001c5498 00000000 c0279fb0
9f60: 00000006 001c5478 c0279f9c c0279f78 c0026a24 c00267f0 c0268040 00000805
9f80: 0019b650 001c5478 00000080 c001fec4 c0278000 001c5478 00000000 c0279fa8
9fa0: c001fd40 c0047a9c 0019b650 001c5478 00900080 001c5670 00000805 001c5498
9fc0: 00000805 0019b650 001c5478 00000000 001c5488 00000006 001c5478 bea47ec4
9fe0: bea478ac bea478a0 0001b73c 00102230 a0000010 00900080 00000000 00000000
Backtrace:
[<c0047a90>] (sys_init_module+0x0/0x16b4) from [<c001fd40>] (ret_fast_syscall+0x0/0x2c)
Code: e52de004 e1a0c002 e1a0e002 e2511040 (a8a0500c)
Segmentation fault