打印

led驱动发生错误

[复制链接]
1536|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
chen_yuan|  楼主 | 2007-9-2 13:52 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我在编译led驱动程序时,出现了下面错误:
arm-linux-gcc -O2 -Wall -D__KERNEL__ -DMODULE -I/zylinux/kernel/include -I. -march=armv4t -c -o -mapcs -c magic-leds.c -o magic-leds.o
In file included from /zylinux/kernel/include/asm/hardware.h:18,
                 from magic-leds.c:48:
/usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/sys-include/asm/arch/hardware.h:16: asm/mach-types.h: ?????????
make: *** [magic-leds.o] Error 1
请知道如何改正的朋友帮我一下,谢谢!

相关帖子

沙发
chen_yuan|  楼主 | 2007-9-3 14:17 | 只看该作者

为何没人帮忙啊

同主题

使用特权

评论回复
板凳
wangkj| | 2007-9-3 15:06 | 只看该作者

信息不全

使用特权

评论回复
地板
chen_yuan|  楼主 | 2007-9-3 15:29 | 只看该作者

led驱动发生错误

Makefile:
EXEC = leds.ko 
OBJS = magic-leds.o 
SRC  = magic-leds.c 

INCLUDE = /zylinux/kernel/include
USEINC =.
CC = arm-linux-gcc
LD = arm-linux-ld
MODCFLAGS = -O2 -Wall -D__KERNEL__ -DMODULE -I$(INCLUDE) -I$(USEINC) -march=armv4t -c -o
LDFLAGS = -r

all: $(EXEC)

$(EXEC): $(OBJS)
    $(LD) $(LDFLAGS) -o $@ $(OBJS)

%.o:%.c
    $(CC) $(MODCFLAGS) -mapcs -c $< -o $@

clean:
    -rm -f $(EXEC) *.o *~ core

cross_2.95.3.tar.bz2已经安装好:/usr/local/arm/下,环境变量已经设置好,编译其它的程序(不是驱动程序)都是可以用的。linux为redhat9.0,内核为:2.4.20-8

magic-leds.c:

#ifndef __KERNEL__
    #define __KERNEL__
#endif

#ifndef MODULE
    #define MODULE
#endif

#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/sched.h>

#include <asm/hardware.h>

#define DEVICE_NAME    "magic-leds"
//#define LED_MAJOR       231    //can be 231~239 or 240~254

static unsigned long leds_table [] = 
{
    GPIO_E11,
    GPIO_E12,
    GPIO_H4,
    GPIO_H6,
    GPIO_H10,
};


static int magic_leds_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg)
{
    if (arg > 4) return -EINVAL;

    switch(cmd) 
    {
        case 0:
        case 1:
            write_gpio_bit(leds_table[arg], cmd);
        default:
            return -EINVAL;
    }
}

static int magic_leds_open(struct inode *inode, struct file *filp)
{
    int i;

    for (i = 0; i < 5; i++)
    {
        set_gpio_ctrl (leds_table | GPIO_PULLUP_EN | GPIO_MODE_OUT);
        write_gpio_bit(leds_table, 1);
    }

    MOD_INC_USE_COUNT;
    printk(KERN_INFO DEVICE_NAME ": opened. ");
    return 0;
}


static int magic_leds_release(struct inode *inode, struct file *filp)
{
    MOD_DEC_USE_COUNT;
    printk(KERN_INFO DEVICE_NAME ": released. ");
    return 0;
}

static struct file_operations magic_leds_fops = 
{
    owner:    THIS_MODULE,
    ioctl:  magic_leds_ioctl,
    open:    magic_leds_open,
    release:    magic_leds_release,
};


static devfs_handle_t devfs_handle;
static int __init magic_leds_init(void)
{
//    int result;

//    result =  register_chrdev(0, DEVICE_NAME, &magic_leds_fops);
//    if (result < 0) 
//    {
//          printk(KERN_ERR DEVICE_NAME ": Failed to register major. ");
//          return result;
//    }
    devfs_handle = devfs_register(NULL, DEVICE_NAME, DEVFS_FL_AUTO_DEVNUM,
        0, 0, S_IFCHR | S_IRUSR | S_IWUSR, &magic_leds_fops, NULL);

    printk(KERN_INFO DEVICE_NAME ": Initialize OK. ");
    return 0;
}

static void __exit magic_leds_exit(void)
{
    devfs_unregister(devfs_handle);
//    unregister_chrdev(0, DEVICE_NAME);
}

module_init(magic_leds_init);
module_exit(magic_leds_exit);

使用特权

评论回复
5
chen_yuan|  楼主 | 2007-9-3 18:36 | 只看该作者

帮帮我呀

如题!

使用特权

评论回复
6
阿南| | 2007-9-3 19:44 | 只看该作者

看看magic-leds.c文件第48行是什么东东?

看看/zylinux/kernel/include/asm/hardware.h文件的第18行是什么东东
还有.......arm-linux/sys-include/asm/arch/hardware.h的第16行

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

4

主题

14

帖子

1

粉丝