驱动编译遇挫,求大虾帮忙

lingdulebaishi 2012-09-13 01:54:34
飞凌Linux3.0.1里的drivers里找出来的led驱动,驱动没问题,仅作参考,主要是把C文件拿到内核外用我的Makefile编译,会出错,求解决
#include <linux/miscdevice.h>
#include <linux/delay.h>
#include <asm/irq.h>
//#include <mach/regs-gpio.h>
#include <mach/hardware.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/mm.h>
#include <linux/fs.h>
#include <linux/types.h>
#include <linux/delay.h>
#include <linux/moduleparam.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/ioctl.h>
#include <linux/cdev.h>
#include <linux/string.h>
#include <linux/list.h>
#include <linux/pci.h>
#include <asm/uaccess.h>
#include <asm/atomic.h>
#include <asm/unistd.h>

#include <mach/map.h>
#include <mach/regs-clock.h>
#include <mach/regs-gpio.h>

#include <plat/gpio-cfg.h>
#include <mach/gpio-bank-e.h>
#include <mach/gpio-bank-m.h>

#define DEVICE_NAME "leds"

static long s3c6410_leds_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
switch(cmd) {
unsigned tmp;
case 0:
case 1:
if (arg > 4)
{
return -EINVAL;
}
tmp = readl(S3C64XX_GPMDAT);

if(cmd==0) //close light
{
tmp &= (~(1<<arg));
}
else //open light
{
tmp |= (1<<arg);
}

writel(tmp,S3C64XX_GPMDAT);

printk (DEVICE_NAME": %d %d\n", arg, cmd);
return 0;
default:
return -EINVAL;
}
}

static struct file_operations dev_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = s3c6410_leds_ioctl,
};

static struct miscdevice misc = {
.minor = MISC_DYNAMIC_MINOR,
.name = DEVICE_NAME,
.fops = &dev_fops,
};

static int __init dev_init(void)
{
int ret;

unsigned tmp;

//gpm0-3 pull up
tmp = readl(S3C64XX_GPMPUD);
tmp &= (~0xFF);
tmp |= 0xaa;
writel(tmp,S3C64XX_GPMPUD);

//gpm0-3 output mode
tmp =readl(S3C64XX_GPMCON);
tmp &= (~0xFFFF);
tmp |= 0x1111;
writel(tmp,S3C64XX_GPMCON);

//gpm0-3 output 0
tmp = __raw_readl(S3C64XX_GPMDAT);
tmp |= 0x10;
writel(tmp,S3C64XX_GPMDAT);

ret = misc_register(&misc);
printk ("\n@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
printk (DEVICE_NAME"\tinitialized\n");
printk ("\n@@@@@@@@@@@@@@@@@@@@@@@@@@\n");

return ret;
}

static void __exit dev_exit(void)
{
misc_deregister(&misc);
}

module_init(dev_init);
module_exit(dev_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("FORLINX Inc.");


附我的Makefile文件:

obj-m := ./ok6410_leds.o
PWD := $(shell pwd)
KERNEL_LOCATION = /system/linux-3.0.1
#KERNEL_LOCATION ?= /lib/modules/$(shell uname -r)/build
all:
make -C $(KERNEL_LOCATION) M=$(PWD) modules

clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions



编译时候遇到的错误如下:
[root@zhangwei zw_test]# make
make -C /system/linux-3.0.1 M=/nfs/zw_test modules
make[1]: Entering directory `/system/[color=#FF0000]linux-3.0.1' CC [M] /nfs/zw_test/./ok6410_leds.o
/nfs/zw_test/./ok6410_leds.c: In function 's3c6410_leds_ioctl':
/nfs/zw_test/./ok6410_leds.c:58: warning: format '%d' expects type 'int', but argument 2 has type 'long unsigned int'
/bin/sh: scripts/basic/fixdep: cannot execute binary file
make[2]: *** [/nfs/zw_test/./ok6410_leds.o] 错误 126
make[1]: *** [_module_/nfs/zw_test] 错误 2
make[1]: Leaving directory `/system/linux-3.0.1'
make: *** [all] 错误 2[/color]
[root@zhangwei zw_test]#

希望谁能帮我解决一下,我自己编写的驱动编译会这样报错,所以找了官方的驱动,确认代码没问题(能够编译正确,正常制作系统镜像),希望哪位大虾帮解决啊
我的arm-linux-gcc版本是4.3.2,原来装过一个低版本的3.4.1,后来我直接把arm那个文件夹删了,重新解压了官方的arm-linux-gcc4.3.2,更改了环境变量PATH,现在能够编译在OK6410板子上执行的程序,我的编译环境应该没什么问题吧
我的情况说清楚了,希望哪位大虾出点主意
...全文
133 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lingdulebaishi 2012-09-14
  • 打赏
  • 举报
回复
谢谢大哥了,我那个Linux内核没有编译,费了我不少周折,谢谢大哥了
deep_pro 2012-09-13
  • 打赏
  • 举报
回复
首先,保证你的/system/linux-3.0.1 是已经执行过make的
其次验证工具链配对,执行个arm-xxx-gcc -v


Makefile需要定义ARCH 和工具链前缀,沾一个我正在用的,其实也没啥大区别


ARCH = mips
CC = mips64el-linux-gcc
DEBFLAGS=-O2
obj-m += xio2221-eeprom.o
KERNELDIR ?= /home/xy/3a/linux-loongson3a-2.6.36-bnc
PWD :=$(shell pwd)



all:
make -C $(KERNELDIR) M=$(PWD) modules

clean:
make -C $(KERNELDIR) M=$(PWD) clean

4,436

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