Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kernel version for target and for module

I'm trying to build a simple kernel module and run it on the Raspberry Pi. I have downloaded kernel sources from official raspberry site, but they have slightly different kernel version then my raspbian on board. Is it necessary to have fully identical version of kernel on source and target machine to run kernel module? I have this on my Raspberry Pi

$ uname -a
Linux raspberrypi 4.4.11+ #888 Mon May 23 20:02:58 BST 2016 armv6l GNU/Linux

And this about my module

$ modinfo ./threads.ko 
filename:       /lib/modules/4.4.11+/kernel/mymodules/./threads.ko
version:        0.0.1
description:    Kernel threads example
author:         xxxxxx
license:        GPL
srcversion:     C906582EC824D2D8DA76BFB
depends:        
vermagic:       4.4.13+ mod_unload modversions ARMv6 

As you see: "4.4.11+" vs "4.4.13+"... Why am I asking? I have a error when insert module:

$ sudo insmod ./threads.ko
insmod: ERROR: could not insert module ./threads.ko: Invalid module format

And do not understand, it is valuable difference in last number of version of the kernel or there is another problem.

like image 838
artsin Avatar asked Jun 20 '16 19:06

artsin


People also ask

What is the Linux kernel version of the target system?

To check Linux Kernel version, try the following commands: uname -r : Find Linux kernel version. cat /proc/version : Show Linux kernel version with help of a special file. hostnamectl | grep Kernel : For systemd based Linux distro you can use hotnamectl to display hostname and running Linux kernel version.

Are kernel modules specific to kernel version?

Kernel VersionsKernel modules must be specifically built to work with the Linux Kernel. To successfully run a Kernel Module on your target it must be built with the exact toolchain with the same header files that were used to build the Linux Distribution on your target.

How can a module be used with a kernel?

Kernel modules are pieces of code that can be loaded and unloaded into the kernel upon demand. They extend the functionality of the kernel without the need to reboot the system. A module can be configured as built-in or loadable.

What is the difference between kernel module and device driver?

a module is a "piece of software", of any kind. it is a part of the main kernel, not a "user program". a driver is a "piece of software" of one specific kind: it is needed to communicate with hardware components.


1 Answers

Is it necessary to have fully identical version of kernel on source and target machine to run kernel module?

Yes.

like image 131
Jonathon Reinhart Avatar answered Oct 19 '22 22:10

Jonathon Reinhart