Character-driven device: no symbol version for module_layout solution

Problem Description

When writing the loading and unloading of the character device driver module, after make generates the module, copy the .ko file to the file system lib/module/4.1.15 folder, first use depmod to generate the other three files, and then Then use modprobe to load the module, there will be problems that no symbol version for module_layout and Invalid module format will cause the module to fail to load. However, what was said on the Internet about the inconsistency between the kernel version and the module driver version caused me to be confused. The reason for finding another problem later is because a file is missing in the kernel source code directory: Module.symvers.

Solutions

  1. First use the find /-name 'Module.symvers' command to find the path of the file, and then find it in the system's own folder under /usr/src/kernel//usr/src/linux-headers-4.15.0 -29-generic/Module.symvers.
  2. Open the Makefile compiled by the module, and find the following path (everyone is different, change it according to your own situation):
    Makefile
  3. Copy Module.symvers to the path framed in the above figure, and then compile again.
  4. After compiling, copy the .ko file to the lib/module/4.1.15 folder, first use depmod and then use modprobe xxx.ko to load the module. (Use lsmod to check whether the loading is successful)

operation result

The problem is solved, and the module is successfully loaded as expected.
result graph

Guess you like

Origin blog.csdn.net/dbqwcl/article/details/125596572