Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用DKMS本地编译驱动 #2636

Open
LIUBANGJIAN opened this issue Nov 9, 2024 · 9 comments
Open

使用DKMS本地编译驱动 #2636

LIUBANGJIAN opened this issue Nov 9, 2024 · 9 comments

Comments

@LIUBANGJIAN
Copy link

大佬,不好意思又是我。现在先打算把驱动打到现在的系统上面去,先用起来再说,后续再慢慢研究怎么把驱动集成到内核里。

驱动的github:https://github.com/hanwckf/hd2312

按照驱动的大佬的的DKMS方法编译
我输入sudo apt install dkms linux-headers-$(uname -r)提示
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package linux-headers-6.6.59-ophub
E: Couldn't find any package by glob 'linux-headers-6.6.59-ophub'

可是我看/usr/src目录下是有linux-headers-6.6.59-ophub的,是放在这个目录不对,还是要其他设置?请指导一下,再次感谢。

@ophub
Copy link
Owner

ophub commented Nov 10, 2024

安装header这步忽略,已经自带。

内核的补丁你本地打进去即可,或者把patch文件按仓库的说明放在固定目录即可自动添加。

@LIUBANGJIAN
Copy link
Author

输入后续的命令,仍然提示没有 kernel headers 文件
root@N1:/usr/src/hd2312-1.0# dkms build -m hd2312/1.0
Error! Your kernel headers for kernel 6.6.59-ophub cannot be found.
Please install the linux-headers-6.6.59-ophub package or use the --kernelsourcedir option to tell DKMS where it's located.

尝试指定kernel headers文件夹,也还是报错
root@N1:/usr/src/hd2312-1.0# dkms build -m hd2312/1.0 --kernelsourcedir=/usr/src/linux-headers-6.6.59-ophub/
Preparing kernel 6.6.59-ophub for module build:
(This is not compiling a kernel, just preparing kernel symbols)
Running Generic preparation routine
make mrproper...(bad exit status: 2)
Warning: Warning! Cannot find a .config file to prepare your kernel with.
Try using the --config option to specify where one can be found.
Your build will likely fail because of this.
make oldconfig...(bad exit status: 2)
make prepare-all...(bad exit status: 2)
Building module:
cleaning build area...(bad exit status: 2)
make -j4 KERNELRELEASE=6.6.59-ophub all KVERSION=6.6.59-ophub...(bad exit status: 2)
Error! Bad return status for module build on kernel: 6.6.59-ophub (aarch64)
Consult /var/lib/dkms/hd2312/1.0/build/make.log for more information.

请问大佬指点一下。

@wcc467
Copy link

wcc467 commented Nov 14, 2024

编译时找不到头文件, 可能是 /lib/modules/$(uname -r)/build 没有正确连结至 /usr/src/linux-headers-$(uname -r)

至于编译错误, 相信是你用的内核没有打开CONFIG_DVB_USB相关选项, 可以用指令'zgrep CONFIG_DVB_USB= /proc/config.gz'核查一下

我用的内核是6.1.xxx, 可以成功编译驱动:-
armbian:~:# uname -a
Linux armbian 6.1.116-ophub #1 SMP Sun Nov 10 08:21:17 EST 2024 aarch64 aarch64 aarch64 GNU/Linux

armbian:~:# ls -l /lib/modules/$(uname -r)/build
lrwxrwxrwx 1 root root 36 Nov 10 23:18 /lib/modules/6.1.116-ophub/build -> /usr/src/linux-headers-6.1.116-ophub

armbian:~:# zgrep CONFIG_DVB_USB= /proc/config.gz
CONFIG_DVB_USB=m

armbian:~:# dkms add -m hd2312/1.0
Creating symlink /var/lib/dkms/hd2312/1.0/source -> /usr/src/hd2312-1.0

armbian:~:# dkms build -m hd2312/1.0

Kernel preparation unnecessary for this kernel. Skipping...

