返回信息流编的一个驱动,用的是2.6.22内核,交叉编译器是arm-linux-gcc 3.4.1。
下面是我的makefile文件:
KERNELDIR :=/home/arm/linux-2.6.22.19
PWD :=$(shell pwd)
CFLAGS =-D__KERNEL__ -DMODULE -I$(KERNELDIR)/include/
CROSS_COMPILE =/home/arm/3.4.1/bin/arm-linux-
CC =$(CROSS_COMPILE)gcc
obj-m := mydev_driver.o
mydev_driver.o : s3c2440_mydev.o
$(CC) $(CFLAGS) -c $^ -o $@
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
modules_install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
clean:
rm -rf *.o *.ko *.mod.o *.mod.c
make的时候,提示的错误信息如下:
debian:/home/arm-drivers/mydev-drviver# make
/home/arm/3.4.1/bin/arm-linux-gcc -D__KERNEL__ -DMODULE -I/home/arm/linux-2.6.22.19/include/ -c -o s3c2440_mydev.o s3c2440_mydev.c
In file included from /home/arm/linux-2.6.22.19/include/linux/notifier.h:14,
from /home/arm/linux-2.6.22.19/include/linux/memory_hotplug.h:7,
from /home/arm/linux-2.6.22.19/include/linux/mmzone.h:466,
from /home/arm/linux-2.6.22.19/include/linux/gfp.h:4,
from /home/arm/linux-2.6.22.19/include/linux/slab.h:14,
from /home/arm/linux-2.6.22.19/include/linux/percpu.h:5,
from /home/arm/linux-2.6.22.19/include/asm-generic/local.h:4,
from /home/arm/linux-2.6.22.19/include/asm/local.h:1,
from /home/arm/linux-2.6.22.19/include/linux/module.h:19,
from s3c2440_mydev.h:7,
from s3c2440_mydev.c:1:
/home/arm/linux-2.6.22.19/include/linux/rwsem.h:24:65: asm/rwsem.h: No such file or directory
In file included from /home/arm/linux-2.6.22.19/include/linux/memory_hotplug.h:7,
from /home/arm/linux-2.6.22.19/include/linux/mmzone.h:466,
from /home/arm/linux-2.6.22.19/include/linux/gfp.h:4,
from /home/arm/linux-2.6.22.19/include/linux/slab.h:14,
from /home/arm/linux-2.6.22.19/include/linux/percpu.h:5,
from /home/arm/linux-2.6.22.19/include/asm-generic/local.h:4,
from /home/arm/linux-2.6.22.19/include/asm/local.h:1,
from /home/arm/linux-2.6.22.19/include/linux/module.h:19,
from s3c2440_mydev.h:7,
from s3c2440_mydev.c:1:
/home/arm/linux-2.6.22.19/include/linux/notifier.h:62: error: field `rwsem' has incomplete type
In file included from /home/arm/linux-2.6.22.19/include/linux/sched.h:51,
from /home/arm/linux-2.6.22.19/include/asm/uaccess.h:14,
from s3c2440_mydev.h:13,
from s3c2440_mydev.c:1:
/home/arm/linux-2.6.22.19/include/linux/jiffies.h:33:3: #error You lose.
/home/arm/linux-2.6.22.19/include/linux/jiffies.h:225:31: division by zero in #if
/home/arm/linux-2.6.22.19/include/linux/jiffies.h:225:31: division by zero in #if
/home/arm/linux-2.6.22.19/include/linux/jiffies.h:225:31: division by zero in #if
/home/arm/linux-2.6.22.19/include/linux/jiffies.h:225:31: division by zero in #if
/home/arm/linux-2.6.22.19/include/linux/jiffies.h:225:31: division by zero in #if
/home/arm/linux-2.6.22.19/include/linux/jiffies.h:225:31: division by zero in #if
/home/arm/linux-2.6.22.19/include/linux/jiffies.h:225:31: division by zero in #if
/home/arm/linux-2.6.22.19/include/linux/jiffies.h:225:31: division by zero in #if
/home/arm/linux-2.6.22.19/include/linux/jiffies.h:225:31: division by zero in #if
/home/arm/linux-2.6.22.19/include/linux/jiffies.h:225:31: division by zero in #if
/home/arm/linux-2.6.22.19/include/linux/jiffies.h:225:31: division by zero in #if
/home/arm/linux-2.6.22.19/include/linux/jiffies.h:225:31: division by zero in #if
/home/arm/linux-2.6.22.19/include/linux/jiffies.h:225:31: division by zero in #if
/home/arm/linux-2.6.22.19/include/linux/jiffies.h:225:31: division by zero in #if
/home/arm/linux-2.6.22.19/include/linux/jiffies.h:225:31: division by zero in #if
/home/arm/linux-2.6.22.19/include/linux/jiffies.h:225:31: division by zero in #if
In file included from /home/arm/linux-2.6.22.19/include/asm/uaccess.h:14,
from s3c2440_mydev.h:13,
from s3c2440_mydev.c:1:
/home/arm/linux-2.6.22.19/include/linux/sched.h:339: error: field `mmap_sem' has incomplete type
In file included from mac_headers.h:66,
from s3c2440_mydev.h:33,
from s3c2440_mydev.c:1:
2440_headers/2440lib.h:19:1: warning: "min" redefined
In file included from /home/arm/linux-2.6.22.19/include/linux/spinlock.h:53,
from /home/arm/linux-2.6.22.19/include/linux/module.h:9,
from s3c2440_mydev.h:7,
from s3c2440_mydev.c:1:
/home/arm/linux-2.6.22.19/include/linux/kernel.h:285:1: warning: this is the location of the previous definition
In file included from mac_headers.h:66,
from s3c2440_mydev.h:33,
from s3c2440_mydev.c:1:
s3c2440_mydev.c: At top level:
s3c2440_mydev.c:225: error: storage size of `s3c2440_mydev_fops' isn't known
make: *** [s3c2440_mydev.o] Error 1
还有一些warning没列出来。
s3c2440_mydev.h中包含的前几个头文件是:
#include <linux/init.h>
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/hardware.h>
我已经指定了内核源码的路径了,为什么会有这些错误呢?提示的错误都是在发生在内核代码里面。
2.6下驱动编译还能用-D__KERNEL__ -DMODULE选项吗?我把这个选项去掉错误就更多了。
大家帮忙看看,谢谢!
这是一条镜像帖。来源:北邮人论坛 / embedded-system / #5197同步于 2009/6/24
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Embedded_System机器人发帖
[求助]arm linux驱动make发生的错误,大家帮忙看看
jennymasar
2009/6/24镜像同步11 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
我原来的makefile里有
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
是不是差不多?
我感觉问题应该出在这里:
obj-m := mydev_driver.o
mydev_driver.o : s3c2440_mydev.o
$(CC) $(CFLAGS) -c $^ -o $@
如果我这样写obj-m := s3c2440_mydev.o ,就可以生成 s3c2440_mydev.ko文件。
要编译的模块涉及到多个源文件,各源文件之间又有些依赖关系,应该怎么来写?
【 在 lester98 的大作中提到: 】
: 你是想变成可加载的内核模块么?这样试一下:
: make -C/kernel_path SUBDIRS=$PWD modules
此外,我用过的makefile如下,倒是比较简单,就一个.c和一个.h,仅供参考
--------------------------------------------------------------------------------------------------------------
# Standard Makefile patten when compile extern module in 2.6 Kernel
# Extern module means: moudles not stored in code tree
#edit by hobby
obj-m := netdrv.o
netdrv-objs := vsc7398drv.o
#The code tree path
KERNELDIR = /usr/src/linux-2.6.13
#The crruent dir
PWD := $(shell pwd)
#the cmd executed when type "make"
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
#the cmd executed when type "make clean"
clean:
rm -rf *.o *.ko *.mod.c
rm:
rm -rf *.c *.h *.o *.ko *.mod.c
--------------------------------------------------------------------------------------------
【 在 jennymasar 的大作中提到: 】
: 我原来的makefile里有
: modules:
: $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
: ...................
这个就不太了解了,如果你查到的话可以分享一下
我按照hobby的模板,没有上面的错误了,主要是之前
obj-m := mydev_driver.o
mydev_driver.o : s3c2440_mydev.o
$(CC) $(CFLAGS) -c $^ -o $@
改成
obj-m := mydev_driver.o
mydev_driver-objs := a.o b.o c.o
现在遇到一个新问题,我在a.h里定义了一些全局变量,在a.c中会用到。
make的时候会提示
WARNING : “…” […] is COMMON symbol
但是还可以生成.ko文件。
insmod的时候,提示 please compile with -fno-common,加载失败。
应该怎么告诉make compile with -fno-common?怎么把这个参数传给make?感觉这个应该是gcc的参数?
还有一点不太明白,一个make命令执行过程中什么时候编译?什么时候连接?
【 在 jennymasar 的大作中提到: 】
: 现在遇到一个新问题,我在a.h里定义了一些全局变量,在a.c中会用到。
: make的时候会提示
: WARNING : “…” […] is COMMON symbol
: ...................
为什么要在.h里定义全局变量?非得这样不可吗?这个习惯非常不好啊.
那全局变量一般在哪定义?我一直都这么用[em9]
【 在 lester98 的大作中提到: 】
: 为什么要在.h里定义全局变量?非得这样不可吗?这个习惯非常不好啊.