Error: could not insert module hello_ world.ko: Invalid module format

Why can’t you stop buying 618?From the technical dimension to explore>>>

There is a problem when compiling a print HelloWorld information driver module

insmod: ERROR: could not insert module hello_ world.ko: Invalid module format

The problem should be that the Linux header file directory selected when compiling the module does not match the currently running system version. Use the command: uname – r to view the currently running kernel version, and then select the correct Linux header file path. You can also download the Linux source code corresponding to the machine kernel. In this way, you can specify the Linux header file directory to the specified source code directory

After querying the kernel version information, modify the path in the makefile file file to make compilation and then load the kernel module

In addition, the information printed by the module’s printk cannot be directly displayed on the terminal. You can use dmesg to view the information since the power on, and you can see the information output by the printk. You can use dmesg | tail to view the last few messages. Rmmod can be used to remove the installed modules

Or you can use the dmesg command to check the possible error information:

It can be seen that the module version information of the previous Ko file does not match the current kernel version information. You can recompile the KO file that needs to be loaded: make helloworld.mk to get the new Ko file. At this time, you will find that it has passed when you reload the module

Reference article:

http://stackoverflow.com/questions/21244481/error-using-insmod-could-not-insert-module-hello-world-ko-invalid-module-forma

Similar Posts: