Edit and compile a kernel module

五迷三道 提交于 2021-01-29 07:17:18

问题


I'm trying to edit one module from kernel source and compile it for kernel: 5.4.0-40-generic #44-Ubuntu.

This is how i did it:

    git clone git://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/focal
    git checkout -b temp Ubuntu-5.4.0-40.44
    nano drivers/media/usb/siano/smsusb.c
    make oldconfig
    make prepare
    make modules_prepare
    make SUBDIRS=scripts/mod
    make SUBDIRS=drivers/media/usb/siano modules
    cd drivers/media/usb/siano/
    insmod smsusb.ko
    

I got this error:

insmod: ERROR: could not insert module drivers/media/usb/siano/smsusb.ko: Invalid module format

My questions are:

  1. 'Invalid module format' suggest that the module is compiled to different version although i checked out the correct version, What is the problem?
  2. Why I need to compile the whole kernel, which consumes a lot of time, Is there a better method to compile only one module?

Update:

I copied the .ko to /lib/modules/... after that I've inserted the device that corresponds to the kernel module which results the following error in dmesg:

version magic '5.4.44+ SMP mod_unload ' should be '5.4.0-40-generic SMP mod_unload '

Thanks.

来源:https://stackoverflow.com/questions/64409182/edit-and-compile-a-kernel-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!