使用 dkms 构建内核模块,缺少标头

使用 dkms 构建内核模块,缺少标头

如果有人能帮助我,我将不胜感激。

1)我正在尝试使用 dkms 为 Ubuntu 服务器构建内核模块。详细手册是这里

2)当使用以下语法构建模块时:

sudo dkms build -m ixgbevf -v 2.15.3

它说,一些内核头丢失了:

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area....(bad exit status: 2)
cd src/; make BUILD_KERNEL=....(bad exit status: 2)
ERROR (dkms apport): binary package for ixgbevf: 2.15.3 not found
Error! Bad return status for module build on kernel: 3.13.0-36-generic (x86_64)
Consult /var/lib/dkms/ixgbevf/2.15.3/build/make.log for more information.

3)日志文件:/var/lib/dkms/ixgbevf/2.15.3/build/make.log:

DKMS make.log for ixgbevf-2.15.3 for kernel 3.13.0-36-generic (x86_64)
Tue Dec 23 09:27:47 UTC 2014
Makefile:64: *** Kernel header files not in any of the expected locations.
Makefile:65: *** Install the appropriate kernel development package, e.g.
Makefile:66: *** kernel-devel, for building kernel modules and try again.  Stop.

4)我这里有标题:

/usr/src/linux-headers-3.13.0-36
/usr/src/linux-headers-3.13.0-36-generic
/usr/include

cpp -v 显示:

#include <...> search starts here:
 /usr/lib/gcc/x86_64-linux-gnu/4.8/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include

如果您需要更多信息,我会立即为您提供。谢谢。

--- 添加信息 ---

1) dpkg -l | dpkg -l | grep linux-headers 显示:

ii  linux-headers-3.13.0-36          3.13.0-36.63                         all          Header files related to Linux kernel version 3.13.0
ii  linux-headers-3.13.0-36-generic  3.13.0-36.63                         amd64        Linux kernel headers for version 3.13.0 on 64 bit x86 SMP
ii  linux-headers-generic            3.13.0.36.43                         amd64        Generic Linux kernel headers
ii  linux-headers-virtual            3.13.0.36.43                         amd64        Transitional package.

2) dpkg -l | 的输出信息grep linux 图像

ii  linux-image-3.13.0-36-generic    3.13.0-36.63                         amd64        Linux kernel image for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-virtual              3.13.0.36.43                         amd64        This package will always depend on the latest minimal generic kernel image.

3) uname -a 的输出

Linux ip-10-0-3-11 3.13.0-36-generic #63-Ubuntu SMP Wed Sep 3 21:30:07 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

4) ixgbevf 模块源的链接是这里

答案1

Ubuntu14.04有补丁发布https://gist.github.com/cdgraff/1c31727901e5c76d5ea8

我可以确认它正在工作:

root@ip-172-31-119-53:~# modinfo ixgbevf
filename:       /lib/modules/3.13.0-45-generic/updates/dkms/ixgbevf.ko
version:        2.16.1
license:        GPL
description:    Intel(R) 10 Gigabit Virtual Function Network Driver
author:         Intel Corporation, <[email protected]>
srcversion:     3F8AACF779F38FD444B1CD3
alias:          pci:v00008086d00001515sv*sd*bc*sc*i*
alias:          pci:v00008086d000010EDsv*sd*bc*sc*i*
depends:        
vermagic:       3.13.0-45-generic SMP mod_unload modversions 
parm:           InterruptThrottleRate:Maximum interrupts per second, per    vector, (956-488281, 0=off, 1=dynamic), default 1 (array of int)

答案2

所以,最后,我成功安装了内核版本 3.13.0-43 的驱动程序 ixgbevf v.2.15.3。

但是,有一些重要的点:

  1. 首先,我尝试使用make手动构建它并得到相同的结果:

    Makefile:64: *** Kernel header files not in any of the expected locations.
    Makefile:65: *** Install the appropriate kernel development package, e.g.
    Makefile:66: *** kernel-devel, for building kernel modules and try again.  Stop.
    
  2. 其次,我运行apt-get upgrade并将apt-get dist-upgrade内核从 3.13.0-36 更新到 3.13.0-43,然后重新启动计算机以更新内核。详细信息是这里。它还安装了 3.13.0-43 的内核头文件。

  3. 第三,我必须更改 dkms.conf 配置文件,如下所示:

    MAKE="make -C src/ KERNELDIR=/lib/modules/${kernelver}/build"
    CLEAN="make -C src/ clean"
    BUILT_MODULE_NAME=ixgbevf
    BUILT_MODULE_LOCATION=src/
    DEST_MODULE_LOCATION="/updates"
    PACKAGE_NAME=ixgbevf-dkms
    PACKAGE_VERSION=2.15.3
    REMAKE_INITRD=no
    

之后,就可以构建驱动程序了。如果您有同样的问题并需要帮助,请随时与我联系。 @Faheem Mitha,非常感谢您的帮助。

相关内容