Building module:
cleaning build area...
make -j4 KERNELRELEASE=6.1.116-ophub all KVERSION=6.1.116-ophub.......
cleaning build area...
armbian:~:# dkms install -m hd2312/1.0

hd2312.ko:
Running module version sanity check.

  • Original module
    • No original module exists within this kernel
  • Installation
    • Installing to /lib/modules/6.1.116-ophub/updates/dkms/

hd2312-fe.ko:
Running module version sanity check.

  • Original module
    • No original module exists within this kernel
  • Installation
    • Installing to /lib/modules/6.1.116-ophub/updates/dkms/

depmod..........

armbian:~:# dkms status
hd2312/1.0, 6.1.116-ophub, aarch64: installed

@LIUBANGJIAN
Copy link
Author

编译时找不到头文件, 可能是 /lib/modules/$(uname -r)/build 没有正确连结至 /usr/src/linux-headers-$(uname -r)

至于编译错误, 相信是你用的内核没有打开CONFIG_DVB_USB相关选项, 可以用指令'zgrep CONFIG_DVB_USB= /proc/config.gz'核查一下

我用的内核是6.1.xxx, 可以成功编译驱动:- armbian:~:# uname -a Linux armbian 6.1.116-ophub #1 SMP Sun Nov 10 08:21:17 EST 2024 aarch64 aarch64 aarch64 GNU/Linux

armbian:~:# ls -l /lib/modules/$(uname -r)/build lrwxrwxrwx 1 root root 36 Nov 10 23:18 /lib/modules/6.1.116-ophub/build -> /usr/src/linux-headers-6.1.116-ophub

armbian:~:# zgrep CONFIG_DVB_USB= /proc/config.gz CONFIG_DVB_USB=m

armbian:~:# dkms add -m hd2312/1.0 Creating symlink /var/lib/dkms/hd2312/1.0/source -> /usr/src/hd2312-1.0

armbian:~:# dkms build -m hd2312/1.0

Kernel preparation unnecessary for this kernel. Skipping...

Building module: cleaning build area... make -j4 KERNELRELEASE=6.1.116-ophub all KVERSION=6.1.116-ophub....... cleaning build area... armbian:~:# dkms install -m hd2312/1.0

hd2312.ko: Running module version sanity check.

  • Original module

    • No original module exists within this kernel
  • Installation

    • Installing to /lib/modules/6.1.116-ophub/updates/dkms/

hd2312-fe.ko: Running module version sanity check.

  • Original module

    • No original module exists within this kernel
  • Installation

    • Installing to /lib/modules/6.1.116-ophub/updates/dkms/

depmod..........

armbian:~:# dkms status hd2312/1.0, 6.1.116-ophub, aarch64: installed

大佬,我n1盒子,帮忙看看。谢谢

root@N1:# uname -a
Linux N1 6.1.116-ophub #1 SMP Thu Nov 14 05:39:28 EST 2024 aarch64 aarch64 aarch64 GNU/Linux
root@N1:
# ls -l /lib/modules/$(uname -r)/build
lrwxrwxrwx 1 root root 9 Nov 15 00:38 /lib/modules/6.1.116-ophub/build -> /usr/src/
root@N1:~# zgrep CONFIG_DVB_USB= /proc/config.gz
CONFIG_DVB_USB=m

@LIUBANGJIAN
Copy link
Author

