【问题标题】:Compiling UVC kernel module out of source tree against running kernel针对正在运行的内核从源代码树中编译 UVC 内核模块
【发布时间】:2023-01-09 18:14:59
【问题描述】:

我正在尝试对 UVC 内核模块进行修改,然后将其插入到我正在运行的内核中。为此,我执行了以下步骤:

  1. 使用sudo apt install linux-headers-$(uname -r) 安装 linux-headers
  2. Linux kernel GitHub repository 检查 UVC 驱动程序文件夹
  3. 进入目录并尝试使用 kernel.org 文档中 Building External Modules 指定的 make -C /lib/modules/`uname -r`/build M=$PWD 进行编译。

但是我从 Make 那里得到了这个错误,抱怨它无法从上面的树中找到一个包含(我没有检查过)

me@bionic:~/src/media/usb/uvc$ make -C /lib/modules/`uname -r`/build M=$PWD
make: Entering directory '/usr/src/linux-headers-5.4.0-131-generic'
  CC [M]  /home/me/src/media/usb/uvc/uvc_driver.o
/home/me/src/media/usb/uvc/uvc_driver.c:23:10: fatal error: media/v4l2-uvc.h: No such file or directory
 #include <media/v4l2-uvc.h>
          ^~~~~~~~~~~~~~~~~~
compilation terminated.
scripts/Makefile.build:270: recipe for target '/home/me/src/media/usb/uvc/uvc_driver.o' failed
make[1]: *** [/home/me/src/media/usb/uvc/uvc_driver.o] Error 1
Makefile:1762: recipe for target '/home/me/src/media/usb/uvc' failed
make: *** [/home/me/src/media/usb/uvc] Error 2
make: Leaving directory '/usr/src/linux-headers-5.4.0-131-generic'

但是它不应该能够从我正在运行的内核中找到这个包含(由-C /lib/modules/`uname -r`/build提供)吗?我怎样才能编译这个内核模块?

UVC 文件夹中的 Makefile 包含:

# SPDX-License-Identifier: GPL-2.0
uvcvideo-objs  := uvc_driver.o uvc_queue.o uvc_v4l2.o uvc_video.o uvc_ctrl.o \
          uvc_status.o uvc_isight.o uvc_debugfs.o uvc_metadata.o
ifeq ($(CONFIG_MEDIA_CONTROLLER),y)
uvcvideo-objs  += uvc_entity.o
endif
obj-$(CONFIG_USB_VIDEO_CLASS) += uvcvideo.o

Kconfig 文件包含:

config USB_VIDEO_CLASS
    tristate "USB Video Class (UVC)"
    depends on VIDEO_V4L2
    select VIDEOBUF2_VMALLOC
    ---help---
      Support for the USB Video Class (UVC).  Currently only video
      input devices, such as webcams, are supported.

      For more information see: <http://linux-uvc.berlios.de/>

config USB_VIDEO_CLASS_INPUT_EVDEV
    bool "UVC input events device support"
    default y
    depends on USB_VIDEO_CLASS
    depends on USB_VIDEO_CLASS=INPUT || INPUT=y
    ---help---
      This option makes USB Video Class devices register an input device
      to report button events.

      If you are in doubt, say Y.

【问题讨论】:

    标签: linux-kernel


    【解决方案1】:

    类似的问题,如何编译这个模块?

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-14
    • 2021-07-16
    • 1970-01-01
    相关资源
    最近更新 更多