1. skull_init.c和skull_clean.c源码见Linux Device Driver(3rd Edition)源码
2. 我的Makefile文件
# Kernel Programming
# Michael Yao
# The path of kernel source code
KERNELDIR = /opt/friendly_ARM/mini2440/linux-2.6.29 #内核源码安装目录
#currnet path
PWD := $(shell pwd)
# Compiler
CROSS_COMPILE = /usr/local/arm/4.3.2/bin/arm-none-linux-gnueabi-
CC = $(CROSS_COMPILE)gcc
# Compilation Options
ifdef CONFIG_SMP
CFLAGS +=-D__SMP__ -DSMP
endif
CFLAGS +=
obj-m := skull.o
skull-objs := skull_init.o skull_clean.o
all:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
install:
cp skull.ko /tftpboot #已经安装并启动tftp服务
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions module*.* Module.*
.PHONY:all install clean
|
3.make时出错
#错误1: /home/michael/LDD3/LDD3_ARM/skull/skull_init.c:23:26: error: linux/config.h: No such file or directory
/home/michael/LDD3/LDD3_ARM/skull/skull_init.c: In function 'skull_init':
#错误2: /home/michael/LDD3/LDD3_ARM/skull/skull_init.c:141: error: implicit declaration of function 'save_flags'
#错误3: /home/michael/LDD3/LDD3_ARM/skull/skull_init.c:142: error: implicit declaration of function 'cli'
#错误4: /home/michael/LDD3/LDD3_ARM/skull/skull_init.c:148: error: implicit declaration of function 'restore_flags'
|
#错误1
-->原因:
The file include/linux/config.h has been removed from 2.6.19 kernel.
-->解决:
1、把#include <linux/config.h>修改为如下:
#ifndef _LINUX_CONFIG_H
#define _LINUX_CONFIG_H
#include <linux/autoconf.h>
#endif
|
2、直接删掉#include
3、touch一个空的linux/config.h
#错误2, 3, 4
-->原因:
save_flags() is replaced with local_irq_save() and
restore_flags() replaced with local_irq_restore()
cli() replaced with local_irq_disable()
至于从linux内核的哪个版本开始被替换就没有去考证了
-->解决
:让原因描述的替换即可
4. 解决问题后再次编译,ok
5. tftp下载skull.ko到目标板/tmp目录,装载skull.ko出现错误如下:(原因未知,待考证)
a0000: empty
a0800: empty
a1000: empty
a1800: empty
a2000: empty
a2800: empty
a3000: empty
a3800: empty
a4000: empty
a4800: empty
a5000: empty
a5800: empty
a6000: empty
a6800: empty
a7000: empty
a7800: empty
a8000: empty
a8800: empty
a9000: empty
a9800: empty
aa000: empty
aa800: empty
ab000: empty
ab800: empty
ac000: empty
ac800: empty
ad000: empty
ad800: empty
ae000: empty
ae800: empty
af000: empty
af800: empty
b0000: empty
b0800: empty
b1000: empty
b1800: empty
b2000: empty
b2800: empty
b3000: empty
b3800: empty
b4000: empty
b4800: empty
b5000: empty
b5800: empty
b6000: empty
b6800: empty
b7000: empty
b7800: empty
b8000: empty
b8800: empty
b9000: empty
b9800: empty
ba000: empty
ba800: empty
bb000: empty
bb800: empty
bc000: empty
bc800: empty
bd000: empty
bd800: empty
be000: empty
be800: empty
bf000: empty
bf800: empty
c0000: empty
c0800: empty
c1000: empty
c1800: empty
c2000: empty
c2800: empty
c3000: empty
c3800: empty
c4000: empty
c4800: empty
c5000: empty
c5800: empty
c6000: empty
c6800: empty
c7000: empty
c7800: empty
c8000: empty
c8800: empty
c9000: empty
c9800: empty
ca000: empty
ca800: empty
cb000: empty
cb800: empty
cc000: empty
cc800: empty
cd000: empty
cd800: empty
ce000: empty
ce800: empty
cf000: empty
cf800: empty
d0000: empty
d0800: empty
d1000: empty
d1800: empty
d2000: empty
d2800: empty
d3000: empty
d3800: empty
d4000: empty
d4800: empty
d5000: empty
d5800: empty
d6000: empty
d6800: empty
d7000: empty
d7800: empty
d8000: empty
d8800: empty
d9000: empty
d9800: empty
da000: empty
da800: empty
db000: empty
db800: empty
dc000: empty
dc800: empty
dd000: empty
dd800: empty
de000: empty
de800: empty
df000: empty
df800: empty
e0000: empty
e0800: empty
e1000: empty
e1800: empty
e2000: empty
e2800: empty
e3000: empty
e3800: empty
e4000: empty
e4800: empty
e5000: empty
e5800: empty
e6000: empty
e6800: empty
e7000: empty
e7800: empty
e8000: empty
e8800: empty
e9000: empty
e9800: empty
ea000: empty
ea800: empty
eb000: empty
eb800: empty
ec000: empty
ec800: empty
ed000: empty
ed800: empty
ee000: empty
ee800: empty
ef000: empty
ef800: empty
f0000: empty
f0800: empty
f1000: empty
f1800: empty
f2000: empty
f2800: empty
f3000: empty
f3800: empty
f4000: empty
f4800: empty
f5000: empty
f5800: empty
f6000: empty
f6800: empty
f7000: empty
f7800: empty
f8000: empty
f8800: empty
f9000: empty
f9800: empty
fa000: empty
fa800: empty
fb000: empty
fb800: empty
fc000: empty
fc800: empty
fd000: empty
fd800: empty
fe000: empty
fe800: empty
ff000: empty
ff800: empty
|
阅读(759) | 评论(0) | 转发(0) |