USB驱动程序编译错误 [英] USB Driver Compilation Error
问题描述
我目前正在尝试编译一个Linux USB UART驱动程序,在这里提供:
http://www.exar.com/connectivity/uart-and-bridging-solutions/usb-uarts/xr21v1410
驱动程序包含2个头文件和一个大C文件。这些是Makefile的内容:
obj-m:= vizzini.o
KERNELDIR? = / lib / modules / $(shell uname -r)/ build
PWD:= $(shell pwd)
EXTRA_CFLAGS:= -DDEBUG = 0
all:
$(MAKE)-C $(KERNELDIR)M = $(PWD)
modules_install:
$(MAKE)-C $(KERNELDIR)M = $ PWD)modules_install
clean:
rm -rf * .o *〜core .depend。*。cmd * .ko * .mod.c .tmp_versions vtty
这是编译器在运行make时抛出的错误:
[sj755 @ localhost xr21v141x-lnx-2.6.35-pak] $ make
make -C /lib/modules/3.4.9-2.fc16.x86_64/build M = /home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak
make [1]:输入目录`/usr/src/kernels/3.4.9-2.fc16.x86_64'
LD /home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/built-in.o
CC [M] /home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.o
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1643:9:warning:从不兼容的指针类型初始化[默认启用]
/ home / sj755 /下载/ xr21v141x-lnx-2.6.35-pak / vizzini.c:1643:9:warning:(接近初始化'vizzini_device.ioctl')[默认启用]
/ home / sj755 / Downloads / xr21v141x- lnx-2.6.35-pak / vizzini.c:1646:9:警告:从不兼容的指针类型初始化[默认启用]
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini .c:1646:9:warning:('vizzini_device.tiocmget'的初始化附近)[默认启用]
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1647 :9:warning:从不兼容的指针类型初始化[默认启用]
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1647:9:warning: 'vizzini_device.tiocmset')[默认启用]
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:在函数'vizzini_init':
/ home / sj755 /Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1663:9:错误:函数'usb_serial_register'的隐含声明[-Werror = implicit-function-declaration]
/ home / sj755 /下载/xr21v141x-lnx-2.6.35-pak/vizzini.c:1677:9:错误:函数的隐式声明'usb_serial_deregister'[-Werror = implicit-function-declaration]
/ home / sj755 / Downloads / xr21v141x -lnx-2.6.35-pak / vizzini.c:在函数'__check_debug':
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1698:83:warning:从不兼容的指针类型返回[默认启用]
cc1:一些警告被视为错误
make [2]:*** [/home/sj755/Downloads/xr21v141x-lnx-2.6.35- pak / vizzini.o]错误1
make [1]:*** [_module_ / home / sj755 / Downloads / xr21v141x-lnx-2.6.35-pak]错误2
make [1]离开目录`/usr/src/kernels/3.4.9-2.fc16.x86_64'
make:*** [all]错误2
这些是包含在主要c源文件中的头文件:
include< linux / kernel.h>
#include< linux / jiffies.h>
#include< linux / errno.h>
#include< linux / tty.h>
#include< linux / tty_flip.h>
#include< linux / module.h>
#include< linux / usb.h>
#include< linux / usb / serial.h>
#include< linux / serial.h>
#include< linux / slab.h>
#include< asm / unaligned.h>
#include
#include< linux / usb / cdc.h>
#ifndef CDC_DATA_INTERFACE_TYPE
#define CDC_DATA_INTERFACE_TYPE 0x0a
#endif
#ifndef USB_RT_ACM
#define USB_RT_ACM(USB_TYPE_CLASS | USB_RECIP_INTERFACE)
#define ACM_CTRL_DTR 0x01
#define ACM_CTRL_RTS 0x02
#define ACM_CTRL_DCD 0x01
#define ACM_CTRL_DSR 0x02
#define ACM_CTRL_BRK 0x04
#define ACM_CTRL_RI 0x08
#define ACM_CTRL_FRAMING 0x10
#define ACM_CTRL_PARITY 0x20
#define ACM_CTRL_OVERRUN 0x40
#endif
#includelinux / version.h
#includevizzini.h
运行Linux内核3.4.9-2.fc16.x86_64
我非常感谢您帮助解决错误。
EDIT
似乎在我的内核的API中从未定义过 usb_serial_register
和 usb_serial_deregister
但是, usb_serial_register_drivers
和 usb_serial_deregister_drivers
是。以下是定义:
int usb_serial_register(struct usb_serial_driver * driver);
void usb_serial_deregister(struct usb_serial_driver * device);
int usb_serial_register_drivers(struct usb_driver * udriver,
struct usb_serial_driver * const serial_drivers []);
void usb_serial_deregister_drivers(struct usb_driver * udriver,
struct usb_serial_driver * const serial_drivers []);
解决方案内核中的API(可用的头文件,内容,函数原型(或者如果它们存在于第一位),...)是不固定的(参见 Documentation / stable_api_nonsense.txt 在您最近的Linux中源代码,如果你很好奇),所以驱动程序通常只能编译一个相当狭窄的内核范围。检查源是否与内核(大致)同时。
您还应该检查是否已经在内核中包含了驱动程序,或者作为官方驱动程序或在分级区域中。查看 Linux USB ,查看其他驱动程序和其他新闻。如果没有其他帮助,您应该查看 LWN 的内核页面(在那里搜索您无法找到的功能当前源和关于替换的讨论),可能在使用像cscope之类的东西创建您的源(内核和驱动程序)的索引之后。请与负责此地区的人取得联系,以便他们知道您正在摸索,或许可以提供一些指导。
I'm currently trying to compile a Linux USB UART driver, which is provided here:
http://www.exar.com/connectivity/uart-and-bridging-solutions/usb-uarts/xr21v1410
The driver consists of 2 header files and one large C file. These are the contents of the Makefile:
obj-m := vizzini.o
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
EXTRA_CFLAGS := -DDEBUG=0
all:
$(MAKE) -C $(KERNELDIR) M=$(PWD)
modules_install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions vtty
This is the error the compiler is throwing when I run make:
[sj755@localhost xr21v141x-lnx-2.6.35-pak]$ make
make -C /lib/modules/3.4.9-2.fc16.x86_64/build M=/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak
make[1]: Entering directory `/usr/src/kernels/3.4.9-2.fc16.x86_64'
LD /home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/built-in.o
CC [M] /home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.o
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1643:9: warning: initialization from incompatible pointer type [enabled by default]
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1643:9: warning: (near initialization for ‘vizzini_device.ioctl’) [enabled by default]
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1646:9: warning: initialization from incompatible pointer type [enabled by default]
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1646:9: warning: (near initialization for ‘vizzini_device.tiocmget’) [enabled by default]
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1647:9: warning: initialization from incompatible pointer type [enabled by default]
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1647:9: warning: (near initialization for ‘vizzini_device.tiocmset’) [enabled by default]
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c: In function ‘vizzini_init’:
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1663:9: error: implicit declaration of function ‘usb_serial_register’ [-Werror=implicit-function-declaration]
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1677:9: error: implicit declaration of function ‘usb_serial_deregister’ [-Werror=implicit-function-declaration]
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c: In function ‘__check_debug’:
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1698:83: warning: return from incompatible pointer type [enabled by default]
cc1: some warnings being treated as errors
make[2]: *** [/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.o] Error 1
make[1]: *** [_module_/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak] Error 2
make[1]: Leaving directory `/usr/src/kernels/3.4.9-2.fc16.x86_64'
make: *** [all] Error 2
These are the headers included in the main c source file:
#include <linux/kernel.h>
#include <linux/jiffies.h>
#include <linux/errno.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/module.h>
#include <linux/usb.h>
#include <linux/usb/serial.h>
#include <linux/serial.h>
#include <linux/slab.h>
#include <asm/unaligned.h>
#include <asm/uaccess.h>
#include <linux/usb/cdc.h>
#ifndef CDC_DATA_INTERFACE_TYPE
#define CDC_DATA_INTERFACE_TYPE 0x0a
#endif
#ifndef USB_RT_ACM
#define USB_RT_ACM (USB_TYPE_CLASS | USB_RECIP_INTERFACE)
#define ACM_CTRL_DTR 0x01
#define ACM_CTRL_RTS 0x02
#define ACM_CTRL_DCD 0x01
#define ACM_CTRL_DSR 0x02
#define ACM_CTRL_BRK 0x04
#define ACM_CTRL_RI 0x08
#define ACM_CTRL_FRAMING 0x10
#define ACM_CTRL_PARITY 0x20
#define ACM_CTRL_OVERRUN 0x40
#endif
#include "linux/version.h"
#include "vizzini.h"
Running Linux kernel 3.4.9-2.fc16.x86_64
I would greatly appreciate any help in resolving the errors.
EDIT
It seems that usb_serial_register
and usb_serial_deregister
were never defined in my kernel's API. However, usb_serial_register_drivers
and usb_serial_deregister_drivers
are. Below are the definitions:
int usb_serial_register(struct usb_serial_driver *driver);
void usb_serial_deregister(struct usb_serial_driver *device);
int usb_serial_register_drivers(struct usb_driver *udriver,
struct usb_serial_driver * const serial_drivers[]);
void usb_serial_deregister_drivers(struct usb_driver *udriver,
struct usb_serial_driver * const serial_drivers[]);
解决方案 The API inside the kernel (available header files, their contents, function prototypes (or if they exist in the first place), ...) is not fixed (see Documentation/stable_api_nonsense.txt in your nearest Linux source if you are curious), so a driver can typically only be compiled for a rather narrow range of kernels. Check if the source is (roughly) contemporary with the kernel.
You should also check if a driver for that has already been included in the kernel, either as an official driver or in the staging area. Look around Linux USB to check for alternative drivers and other news. If nothing else helps, you should take a look at LWN's kernel pages (search there for functions you can't find in the current source and discussion on replacement), probably after using something like cscope to create an index of your source (kernel and driver). Please do get in touch with the people responsible for this area, so they know you are groping around and perhaps give some pointers.
这篇关于USB驱动程序编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!