编译时找不到头文件, 可能是 /lib/modules/$(uname -r)/build 没有正确连结至 /usr/src/linux-headers-$(uname -r)
至于编译错误, 相信是你用的内核没有打开CONFIG_DVB_USB相关选项, 可以用指令'zgrep CONFIG_DVB_USB= /proc/config.gz'核查一下
我用的内核是6.1.xxx, 可以成功编译驱动:- armbian::# uname -a Linux armbian 6.1.116-ophub #1 SMP Sun Nov 10 08:21:17 EST 2024 aarch64 aarch64 aarch64 GNU/Linux
armbian:
:# ls -l /lib/modules/$(uname -r)/build lrwxrwxrwx 1 root root 36 Nov 10 23:18 /lib/modules/6.1.116-ophub/build -> /usr/src/linux-headers-6.1.116-ophub
armbian::# zgrep CONFIG_DVB_USB= /proc/config.gz CONFIG_DVB_USB=m
armbian:
:# dkms add -m hd2312/1.0 Creating symlink /var/lib/dkms/hd2312/1.0/source -> /usr/src/hd2312-1.0
armbian::# dkms build -m hd2312/1.0
Kernel preparation unnecessary for this kernel. Skipping...
Building module: cleaning build area... make -j4 KERNELRELEASE=6.1.116-ophub all KVERSION=6.1.116-ophub....... cleaning build area... armbian:
:# dkms install -m hd2312/1.0
hd2312.ko: Running module version sanity check.

  • Original module

    • No original module exists within this kernel
  • Installation

    • Installing to /lib/modules/6.1.116-ophub/updates/dkms/

hd2312-fe.ko: Running module version sanity check.

  • Original module

    • No original module exists within this kernel
  • Installation

    • Installing to /lib/modules/6.1.116-ophub/updates/dkms/

depmod..........
armbian:~:# dkms status hd2312/1.0, 6.1.116-ophub, aarch64: installed

大佬,我n1盒子,帮忙看看。谢谢

root@N1:# uname -a Linux N1 6.1.116-ophub #1 SMP Thu Nov 14 05:39:28 EST 2024 aarch64 aarch64 aarch64 GNU/Linux root@N1:# ls -l /lib/modules/$(uname -r)/build lrwxrwxrwx 1 root root 9 Nov 15 00:38 /lib/modules/6.1.116-ophub/build -> /usr/src/ root@N1:~# zgrep CONFIG_DVB_USB= /proc/config.gz CONFIG_DVB_USB=m

我重新链接之后也是不行,请大佬指导一下。

root@N1:/usr/src# rm /lib/modules/$(uname -r)/build
root@N1:/usr/src# ln -s /usr/src/kernels/6.1.116-ophub /lib/modules/$(uname -r)/build

root@N1:/usr/src# ls -l /lib/modules/$(uname -r)/build
lrwxrwxrwx 1 root root 30 Nov 15 00:45 /lib/modules/6.1.116-ophub/build -> /usr/src/kernels/6.1.116-ophub

root@N1:/usr/src/hd2312-1.0# dkms add -m hd2312/1.0
Error! DKMS tree already contains: hd2312-1.0
You cannot add the same module/version combo more than once.
root@N1:/usr/src/hd2312-1.0# dkms build -m hd2312/1.0
Error! Your kernel headers for kernel 6.1.116-ophub cannot be found.
Please install the linux-headers-6.1.116-ophub package or use the --kernelsourcedir option to tell DKMS where it's located.

@LIUBANGJIAN
Copy link
Author

大佬不好意思,可以了。是我ln错了。
重新ln一下就好了
sudo ln -s /usr/src/linux-headers-6.1.116-ophub /lib/modules/6.1.116-ophub/build

现在就想想怎么编译内核的时候把驱动编译进去,这样方便后续编译固件。大佬可以指导一下嘛!非常感谢

@LIUBANGJIAN
Copy link
Author

大佬再请教一下,这打内核模块的模式,是不是升级内核模块就会失效啦?

@ophub
Copy link
Owner

ophub commented Nov 15, 2024

https://github.com/ophub/amlogic-s9xxx-armbian/blob/main/documents/README.cn.md

看仓库文档第9章,编译内核时添加补丁有文档。

@LIUBANGJIAN
Copy link
Author

https://github.com/ophub/amlogic-s9xxx-armbian/blob/main/documents/README.cn.md

看仓库文档第9章,编译内核时添加补丁有文档。

是的,这个我看了,我现在还卡着
#2614

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants