查看: 5186|回复: 3

linux2.6下的设备驱动问题

[复制链接]
发表于 2009-4-24 14:49:32 | 显示全部楼层 |阅读模式
关键词: linux , 驱动 , 设备
这是C文件

#include
#include
MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void)
{
        printk(KERN_ALERT "hello,world\n");
        return 0;
}

static void hello_exit(void)
{
        printk(KERN_ALERT "Goodbye,cruel world\n");
}

module_init(hello_init);
module_exit(hello_exit);
~                           


下面是makefile

CC =/usr/local/arm/bin/arm-linux-gcc
KERNELDIR=/home/work/linux2.6
CFLAGS =-D__KERNEL__ -DMODULE -I$(KERNELDIR)/include -O -Wall

hello.hello.c

        $(CC)$(CFLAGS)  -g -c $<

clean:



这时报错:

/usr/local/arm/bin/arm-linux-gcc -D__KERNEL__ -DMODULE -I/home/work/linux2.6/include -O -Wall  -g -c hello.c   
In file included from /home/work/linux2.6/include/asm/hardware.h:16,
                 from /home/work/linux2.6/include/asm/arch/memory.h:24,
                 from /home/work/linux2.6/include/asm/memory.h:27,
                 from /home/work/linux2.6/include/asm/system.h:6,
                 from /home/work/linux2.6/include/asm/bitops.h:23,
                 from /home/work/linux2.6/include/linux/bitops.h:9,
                 from /home/work/linux2.6/include/linux/thread_info.h:20,
                 from /home/work/linux2.6/include/linux/preempt.h:9,
                 from /home/work/linux2.6/include/linux/spinlock.h:49,
                 from /home/work/linux2.6/include/linux/module.h:9,
                 from hello.c:2:
/home/work/linux2.6/include/asm/arch/hardware.h:30:2: #error "Unsupported AT91 processor"
In file included from /home/work/linux2.6/include/linux/bitops.h:9,
                 from /home/work/linux2.6/include/linux/thread_info.h:20,
                 from /home/work/linux2.6/include/linux/preempt.h:9,
                 from /home/work/linux2.6/include/linux/spinlock.h:49,
                 from /home/work/linux2.6/include/linux/module.h:9,
                 from hello.c:2:
/home/work/linux2.6/include/asm/bitops.h: In function `____atomic_set_bit':
/home/work/linux2.6/include/asm/bitops.h:40: warning: implicit declaration of function `local_irq_save'
/home/work/linux2.6/include/asm/bitops.h:42: warning: implicit declaration of function `local_irq_restore'
In file included from /home/work/linux2.6/include/linux/kobject.h:25,
                 from /home/work/linux2.6/include/linux/module.h:17,
                 from hello.c:2:
/home/work/linux2.6/include/linux/rwsem.h:24:65: asm/rwsem.h: No such file or directory
In file included from /home/work/linux2.6/include/linux/module.h:17,
                 from hello.c:2:
/home/work/linux2.6/include/linux/kobject.h: At top level:
/home/work/linux2.6/include/linux/kobject.h:178: error: field `rwsem' has incomplete type
In file included from /home/work/linux2.6/include/linux/memory_hotplug.h:7,
                 from /home/work/linux2.6/include/linux/mmzone.h:463,
                 from /home/work/linux2.6/include/linux/gfp.h:4,
                 from /home/work/linux2.6/include/linux/slab.h:14,
                 from /home/work/linux2.6/include/linux/percpu.h:5,
                 from /home/work/linux2.6/include/asm-generic/local.h:4,
                 from /home/work/linux2.6/include/asm/local.h:1,
                 from /home/work/linux2.6/include/linux/module.h:19,
                 from hello.c:2:
/home/work/linux2.6/include/linux/notifier.h:62: error: field `rwsem' has incomplete type
In file included from /home/work/linux2.6/include/asm/io.h:76,
                 from /home/work/linux2.6/include/asm/arch/irqs.h:24,
                 from /home/work/linux2.6/include/asm/irq.h:4,
                 from /home/work/linux2.6/include/asm/hardirq.h:6,
                 from /home/work/linux2.6/include/linux/hardirq.h:7,
                 from /home/work/linux2.6/include/asm-generic/local.h:5,
                 from /home/work/linux2.6/include/asm/local.h:1,
                 from /home/work/linux2.6/include/linux/module.h:19,
                 from hello.c:2:
/home/work/linux2.6/include/asm/arch/io.h: In function `at91_sys_read':
/home/work/linux2.6/include/asm/arch/io.h:36: error: `AT91_BASE_SYS' undeclared (first use in this function)
/home/work/linux2.6/include/asm/arch/io.h:36: error: (Each undeclared identifier is reported only once
/home/work/linux2.6/include/asm/arch/io.h:36: error: for each function it appears in.)
/home/work/linux2.6/include/asm/arch/io.h: In function `at91_sys_write':
/home/work/linux2.6/include/asm/arch/io.h:43: error: `AT91_BASE_SYS' undeclared (first use in this function)
make: *** [hello.o] 错误 1



到底是什么原因,版主和朋友们能不能帮个忙,谢谢了
发表于 2009-4-24 17:32:26 | 显示全部楼层
回复1楼chengnokia


#error "Unsupported AT91 processor"

楼主使用的处理器是AT91系列的吗?最好是找一个支持该处理器或开发板的Linux整个包,自己移植太累了
发表于 2009-4-24 19:06:48 | 显示全部楼层
谢谢阿南!!!
发表于 2009-4-27 12:01:58 | 显示全部楼层
老郭客气
应该的,嘿嘿
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关于我们  -  服务条款  -  使用指南  -  站点地图  -  友情链接  -  联系我们
电子工程网 © 版权所有   京ICP备16069177号 | 京公网安备11010502021702
快速回复 返回顶部 返回列表